Hash-index @ SwayDB
哈希索引将随机读取性能提高了55%!

哈希索引,例如哈希集要么哈希图对于处理随机读取请求很有用。 它们提高了随机访问数据的性能,减少了IOps的总数并节省了CPU时间。 但是对于那些需要很少像这样随机读取
- 时间序列要么事件源数据可能只需要快速顺序读取。
- 冷库要么存档数据可能根本不需要随机读取。
A configurable hash-index is required for SwayDB so various data storage requirements could be handled. 以下是要求:
- (可选)启用或禁用哈希索引。
- 允许创建完美或接近完美的哈希索引。
- Create partially indexed hash-indexes with fallback to alternative indexes like binary-search & linear-search.
- 将密钥直接复制到哈希索引中。
- 受控并发。
- 压缩。
Example configuration
下面创建一个持久的地图禁用哈希索引的位置。
Map<Integer, String, Void> map =
.functionsOff(Paths.get("myMap"), intSerializer(), stringSerializer())
.set随机关键字索引(RandomKeyIndex.disable())
map.get(1); //Optional[one]
以下启用哈希索引(RandomKeyIndex)与自定义配置。
Map<Integer, String, Void> map =
.functionsOff(Paths.get("myMap"), intSerializer(), stringSerializer())
.maxProbe(10) //re-hash 10 times to resolve hash collision
.minimumNumberOfKeys(20) //minimum keys required
.minimumNumberOfHits(10) //minimum indexed keys required
//use reference format. IndexFormat.copyKeys() can also be used here
//to copy keys directly into the hash-index
.indexFormat(IndexFormat.reference())
(RandomKeyIndex.RequiredSpace optimalSpace) ->
//allocates 3 times more storage than the
//default optimal space for higher hit rate.
optimalSpace.requiredSpace() * 3
//allow async IO for all IO operations
.ioStrategy((IOAction ioAction) -> new IOStrategy.AsyncIO(true))
//Use LZ4 and fallback to Snappy.
.compression((UncompressedBlockInfo info) ->
//try running LZ4 with minimum 20.0% compression
new Pair(LZ4Instance.fastestInstance(), new LZ4Compressor.Fast(20.0)),
new Pair(LZ4Instance.fastestInstance(), LZ4Decompressor.fastDecompressor())
//if LZ4 fails try Snappy with 20.0% compression.
new Compression.Snappy(20.0)
map.get(1); //Optional[one]
For a detail documentation of the configurations refer to documentation website.
from: https://dev.to//simerplaha/hash-index-swaydb-4k8
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69999831/viewspace-3164808/
,如需转载,请注明出处,否则将追究法律责任。