Example usage for org.apache.cassandra.utils CounterId fromInt

List of usage examples for org.apache.cassandra.utils CounterId fromInt

Introduction

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

Prototype

public static CounterId fromInt(int n) 

Source Link

Document

Pack an int in a valid CounterId so that the resulting ids respects the numerical ordering.

Usage

From source file:com.knewton.mapreduce.SSTableColumnRecordReaderTest.java

License:Apache License

@Before
public void setUp() throws Exception {
    conf = new Configuration();
    attemptId = new TaskAttemptID();
    Path inputPath = new Path(TABLE_PATH_STR);
    inputSplit = new FileSplit(inputPath, 0, 1, null);
    Descriptor desc = new Descriptor(new File(TABLE_PATH_STR), "keyspace", "columnFamily", 1, Type.FINAL);

    doReturn(desc).when(ssTableColumnRecordReader).getDescriptor();

    doNothing().when(ssTableColumnRecordReader).copyTablesToLocal(any(FileSystem.class), any(FileSystem.class),
            any(Path.class), any(TaskAttemptContext.class));

    doReturn(ssTableReader).when(ssTableColumnRecordReader).openSSTableReader(any(IPartitioner.class),
            any(CFMetaData.class));

    when(ssTableReader.estimatedKeys()).thenReturn(2L);
    when(ssTableReader.getScanner()).thenReturn(tableScanner);

    when(tableScanner.hasNext()).thenReturn(true, true, false);

    key = new BufferDecoratedKey(new StringToken("a"), ByteBuffer.wrap("b".getBytes()));
    CellNameType simpleDenseCellType = new SimpleDenseCellNameType(BytesType.instance);
    CellName cellName = simpleDenseCellType.cellFromByteBuffer(ByteBuffer.wrap("n".getBytes()));
    ByteBuffer counterBB = CounterContext.instance().createGlobal(CounterId.fromInt(0),
            System.currentTimeMillis(), 123L);
    value = BufferCounterCell.create(cellName, counterBB, System.currentTimeMillis(), 0L, Flag.PRESERVE_SIZE);

    SSTableIdentityIterator row1 = getNewRow();
    SSTableIdentityIterator row2 = getNewRow();

    when(tableScanner.next()).thenReturn(row1, row2);
}