用于JVM的高性能持久LSM key-value存儲庫:HeftyDB
HeftyDB是一個用于JVM的高性能持久LSM key-value存儲庫。它的設計充分考慮了以下目標:
- Be as fast and memory efficient as is feasible on the JVM for random reads, random writes, and range scans.
- Provide a stable base on which to build new and interesting storage systems.
- Provide detailed metrics about what is going on at every level of the stack.
- Have clean, understandable code that others can learn from. </ol>
特性
Simple API
Supports gets and puts by key as well as ascending and descending iteration from any key.
Log Structured Merge Trees
All write operations are sequential, and are limited by the sequential IO performance of the underlying disk. Tables are written with a full B+tree index for memory efficiency, even at very large table sizes.
Snapshotted multi-version concurrency control
Reads and range scans never block writes.
Off-heap data structures
Operations in the critical read and write paths are implemented using off-heap memory wherever possible to reduce GC pressure and memory overhead.
Multi-threaded compactions
Make use of multiple CPU cores for table writes and table compactions
Pluggable compaction strategies
Provide custom compaction behavior tailored to specific workloads.
try { //Open a HeftyDB in a directory DB testDB = HeftyDB.open(new Config.Builder().directory(directory).build()); //Write a key Snapshot snapshot = testDB.put(someByteBufferKey, someByteBufferValue); //Read a key at a particular snapshot Record record = testDB.get(someByteBufferKey, snapshot); //Delete a key Snapshot deleteSnapshot = testDB.delete(someByteBufferKey); //Get an ascending iterator of keys greater than or equal //to the provided key at the provided snapshot CloseableIterator<Record> ascendingIterator = testDB.ascendingIterator(someByteBufferKey, snapshot); while (ascendingIterator.hasNext()){ Record next = ascendingIterator.next(); } //Get a descending iterator of keys less than or equal //to the provided key at the provided snapshot CloseableIterator<Record> descendingIterator = testDB.descendingIterator(someByteBufferKey, snapshot); while (descendingIterator.hasNext()){ Record next = descendingIterator.next(); } //Compact the database Future<?> compactionFuture = testDB.compact(); compactionFuture.get(); //Close the database testDB.close(); } catch (IOException e){ Logger.error(e); }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!