use of org.rocksdb.HashLinkedListMemTableConfig in project alluxio by Alluxio.
the class RocksStoreTest method backupRestore.
@Test
public void backupRestore() throws Exception {
ColumnFamilyOptions cfOpts = new ColumnFamilyOptions().setMemTableConfig(new HashLinkedListMemTableConfig()).setCompressionType(CompressionType.NO_COMPRESSION).useFixedLengthPrefixExtractor(// We always search using the initial long key
Longs.BYTES);
List<ColumnFamilyDescriptor> columnDescriptors = Arrays.asList(new ColumnFamilyDescriptor("test".getBytes(), cfOpts));
String dbDir = mFolder.newFolder("rocks").getAbsolutePath();
String backupsDir = mFolder.newFolder("rocks-backups").getAbsolutePath();
AtomicReference<ColumnFamilyHandle> testColumn = new AtomicReference<>();
RocksStore store = new RocksStore("test", dbDir, backupsDir, columnDescriptors, Arrays.asList(testColumn));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
RocksDB db = store.getDb();
int count = 10;
for (int i = 0; i < count; i++) {
db.put(testColumn.get(), new WriteOptions().setDisableWAL(true), ("a" + i).getBytes(), "b".getBytes());
}
store.writeToCheckpoint(baos);
String newBbDir = mFolder.newFolder("rocks-new").getAbsolutePath();
store = new RocksStore("test-new", newBbDir, backupsDir, columnDescriptors, Arrays.asList(testColumn));
store.restoreFromCheckpoint(new CheckpointInputStream(new ByteArrayInputStream(baos.toByteArray())));
db = store.getDb();
for (int i = 0; i < count; i++) {
assertArrayEquals("b".getBytes(), db.get(testColumn.get(), ("a" + i).getBytes()));
}
}
Aggregations