RocksDbTableDescriptor extends LocalTableDescriptor<K, V, RocksDbTableDescriptor<K, V>> { @Override public Map<String, String> toConfig(Config jobConfig) { Map<String, String> tableConfig = new HashMap<>(super.toConfig(jobConfig)); tableConfig.put(String.format(StorageConfig.FACTORY, tableId), RocksDbKeyValueStorageEngineFactory.class.getName()); if (writeBatchSize != null) { addStoreConfig(WRITE_BATCH_SIZE, writeBatchSize.toString(), tableConfig); } if (objectCacheSize != null) { addStoreConfig(OBJECT_CACHE_SIZE, objectCacheSize.toString(), tableConfig); } if (cacheSize != null) { addStoreConfig(CONTAINER_CACHE_SIZE_BYTES, cacheSize.toString(), tableConfig); } if (writeBufferSize != null) { addStoreConfig(CONTAINER_WRITE_BUFFER_SIZE_BYTES, writeBufferSize.toString(), tableConfig); } if (compressionType != null) { addStoreConfig(ROCKSDB_COMPRESSION, compressionType, tableConfig); } if (blockSize != null) { addStoreConfig(ROCKSDB_BLOCK_SIZE_BYTES, blockSize.toString(), tableConfig); } if (ttl != null) { addStoreConfig(ROCKSDB_TTL_MS, ttl.toString(), tableConfig); } if (compactionStyle != null) { addStoreConfig(ROCKSDB_COMPACTION_STYLE, compactionStyle, tableConfig); } if (numWriteBuffers != null) { addStoreConfig(ROCKSDB_NUM_WRITE_BUFFERS, numWriteBuffers.toString(), tableConfig); } if (maxLogFileSize != null) { addStoreConfig(ROCKSDB_MAX_LOG_FILE_SIZE_BYTES, maxLogFileSize.toString(), tableConfig); } if (numLogFilesToKeep != null) { addStoreConfig(ROCKSDB_KEEP_LOG_FILE_NUM, numLogFilesToKeep.toString(), tableConfig); } return Collections.unmodifiableMap(tableConfig); } RocksDbTableDescriptor(String tableId, KVSerde<K, V> serde); RocksDbTableDescriptor withWriteBatchSize(int writeBatchSize); RocksDbTableDescriptor withObjectCacheSize(int objectCacheSize); RocksDbTableDescriptor<K, V> withCacheSize(int cacheSize); RocksDbTableDescriptor<K, V> withWriteBufferSize(int writeBufferSize); RocksDbTableDescriptor<K, V> withCompressionType(String compressionType); RocksDbTableDescriptor<K, V> withBlockSize(int blockSize); RocksDbTableDescriptor<K, V> withTtl(long ttl); RocksDbTableDescriptor<K, V> withCompactionStyle(String compactionStyle); RocksDbTableDescriptor<K, V> withNumWriteBuffers(int numWriteBuffers); RocksDbTableDescriptor<K, V> withMaxLogFileSize(int maxLogFileSize); RocksDbTableDescriptor<K, V> withNumLogFilesToKeep(int numLogFilesToKeep); @Override String getProviderFactoryClassName(); @Override Map<String, String> toConfig(Config jobConfig); static final public String WRITE_BATCH_SIZE; static final public String OBJECT_CACHE_SIZE; static final public String CONTAINER_CACHE_SIZE_BYTES; static final public String CONTAINER_WRITE_BUFFER_SIZE_BYTES; static final public String ROCKSDB_COMPRESSION; static final public String ROCKSDB_BLOCK_SIZE_BYTES; static final public String ROCKSDB_TTL_MS; static final public String ROCKSDB_COMPACTION_STYLE; static final public String ROCKSDB_NUM_WRITE_BUFFERS; static final public String ROCKSDB_MAX_LOG_FILE_SIZE_BYTES; static final public String ROCKSDB_KEEP_LOG_FILE_NUM; }
@Test public void testMinimal() { Map tableConfig = createTableDescriptor() .toConfig(createJobConfig()); Assert.assertNotNull(tableConfig); Assert.assertEquals(2, tableConfig.size()); }
@Test public void testTableProviderFactoryConfig() { Map tableConfig = createTableDescriptor() .toConfig(createJobConfig()); Assert.assertEquals(2, tableConfig.size()); Assert.assertEquals(LocalTableProviderFactory.class.getName(), tableConfig.get(String.format(JavaTableConfig.TABLE_PROVIDER_FACTORY, TABLE_ID))); Assert.assertEquals(RocksDbKeyValueStorageEngineFactory.class.getName(), tableConfig.get(String.format(StorageConfig.FACTORY, TABLE_ID))); }