Example usage for org.apache.cassandra.io.sstable Descriptor Descriptor

List of usage examples for org.apache.cassandra.io.sstable Descriptor Descriptor

Introduction

In this page you can find the example usage for org.apache.cassandra.io.sstable Descriptor Descriptor.

Prototype

public Descriptor(File directory, String ksname, String cfname, int generation, SSTableFormat.Type formatType) 

Source Link

Document

Constructor for sstable writers only.

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);
}

From source file:com.knewton.mapreduce.SSTableRowRecordReaderTest.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(ssTableRowRecordReader).getDescriptor();

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

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

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

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

    key = new BufferDecoratedKey(new StringToken("a"), ByteBuffer.wrap("b".getBytes()));

    row = mock(SSTableIdentityIterator.class);
    when(row.getKey()).thenReturn(key);//w ww.j  ava 2 s  .  com

    when(tableScanner.next()).thenReturn(row);
}