Java Code Examples for org.apache.cassandra.thrift.KeyRange#setStart_key()

The following examples show how to use org.apache.cassandra.thrift.KeyRange#setStart_key() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraDefs.java    From Doradus with Apache License 2.0 5 votes vote down vote up
/**
 * Create a KeyRange that begins at the given row key.
 * 
 * @param startRowKey   Starting row key as a byte[].
 * @return              KeyRange that starts at the given row, open-ended.
 */
static KeyRange keyRangeStartRow(byte[] startRowKey) {
    KeyRange keyRange = new KeyRange();
    keyRange.setStart_key(startRowKey);
    keyRange.setEnd_key(EMPTY_BYTE_BUFFER);
    keyRange.setCount(MAX_ROWS_BATCH_SIZE);
    return keyRange;
}
 
Example 2
Source File: CassandraDefs.java    From Doradus with Apache License 2.0 5 votes vote down vote up
static KeyRange keyRangeStartRow(byte[] startRowKey, int count) {
    KeyRange keyRange = new KeyRange();
    keyRange.setStart_key(startRowKey == null ? EMPTY_BYTES : startRowKey);
    keyRange.setEnd_key(EMPTY_BYTES);
    keyRange.setCount(count);
    return keyRange;
}
 
Example 3
Source File: CassandraDefs.java    From Doradus with Apache License 2.0 5 votes vote down vote up
/**
 * Create a KeyRange that selects a single row with the given key.
 * 
 * @param rowKey    Row key as a byte[].
 * @return          KeyRange that starts and ends with the given key.
 */
static KeyRange keyRangeSingleRow(byte[] rowKey) {
    KeyRange keyRange = new KeyRange();
    keyRange.setStart_key(rowKey);
    keyRange.setEnd_key(rowKey);
    keyRange.setCount(1);
    return keyRange;
}
 
Example 4
Source File: CassandraInputData.java    From learning-hadoop with Apache License 2.0 4 votes vote down vote up
public void sliceModeInit(CassandraColumnMetaData meta,
    List<String> colNames, int maxRows, int maxCols, int rowBatchSize,
    int colBatchSize) throws KettleException {

  m_newSliceQuery = true;
  m_requestedCols = colNames;
  m_sliceRowsMax = maxRows;
  m_sliceColsMax = maxCols;
  m_sliceRowsBatchSize = rowBatchSize;
  m_sliceColsBatchSize = colBatchSize;
  m_rowIndex = 0;
  m_colIndex = 0;

  if (m_sliceColsBatchSize <= 0) {
    m_sliceColsBatchSize = Integer.MAX_VALUE;
  }

  if (m_sliceRowsBatchSize <= 0) {
    m_sliceRowsBatchSize = Integer.MAX_VALUE;
  }

  List<ByteBuffer> specificCols = null;
  if (m_requestedCols != null && m_requestedCols.size() > 0) {
    specificCols = new ArrayList<ByteBuffer>();

    // encode the textual column names
    for (String colName : m_requestedCols) {
      ByteBuffer encoded = meta.columnNameToByteBuffer(colName);
      specificCols.add(encoded);
    }
  }

  m_slicePredicate = new SlicePredicate();

  if (specificCols == null) {
    m_sliceRange = new SliceRange(ByteBuffer.wrap(new byte[0]),
        ByteBuffer.wrap(new byte[0]), false, m_sliceColsBatchSize);
    m_slicePredicate.setSlice_range(m_sliceRange);
  } else {
    m_slicePredicate.setColumn_names(specificCols);
  }

  m_keyRange = new KeyRange(m_sliceRowsBatchSize);
  m_keyRange.setStart_key(new byte[0]);
  m_keyRange.setEnd_key(new byte[0]);

  m_colParent = new ColumnParent(meta.getColumnFamilyName());
  m_converted = new ArrayList<Object[]>();
}