@Test public void testReadCorrectDbValue() throws RocksDBException { HashMap<String, String> map = new HashMap<String, String>(); map.put("stores." + DB_NAME + ".factory", "mockFactory"); map.put("stores." + DB_NAME + ".key.serde", "string"); map.put("stores." + DB_NAME + ".msg.serde", "string"); Config config = new MapConfig(map); RocksDbKeyValueReader reader = new RocksDbKeyValueReader(DB_NAME, dirPath.toString(), config); assertEquals("this is string", reader.get("testString")); // should throw exception if the input is in other type boolean throwClassCastException = false; try { reader.get(123); } catch (Exception e) { if (e instanceof ClassCastException) { throwClassCastException = true; } } assertTrue(throwClassCastException); reader.stop(); // test with customized serde map.put("serializers.registry.mock.class", IntegerSerdeFactory.class.getCanonicalName()); map.put("stores." + DB_NAME + ".key.serde", "mock"); map.put("stores." + DB_NAME + ".msg.serde", "mock"); config = new MapConfig(map); reader = new RocksDbKeyValueReader(DB_NAME, dirPath.toString(), config); assertEquals(456, reader.get(123)); assertNull(reader.get(789)); reader.stop(); }
public static void main(String[] args) throws RocksDBException { RocksDbReadingTool tool = new RocksDbReadingTool(); OptionSet options = tool.parser().parse(args); MapConfig config = tool.loadConfig(options); String path = tool.getDbPath(); String dbName = tool.getDbName(); RocksDbKeyValueReader kvReader = new RocksDbKeyValueReader(dbName, path, config); for (Object obj : tool.getKeys()) { Object result = kvReader.get(obj); tool.outputResult(obj, result); } kvReader.stop(); } }
public static void main(String[] args) throws RocksDBException { RocksDbReadingTool tool = new RocksDbReadingTool(); OptionSet options = tool.parser().parse(args); MapConfig config = tool.loadConfig(options); String path = tool.getDbPath(); String dbName = tool.getDbName(); RocksDbKeyValueReader kvReader = new RocksDbKeyValueReader(dbName, path, config); for (Object obj : tool.getKeys()) { Object result = kvReader.get(obj); tool.outputResult(obj, result); } kvReader.stop(); } }
public static void main(String[] args) throws RocksDBException { RocksDbReadingTool tool = new RocksDbReadingTool(); OptionSet options = tool.parser().parse(args); MapConfig config = tool.loadConfig(options); String path = tool.getDbPath(); String dbName = tool.getDbName(); RocksDbKeyValueReader kvReader = new RocksDbKeyValueReader(dbName, path, config); for (Object obj : tool.getKeys()) { Object result = kvReader.get(obj); tool.outputResult(obj, result); } kvReader.stop(); } }