Java Code Examples for org.apache.hadoop.hbase.KeyValue#LOWESTKEY

The following examples show how to use org.apache.hadoop.hbase.KeyValue#LOWESTKEY . These examples are extracted from open source projects. 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
@SuppressWarnings("deprecation")
@Override
public KeyValue getHint(KeyValue peeked) {
  // check to see if we have another column to seek
  ImmutableBytesPtr nextFamily =
      getNextFamily(new ImmutableBytesPtr(peeked.getBuffer(), peeked.getFamilyOffset(),
          peeked.getFamilyLength()));
  if (nextFamily == null) {
    // no known next family, so we can be completely done
    done = true;
    return KeyValue.LOWESTKEY;
  }
    // there is a valid family, so we should seek to that
  return KeyValue.createFirstOnRow(peeked.getRow(), nextFamily.copyBytesIfNecessary(),
    HConstants.EMPTY_BYTE_ARRAY);
}
 
Example 2
private QueryPlan newLiteralResultIterationPlan(Integer offset, Integer limit) throws SQLException {
    List<Tuple> tuples = Lists.newArrayList();

    Tuple baseTuple = new SingleKeyValueTuple(KeyValue.LOWESTKEY);
    for (Object[] row : RELATION) {
        Expression[] exprs = new Expression[row.length];
        for (int i = 0; i < row.length; i++) {
            exprs[i] = LiteralExpression.newConstant(row[i]);
        }
        TupleProjector projector = new TupleProjector(exprs);
        tuples.add(projector.projectResults(baseTuple));
    }

    return new LiteralResultIterationPlan(tuples, CONTEXT, SelectStatement.SELECT_ONE, TableRef.EMPTY_TABLE_REF,
            RowProjector.EMPTY_PROJECTOR, limit, offset, OrderBy.EMPTY_ORDER_BY, null);
}
 
Example 3
@Override
public Cell getHint(Cell peeked) {
  // check to see if we have another column to seek
  ImmutableBytesPtr nextFamily =
      getNextFamily(new ImmutableBytesPtr(peeked.getFamilyArray(), peeked.getFamilyOffset(),
          peeked.getFamilyLength()));
  if (nextFamily == null) {
    return KeyValue.LOWESTKEY;
  }
    // there is a valid family, so we should seek to that
  return org.apache.hadoop.hbase.KeyValueUtil.createFirstOnRow(peeked.getRowArray(),
      peeked.getRowOffset(), peeked.getRowLength(), nextFamily.get(),
      nextFamily.getOffset(), nextFamily.getLength(), HConstants.EMPTY_BYTE_ARRAY, 0, 0);
}
 
Example 4
Source Project: phoenix   File: FilteredKeyValueScanner.java    License: Apache License 2.0 5 votes vote down vote up
private boolean seekToNextUnfilteredKeyValue() throws IOException {
    while (true) {
        Cell peeked = delegate.peek();
        // no more key values, so we are done
        if (peeked == null) { return false; }

        // filter the peeked value to see if it should be served
        ReturnCode code = filter.filterKeyValue(peeked);
        switch (code) {
        // included, so we are done
        case INCLUDE:
        case INCLUDE_AND_NEXT_COL:
            return true;
            // not included, so we need to go to the next row
        case SKIP:
        case NEXT_COL:
        case NEXT_ROW:
            delegate.next();
            break;
        // use a seek hint to find out where we should go
        case SEEK_NEXT_USING_HINT:
            Cell nextCellHint = filter.getNextCellHint(peeked);
            if(nextCellHint == KeyValue.LOWESTKEY) {
                delegate.next();
            } else {
                delegate.seek(PhoenixKeyValueUtil.maybeCopyCell(nextCellHint));
            }
        }
    }
}
 
Example 5
Source Project: phoenix   File: CorrelatePlanTest.java    License: Apache License 2.0 5 votes vote down vote up
private QueryPlan newLiteralResultIterationPlan(Object[][] rows, Integer offset) throws SQLException {
    List<Tuple> tuples = Lists.newArrayList();
    Tuple baseTuple = new SingleKeyValueTuple(KeyValue.LOWESTKEY);
    for (Object[] row : rows) {
        Expression[] exprs = new Expression[row.length];
        for (int i = 0; i < row.length; i++) {
            exprs[i] = LiteralExpression.newConstant(row[i]);
        }
        TupleProjector projector = new TupleProjector(exprs);
        tuples.add(projector.projectResults(baseTuple));
    }
    
    return new LiteralResultIterationPlan(tuples, CONTEXT, SelectStatement.SELECT_ONE, TableRef.EMPTY_TABLE_REF,
            RowProjector.EMPTY_PROJECTOR, null, offset, OrderBy.EMPTY_ORDER_BY, null);
}
 
Example 6
@Override
public KeyValue getHint(KeyValue peeked) {
  // check to see if we have another column to seek
  ImmutableBytesPtr nextFamily =
      getNextFamily(new ImmutableBytesPtr(peeked.getBuffer(), peeked.getFamilyOffset(),
          peeked.getFamilyLength()));
  if (nextFamily == null) {
    // no known next family, so we can be completely done
    done = true;
    return KeyValue.LOWESTKEY;
  }
    // there is a valid family, so we should seek to that
  return KeyValue.createFirstOnRow(peeked.getRow(), nextFamily.copyBytesIfNecessary(),
    HConstants.EMPTY_BYTE_ARRAY);
}