org.rocksdb.LRUCache Java Examples
The following examples show how to use
org.rocksdb.LRUCache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RocksDBResourceContainerTest.java From flink with Apache License 2.0 | 5 votes |
private OpaqueMemoryResource<RocksDBSharedResources> getSharedResources() { final long cacheSize = 1024L, writeBufferSize = 512L; final LRUCache cache = new LRUCache(cacheSize, -1, false, 0.1); final WriteBufferManager wbm = new WriteBufferManager(writeBufferSize, cache); RocksDBSharedResources rocksDBSharedResources = new RocksDBSharedResources(cache, wbm); return new OpaqueMemoryResource<>(rocksDBSharedResources, cacheSize, rocksDBSharedResources::close); }
Example #2
Source File: RocksDBResourceContainerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFreeSharedResourcesAfterClose() throws Exception { LRUCache cache = new LRUCache(1024L); WriteBufferManager wbm = new WriteBufferManager(1024L, cache); RocksDBSharedResources sharedResources = new RocksDBSharedResources(cache, wbm); final ThrowingRunnable<Exception> disposer = sharedResources::close; OpaqueMemoryResource<RocksDBSharedResources> opaqueResource = new OpaqueMemoryResource<>(sharedResources, 1024L, disposer); RocksDBResourceContainer container = new RocksDBResourceContainer(PredefinedOptions.DEFAULT, null, opaqueResource); container.close(); assertThat(cache.isOwningHandle(), is(false)); assertThat(wbm.isOwningHandle(), is(false)); }
Example #3
Source File: RocksDBColumnarKeyValueStorage.java From besu with Apache License 2.0 | 4 votes |
private BlockBasedTableConfig createBlockBasedTableConfig(final RocksDBConfiguration config) { final LRUCache cache = new LRUCache(config.getCacheCapacity()); return new BlockBasedTableConfig().setBlockCache(cache); }
Example #4
Source File: RocksDBKeyValueStorage.java From besu with Apache License 2.0 | 4 votes |
private BlockBasedTableConfig createBlockBasedTableConfig(final RocksDBConfiguration config) { final LRUCache cache = new LRUCache(config.getCacheCapacity()); return new BlockBasedTableConfig().setBlockCache(cache); }
Example #5
Source File: RocksDbInstanceFactory.java From teku with Apache License 2.0 | 4 votes |
private static BlockBasedTableConfig createBlockBasedTableConfig( final RocksDbConfiguration config) { final LRUCache cache = new LRUCache(config.getCacheCapacity()); return new BlockBasedTableConfig().setBlockCache(cache); }
Example #6
Source File: RocksDBCache.java From kcache with Apache License 2.0 | 4 votes |
private void openDB() { // initialize the default rocksdb options final DBOptions dbOptions = new DBOptions(); final ColumnFamilyOptions columnFamilyOptions = new ColumnFamilyOptions(); userSpecifiedOptions = new RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapter(dbOptions, columnFamilyOptions); userSpecifiedOptions.setComparator(new RocksDBKeySliceComparator<>(keySerde, comparator)); final BlockBasedTableConfig tableConfig = new BlockBasedTableConfig(); cache = new LRUCache(BLOCK_CACHE_SIZE); tableConfig.setBlockCache(cache); tableConfig.setBlockSize(BLOCK_SIZE); filter = new BloomFilter(); tableConfig.setFilterPolicy(filter); userSpecifiedOptions.optimizeFiltersForHits(); userSpecifiedOptions.setTableFormatConfig(tableConfig); userSpecifiedOptions.setWriteBufferSize(WRITE_BUFFER_SIZE); userSpecifiedOptions.setCompressionType(COMPRESSION_TYPE); userSpecifiedOptions.setCompactionStyle(COMPACTION_STYLE); userSpecifiedOptions.setMaxWriteBufferNumber(MAX_WRITE_BUFFERS); userSpecifiedOptions.setCreateIfMissing(true); userSpecifiedOptions.setErrorIfExists(false); userSpecifiedOptions.setInfoLogLevel(InfoLogLevel.ERROR_LEVEL); // this is the recommended way to increase parallelism in RocksDb // note that the current implementation of setIncreaseParallelism affects the number // of compaction threads but not flush threads (the latter remains one). Also // the parallelism value needs to be at least two because of the code in // https://github.com/facebook/rocksdb/blob/62ad0a9b19f0be4cefa70b6b32876e764b7f3c11/util/options.cc#L580 // subtracts one from the value passed to determine the number of compaction threads // (this could be a bug in the RocksDB code and their devs have been contacted). userSpecifiedOptions.setIncreaseParallelism(Math.max(Runtime.getRuntime().availableProcessors(), 2)); wOptions = new WriteOptions(); wOptions.setDisableWAL(true); fOptions = new FlushOptions(); fOptions.setWaitForFlush(true); dbDir = new File(new File(rootDir, parentDir), name); try { Files.createDirectories(dbDir.getParentFile().toPath()); Files.createDirectories(dbDir.getAbsoluteFile().toPath()); } catch (final IOException fatal) { throw new CacheInitializationException("Could not create directories", fatal); } openRocksDB(dbOptions, columnFamilyOptions); open = true; }
Example #7
Source File: RocksDBMemoryControllerUtils.java From flink with Apache License 2.0 | 4 votes |
@VisibleForTesting static Cache createCache(long cacheCapacity, double highPriorityPoolRatio) { // TODO use strict capacity limit until FLINK-15532 resolved return new LRUCache(cacheCapacity, -1, false, highPriorityPoolRatio); }