Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 months ago.
Improve this question
I have been looking around in the documentation, but could not find an explanation of what the "int2vector" type really is. It is found in some system tables like pg_trigger, but that's all a documentation search returns...
It seems to be vaguely similar to int2array, but has a different OID (INT2VECTOROID is 22, INT2ARRAYOID is 1005).
I have found ways to generate int2array in SQL (for instance with SELECT cast('{1,2}' as int2[])), but not int2vector.
The question applies to int4vector & int4array as well, and the uses case is when interfacing with libpq in binary format.
int2vector is an obsolete data type for arrays of smallint from the time before PostgreSQL had array data types. Today you would use smallint[].
You shouldn't use int2vector in your table definitions, as it is not documented. On the other hand, it is unlikely to get removed, since the catalog tables make use of that data type for historical reasons. There is no advantage to be had by using int2vector.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
My app involves repeated equality comparisons of many megabytes of an array of strings. I was (naively?) surprised that such comparisons became immensely faster when I added a shadow array of the count of each string; if the counts are not equal, the strings cannot be equal.
I would have thought that the Swift compiler could easily and efficiently maintain a string's count in the internal representation, and short-circuit string equality comparisons if the counts differ. The initial creation of each string would provide the opportunity to initialize the count, and each manipulation would then know the count of each participant. But it seems not so. If only some applications would benefit from a stored count, a compiler switch to turn it on could help them.
Would this be a reasonable standard library refinement?
The problem with String is that it is not stored always in the same way. There are different types of storage and for them to be properly compared, they have to be converted to the same representation first.
Looking into the source code here: StringComparison.swift, I think you are right and count should be compared first when checking equality.
I recommend filing a bug.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have this code, and it is supposed to write to Firestore. However, when it does the function, in the back end, it shows highlighted as red and then disappears.
db.collection("jokes").document("Dad Jokes").setData(["\(dadJokeNum + 1)": Joke.text!])
Please help.
Using SetData without Merge will delete existing values - it is suggested that if the document exists prior, you should always be using merge: true. Firestore also has a limited 1 write per second each, you should be managing writes together as it is most likely similar writes will conflict and potentially resolve out of order.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am thinking about using snake_case in my mongoDB-documents due to convention in the project.
As I researched here, camelCase seems to be a standard in mongodb due to its BSON-storage.
My documents are for example
{
"created_at": "",
"issuer": "my-user-name",
"document_id": "81234-guid",
"file_id": "81234-another-guid",
"details": {
...
}
}
As you see, I under snake_case. That means that many of my field names are one char longer.
How does this affect the storage?
Is there any compression or algorithm, that stores field names separatly or is really each field name stored within the BSON?
In my use case the collection there will have many small entries
For each document there will be about 10 entities stored in mongodb.
There will be about 1.000.000.000 documents, meaning at least 10.000.000.000 entities stored in collection.
The database does not prescribe how to name fields (other than there must be a field named _id).
In Ruby for example the convention is to use underscore style as you are contemplating.
If you want to use short field names for storage optimization, changing from camel case to underscore will be much less of a difference than actually using shorter field names (for example n instead of count, etc.).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 2 years ago.
Improve this question
I have a method that I want to call with different test data that is stored in either JSON or excel or in the form of the properties file. Is there a concept of DataProvider in NUnit like we have in TestNG?
NUnit has a number of attributes, which are used to provide data to test methods. A good starting point in the documentation to see them all is https://github.com/nunit/docs/wiki/Parameterized-Tests , which links to lots of information.
All of the built-in attributes allow for data to be provided programmatically, but NUnit does not have any attributes that fetch the data from a file or other external source.
There are two ways that people normally deal with this:
Use an existing attribute (e.g. [TestCaseSource] and write a method that will read the external data and supply test cases.
Create an in-house custom attribute that takes the name of a particular type of source, opens it, reads the data and creates the test cases.
Typically, folks start out with (1), which is simpler to implement and then - if and when necessary - migrate the same code to (2) by incorporating it within a custom attribute.
For info about writing Custom Attributes (if you need to) start with https://github.com/nunit/docs/wiki/Custom-Attributes
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am looking for a simple example of State monad in a business application.
I have found good examples -- memoisation to calculate Fibonacci numbers and random numbers generation -- but I would like to see an example from a business domain (preferably in Scala).
For example, I can easily find examples of using Option, Either, List, Reader, and Writer monads:
option : look up an entity (order, product, customer, whatever) which does not exist
either : any failure
list : customer orders, order items, etc.
reader : read any entity from the database
writer : write to the log
Now I am looking for something similar for State monad, i.e. any stateful computation with a mutable state, as I understand it.
The typical application where I reach for State is where I need a supply of values, like a random number generator or a supply of unique identifiers.
Another typical use case is testing an application that interacts with a database. Using State, you can simulate an in-memory database and check that the program manipulates the database in the expected way.