Search in sources :

Example 1 with KeyValueStoreReader

use of alluxio.client.keyvalue.KeyValueStoreReader 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 KeyValueStoreReader

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

the class SameKeyValueStoresTest method call.

@Override
public Boolean call() throws Exception {
    KeyValueSystem kvs = KeyValueSystem.Factory.create();
    KeyValueStoreReader reader1 = kvs.openStore(mStoreUri1);
    KeyValueStoreReader reader2 = kvs.openStore(mStoreUri2);
    boolean pass = areTheSameStores(reader1, reader2);
    reader1.close();
    reader2.close();
    return pass;
}
Also used : KeyValueSystem(alluxio.client.keyvalue.KeyValueSystem) KeyValueStoreReader(alluxio.client.keyvalue.KeyValueStoreReader)

Example 3 with KeyValueStoreReader

use of alluxio.client.keyvalue.KeyValueStoreReader 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)

Example 4 with KeyValueStoreReader

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

the class ShowKeyValueStore method main.

/**
   * @param args two parameters, the first is the key-value store URI, the second is the scope of
   *    the store to be shown ("key" to show only keys, "value" to show only values, and "all" to
   *    show both keys and values)
   * @throws Exception if any exception happens
   */
public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        System.out.println("Usage: java -cp " + RuntimeConstants.ALLUXIO_JAR + " " + ShowKeyValueStore.class.getName() + " <key-value store URI>" + " <scope, be one of key/value/all>");
        System.exit(-1);
    }
    KeyValueStoreReader reader = KeyValueSystem.Factory.create().openStore(new AlluxioURI(args[0]));
    KeyValueIterator iterator = reader.iterator();
    while (iterator.hasNext()) {
        show(iterator.next(), args[1]);
    }
    reader.close();
}
Also used : KeyValueIterator(alluxio.client.keyvalue.KeyValueIterator) KeyValueStoreReader(alluxio.client.keyvalue.KeyValueStoreReader) AlluxioURI(alluxio.AlluxioURI)

Aggregations

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