Tabnine Logo
RocksDbKeyValueReader
Code IndexAdd Tabnine to your IDE (free)

How to use
RocksDbKeyValueReader
in
org.apache.samza.storage.kv

Best Java code snippets using org.apache.samza.storage.kv.RocksDbKeyValueReader (Showing top 7 results out of 315)

origin: org.apache.samza/samza-kv-rocksdb_2.11

 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();
 }
}
origin: apache/samza

/**
 * Construct the <code>RocksDbKeyValueReader</code> with store's name,
 * database's path and Samza's config
 *
 * @param storeName name of the RocksDb defined in the config file
 * @param dbPath path to the db directory
 * @param config Samza's config
 */
public RocksDbKeyValueReader(String storeName, String dbPath, Config config) {
 // get the key serde and value serde from the config
 JavaStorageConfig storageConfig = new JavaStorageConfig(config);
 JavaSerializerConfig serializerConfig = new JavaSerializerConfig(config);
 keySerde = getSerdeFromName(storageConfig.getStorageKeySerde(storeName), serializerConfig);
 valueSerde = getSerdeFromName(storageConfig.getStorageMsgSerde(storeName), serializerConfig);
 // get db options
 Options options = RocksDbOptionsHelper.options(config, 1, new File(dbPath), StorageEngineFactory.StoreMode.ReadWrite);
 // open the db
 RocksDB.loadLibrary();
 try {
  db = RocksDB.openReadOnly(options, dbPath);
 } catch (RocksDBException e) {
  throw new SamzaException("can not open the rocksDb in " + dbPath, e);
 }
}
origin: org.apache.samza/samza-kv-rocksdb

/**
 * Construct the <code>RocksDbKeyValueReader</code> with store's name,
 * database's path and Samza's config
 *
 * @param storeName name of the RocksDb defined in the config file
 * @param dbPath path to the db directory
 * @param config Samza's config
 */
public RocksDbKeyValueReader(String storeName, String dbPath, Config config) {
 // get the key serde and value serde from the config
 JavaStorageConfig storageConfig = new JavaStorageConfig(config);
 JavaSerializerConfig serializerConfig = new JavaSerializerConfig(config);
 keySerde = getSerdeFromName(storageConfig.getStorageKeySerde(storeName), serializerConfig);
 valueSerde = getSerdeFromName(storageConfig.getStorageMsgSerde(storeName), serializerConfig);
 // get db options
 Options options = RocksDbOptionsHelper.options(config, 1);
 // open the db
 RocksDB.loadLibrary();
 try {
  db = RocksDB.openReadOnly(options, dbPath);
 } catch (RocksDBException e) {
  throw new SamzaException("can not open the rocksDb in " + dbPath, e);
 }
}
origin: apache/samza

 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();
 }
}
origin: org.apache.samza/samza-kv-rocksdb_2.11

/**
 * Construct the <code>RocksDbKeyValueReader</code> with store's name,
 * database's path and Samza's config
 *
 * @param storeName name of the RocksDb defined in the config file
 * @param dbPath path to the db directory
 * @param config Samza's config
 */
public RocksDbKeyValueReader(String storeName, String dbPath, Config config) {
 // get the key serde and value serde from the config
 JavaStorageConfig storageConfig = new JavaStorageConfig(config);
 JavaSerializerConfig serializerConfig = new JavaSerializerConfig(config);
 keySerde = getSerdeFromName(storageConfig.getStorageKeySerde(storeName), serializerConfig);
 valueSerde = getSerdeFromName(storageConfig.getStorageMsgSerde(storeName), serializerConfig);
 // get db options
 Options options = RocksDbOptionsHelper.options(config, 1);
 // open the db
 RocksDB.loadLibrary();
 try {
  db = RocksDB.openReadOnly(options, dbPath);
 } catch (RocksDBException e) {
  throw new SamzaException("can not open the rocksDb in " + dbPath, e);
 }
}
origin: org.apache.samza/samza-kv-rocksdb

 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();
 }
}
origin: apache/samza

@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();
}
org.apache.samza.storage.kvRocksDbKeyValueReader

Javadoc

This class is to read the RocksDb according to the provided directory position

Most used methods

  • <init>
    Construct the RocksDbKeyValueReader with store's name, database's path and Samza's config
  • get
    get the value from the key. This key will be serialized to bytes using the serde defined in systems.
  • stop
  • getSerdeFromName
    A helper method to get the Serde from the serdeName

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Runner (org.openjdk.jmh.runner)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now