Example usage for org.apache.cassandra.utils Pair Pair

List of usage examples for org.apache.cassandra.utils Pair Pair

Introduction

In this page you can find the example usage for org.apache.cassandra.utils Pair Pair.

Prototype

protected Pair(T1 left, T2 right) 

Source Link

Usage

From source file:com.buzzinate.dm.cassandra.ColumnFamilyRecordWriter.java

License:Apache License

/**
 * If the key is to be associated with a valid value, a mutation is created
 * for it with the given column family and columns. In the event the value
 * in the column is missing (i.e., null), then it is marked for
 * {@link Deletion}. Similarly, if the entire value for a key is missing
 * (i.e., null), then the entire key is marked for {@link Deletion}.
 * </p>/* w  w  w.jav a  2 s  . c o  m*/
 *
 * @param keybuff
 *            the key to write.
 * @param value
 *            the value to write.
 * @throws IOException
 */
@Override
public void write(ByteBuffer keybuff, List<Mutation> value) throws IOException {
    Range<Token> range = ringCache.getRange(keybuff);

    // get the client for the given range, or create a new one
    RangeClient client = clients.get(range);
    if (client == null) {
        // haven't seen keys for this range: create new client
        client = new RangeClient(ringCache.getEndpoint(range));
        client.start();
        clients.put(range, client);
    }

    for (Mutation amut : value)
        client.put(new Pair<ByteBuffer, Mutation>(keybuff, amut));
    progressable.progress();
}

From source file:org.pingles.cascading.cassandra.hadoop.ColumnFamilyRecordWriter.java

License:Apache License

/**
 * If the key is to be associated with a valid value, a mutation is created
 * for it with the given column family and columns. In the event the value
 * in the column is missing (i.e., null), then it is marked for
 * {@link Deletion}. Similarly, if the entire value for a key is missing
 * (i.e., null), then the entire key is marked for {@link Deletion}.
 * </p>/*from   w ww.ja  va  2  s .c  o  m*/
 * 
 * @param keybuff
 *            the key to write.
 * @param value
 *            the value to write.
 * @throws IOException
 */
@Override
public void write(ByteBuffer keybuff, List<Mutation> value) throws IOException {
    Range range = ringCache.getRange(keybuff);

    // get the client for the given range, or create a new one
    RangeClient client = clients.get(range);
    if (client == null) {
        // haven't seen keys for this range: create new client
        client = new RangeClient(ringCache.getEndpoint(range));
        client.start();
        clients.put(range, client);
    }

    for (Mutation amut : value)
        client.put(new Pair<ByteBuffer, Mutation>(keybuff, amut));
}