Example usage for org.apache.cassandra.db DataRange forKeyRange

List of usage examples for org.apache.cassandra.db DataRange forKeyRange

Introduction

In this page you can find the example usage for org.apache.cassandra.db DataRange forKeyRange.

Prototype

public static DataRange forKeyRange(Range<PartitionPosition> keyRange) 

Source Link

Document

Creates a DataRange to query all rows over the provided key range.

Usage

From source file:edu.dprg.morphous.MoveSSTableTest.java

License:Apache License

@Deprecated
@SuppressWarnings("rawtypes")
public static void doInsertOnTemporaryCFForRangesChoosingEndpointManually(String ksName, String originalCfName,
        String tempCfName, Collection<Range<Token>> ranges) {
    for (Range<Token> range : ranges) {
        ColumnFamilyStore originalCfs = Keyspace.open(ksName).getColumnFamilyStore(originalCfName);
        ColumnFamilyStore tempCfs = Keyspace.open(ksName).getColumnFamilyStore(originalCfName);
        ColumnFamilyStore.AbstractScanIterator iterator = edu.uiuc.dprg.morphous.Util
                .invokePrivateMethodWithReflection(originalCfs, "getSequentialIterator",
                        DataRange.forKeyRange(range), System.currentTimeMillis());

        while (iterator.hasNext()) {
            Row row = iterator.next();/*  ww  w  .ja v a  2  s .co  m*/
            ColumnFamily data = row.cf;
            ColumnFamily tempData = TreeMapBackedSortedColumns.factory.create(ksName, tempCfName);
            tempData.addAll(data, null);

            ByteBuffer newKey = tempData
                    .getColumn(tempData.metadata().partitionKeyColumns().get(0).name.asReadOnlyBuffer())
                    .value();
            InetAddress destinationNode = edu.uiuc.dprg.morphous.Util.getNthReplicaNodeForKey(ksName, newKey,
                    1);

            RowMutation rm = new RowMutation(newKey, tempData);
            MessageOut<RowMutation> message = rm.createMessage();
            MessagingService.instance().sendRR(message, destinationNode); //TODO Maybe use more robust way to send message
        }
    }
}