Search in sources :

Example 1 with KeyValueStoreWriter

use of alluxio.client.keyvalue.KeyValueStoreWriter in project alluxio by Alluxio.

the class KeyValueStoreOperations method call.

@Override
public Boolean call() throws Exception {
    Configuration.set(PropertyKey.KEY_VALUE_ENABLED, String.valueOf(true));
    Configuration.set(PropertyKey.KEY_VALUE_PARTITION_SIZE_BYTES_MAX, String.valueOf(mPartitionLength));
    KeyValueSystem kvs = KeyValueSystem.Factory.create();
    KeyValueStoreWriter writer = kvs.createStore(mStoreUri);
    putKeyValuePairs(writer);
    writer.close();
    KeyValueStoreReader reader = kvs.openStore(mStoreUri);
    boolean pass = getKeyValuePairs(reader);
    reader.close();
    return pass;
}
Also used : KeyValueStoreWriter(alluxio.client.keyvalue.KeyValueStoreWriter) KeyValueSystem(alluxio.client.keyvalue.KeyValueSystem) KeyValueStoreReader(alluxio.client.keyvalue.KeyValueStoreReader)

Example 2 with KeyValueStoreWriter

use of alluxio.client.keyvalue.KeyValueStoreWriter in project alluxio by Alluxio.

the class KeyValueStoreQuickStart method main.

/**
   * The main program.
   *
   * @param args one argument which is the path of the new key-value store
   * @throws Exception if any exception happens
   */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("Usage: java -cp " + RuntimeConstants.ALLUXIO_JAR + " " + KeyValueStoreQuickStart.class.getName() + " <key-value store URI>");
        System.exit(-1);
    }
    AlluxioURI storeUri = new AlluxioURI(args[0]);
    KeyValueSystem kvs = KeyValueSystem.Factory.create();
    // Creates a store.
    KeyValueStoreWriter writer = kvs.createStore(storeUri);
    // Puts a key-value pair ("key", "value").
    String key = "key";
    String value = "value";
    writer.put(key.getBytes(), value.getBytes());
    System.out.println(String.format("(%s, %s) is put into the key-value store", key, value));
    // Completes the store.
    writer.close();
    // Opens a store.
    KeyValueStoreReader reader = kvs.openStore(storeUri);
    // Gets the value for "key".
    System.out.println(String.format("Value for key '%s' got from the store is '%s'", key, new String(reader.get(key.getBytes()))));
    // Closes the reader.
    reader.close();
}
Also used : KeyValueStoreWriter(alluxio.client.keyvalue.KeyValueStoreWriter) KeyValueSystem(alluxio.client.keyvalue.KeyValueSystem) KeyValueStoreReader(alluxio.client.keyvalue.KeyValueStoreReader) AlluxioURI(alluxio.AlluxioURI)

Aggregations

KeyValueStoreReader (alluxio.client.keyvalue.KeyValueStoreReader)2 KeyValueStoreWriter (alluxio.client.keyvalue.KeyValueStoreWriter)2 KeyValueSystem (alluxio.client.keyvalue.KeyValueSystem)2 AlluxioURI (alluxio.AlluxioURI)1