4 ms·
Indexing semantic versions in RocksDB
- zokier 3y agoI don't know anything about rocksdb, but this approach on surface level seems like it could be very slow? Wouldn't it be more efficient to encode the semver in a format more suitable to sorting
- hdhfjkrkrme 3y agoSure, the old performance/productivity tradeoff. This quickly solves the problem then you can iterate for performance.
- adamretter 3y agoBy default RocksDB uses a ByteWiseComparator to sort the keys in the SST. However, RocksDB allows you to provide any comparator you wish. So ultimately it will depend on the performance of the comparator that you implement.
- utopcell 3y ago> "The technical primitive data structure here is a hashmap where the keys are sorted." ..somewhere, this person's algorithms teacher is pondering about his life choices.
- klysm 3y agoI don’t see why that’s a particularly bad explanation of how RocksDB works
- morelisp 3y agoIt's not using hashes. (OK, well, it is maybe using hashes for the per-SST Bloom filter, but that's not what's interesting here. It's maybe also using hashes in the memtable in which case they're using it very inefficiently since the key encoding is not prefix-scan-friendly.)
- gnulinux 3y ago> The technical primitive data structure here is a hashmap where the keys are sorted. Why not a tree based map instead?
- The_Colonel 3y agoHashMap and sorted keys sounds like a contradiction. I think they just use "HashMap" as a generic term for "Map" and it's actually a tree based map.
- morelisp 3y agoIt is an LSMT, but I cannot imagine why they would need one here.
- samsquire 3y agoI am curious, I recently wrote a naive hashmap for C. I am curious about iterating in insert and sort order. Is it possible for a hash function to maintain a sort relationship to it's input and output?
- hdhfjkrkrme 3y agoIf you iterate a python dictionary it will return the keys in insert order. For sort order you need to sort separately.
- blyzz 3y agoSupporting insertion order is straightforward (but has some trade-offs) - you store the values in a backing array or linked list, and the hash table array stores pointers to the values. You could do something similar with a sorted data structure backing the hashmap to get sorted order (a b-tree or something similar). You could have the hash function preserve order at the cost of it being a very bad hash function. If you had n buckets, then the first 1/n elements in the keyspace would map to bucket 0, then next 1/n elements map to bucket 1, etc.
- morelisp 3y agoUsing RocksDB here seems fairly insane unless you need to keep (at least) several billion constantly-updating versions sorted. Otherwise you can just use SortedMap and regular Java comparators.
- curtisblaine 3y agoThey might just want cheap disk persistence. I'm not a Java developer, but if SortedMaps are a memory-only data structure, persisting them reliably doesn't look an easy feat.
- morelisp 3y agoRocksDB is disk persistence but it sure ain't (for this scale) cheap. Persisting just about anything in Java is easier than persisting it in Java in RocksDB.
- curtisblaine 3y agoHow would you persist a Sorted Map in Java easily? Serializing and deserializing is OK, but keep in mind that if the program crashes you still need to persist all the data that was saved before the crash (so you can't keep in memory and serialize at exit, or at a time interval)
- morelisp 3y agoGiven the size of any dataset of the type being discussed here, you dump the whole thing to disk on every change.