How is sorting done in cassandra? [closed] - database

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am a newbie in Cassandra.
Does Cassandra follow any specified sorting algorithm like bubble sort, binary sort, etc.? If not, How does it sort in order by command?

It doesn't, or at least it shouldn't. In Cassandra you build your data model around your use cases. So if you want to retrieve sorted data you have to store it sorted. If you want the same data sorted in different ways, you store the same data multiple times sorted differently. There is a lot more to read about how Cassandra works, and I think every user of Cassandra should.
Links related to your question:
https://docs.datastax.com/en/cql/3.3/cql/cql_using/useSimplePrimaryKeyConcept.html
https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCompoundPrimaryKeyConcept.html
https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlCreateIndex.html
Getting started with Cassandra:
https://academy.datastax.com/courses (the first two courses is a must do. You need to register but they 100% free)

Related

How to generate unique ids in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am developing an app which requires to generate an id for new users I want to do it with the smallest number of characters that allows me to create 100 billion diferent possible ids so how should I do that and how to avoid giving two users the same it? Should I look if that id exists? Should I use a random id generator or give ids in order like 001 002 and so on?
This depends entirely on what kind of functionality you expect from this id, do you intend for these id's to correlate with persisted data, such as a database? If this is the case, it might be more prudent to let the database handle the unique ID generation for you. Otherwise, using sequential values such as 1,2,3... etc would probably be ideal. unsigned long will keep you covered for the first 2 billion users... If you somehow go beyond that, you can rethink your data storage then.
The question is very broad.

Is NSOrderedSet faster than NSSet? [closed]

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 6 years ago.
Improve this question
Is NSOrderedSet faster than NSSet? Has anyone done any tests where on is better over the other? If not why was NSOrderedSet introduced in the first place?
NSOrderedSet
The point of using an ordered set is that it is traversable in its original order in which items were added to it, and querying whether an object is contained is faster than for an unordered array. The "contains" operation (and set operations that build on it) is however slower than the O(1) that's possible with an unordered set for that operation.
Unordered set
The point of a set is that it allows for a best case O(1) "contains" query time. It is the data structure you should use out of these two when you need as fast "contains" time and do not need to retrieve the items in the structure in any specified sort order.
It is internally probably implemented as a hash map, although it's not pointed out in the Foundation documentation.
I'd advise reading this great blog post regarding the different uses of the different Foundation data structures.

Bullet Points and Databases [closed]

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 received a list from a customer using bullet points, and then sub bullet points. What is the best way to store these in a Postgres database, if you could give me an example of this, that would be great.
Thanks!
Structure of it is something similar to this:
Defect1
possible instance of defect1
another possible instance of defect1
Defect2
possible instance of defect2
another possible instance of defect2...
For indented lists you're basically talking about a tree structure. There are many ways to store hierarchies. See this answer for a comparison.
Design Relational Database - Use hierarchical datamodels or avoid them?
Depending on how you want to use the data, i.e., if you're just going to spit it back out as it came in, you may be able to skip the hierarchy aspect in this particular use case and just store each line in sequence with an indentation field. It won't do nearly what can be done with a tree, but it may be all that's needed in your particular case.

Database Design for similar data across multiple time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am attempting to come up with a Database Design that works well for a specific division of my company.
Basically, I have a list of Account Numbers with a ton of fields associated with them. My division needs to compare how these fields change over time (What was in that field for this account number a year ago?).
I am currently thinking of a very linear approach where I use only one large table for the data that is time stamped so a table would have the name AccountInfo04012013 and then the next month would be a new table called AccountInfo05012013. This way we can make comparisons between any two months.
What are the drawbacks of this plan? and what should I be doing instead?
You are going to have to use timestamps. All database managers will have this built in.

parsing a large file for some information in a single parse [closed]

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 8 years ago.
Improve this question
I have a large file that contains a particular structure.I want to know the top 10 most commonly occurring values for a particular fields in the structure.Will I be able to do it in a single parse?
You'll need to store and update an associative array that contains the field and number of occurrences. Depending on how many different fields there are, your memory will be the limitation.
After that's done, do a sort of the array based on the value.
AFAIK, C does not include an associative array data type, so you'll need to use a 3rd party library, see Looking for a good hash table implementation in C for some options.
As for sorting, there is http://linux.die.net/man/3/qsort.
So ignoring possible memory requirements, you can do it in one pass.

Resources