C
C
click_f2016-10-25 12:29:55
Java
click_f, 2016-10-25 12:29:55

What data structure to choose for storing data in memory?

It is required to store a large number of users (2-3 million). Each user has a set of attributes. For some purposes it is necessary to quickly list users in descending/ascending order of some of the given attributes.

  1. The question is what structure would be best to use for this in general?
  2. Does it make sense to write binary heap from scratch?
  3. Which of the existing java data structures is best for this purpose?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2016-10-25
@leahch

Why do it directly in the application? Take, for example, redis.io, and store it in it. There, not only sortedset, but also hash and counterers and a bunch of other things are implemented. It works fast, lies in memory, clusters and shards.
In your case, it would be more convenient to keep your attributes in a sortedset, where the collection name = attribute, and the values ​​are user ids.

R
Rou1997, 2016-10-25
@Rou1997

Do you need to remove all users at once? Or maybe it's not worth keeping so much in memory?
It’s better that it’s not Java, but C / C ++, use JNI for this, otherwise it will take up a lot of RAM, and performance is unlikely to be up to par.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question