Alternative to dictionary for search

I have a requirement to build a lookup table. I use a dictionary. It contains 45M long and 45M int. long as a key and int as a value. the size of the collection is (45M * 12), where long is 8 bytes and int is 4 bytes. The size is about 515 MB. But in fact, the size of the process is 1.3 GB. The process contains only this lookup table. Mother, is there an alternative to the dictionary?

thank

+3
source share
5 answers

How much effort are you willing to spend?
you can use

KeyValuePair<long,int>[] table = new KeyValuePair<long,int> [45 M];

then sort this in the first column ( long Key) and use binary search to find your values.

+3
source

SortedList , , , :)

+1

, , , , , . , (25 +%). , - ( ), , , , ( , , GC , , ).

, , , , ? ( ​​ ), , . ?

+1

10 ^ 12, , , , int. , - : 512

 var myData = new Dictionary<int,int>[512];

int, ( "" ), :

myData[key & 511].Add((int) (key >> 9), intValue);
int result = myData[(int) (key & 511)][(int) (key >> 9)];

, , , , , , .

+1

, , : - int. , N N . Array.BinarySearch, , .

0

All Articles