return new PhoenixStatement(connection) {
@Override
protected PhoenixResultSet newResultSet(Scanner scanner) throws SQLException {
RowProjector projector = scanner.getProjection();
List<ColumnProjector> columns = new ArrayList<ColumnProjector>(projector.getColumnProjectors());
ColumnProjector column = columns.get(keySeqPosition);
columns.set(keySeqPosition, new ExpressionProjector(column.getName(), column.getTableName(),
new BaseTerminalExpression() {
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
ptr.set(rowNumberHolder);
return true;
}
@Override
public PDataType getDataType() {
return PDataType.INTEGER;
}
},
column.isCaseSensitive())
);
column = columns.get(pkNamePosition);
columns.set(pkNamePosition, new ExpressionProjector(column.getName(), column.getTableName(),
new BaseTerminalExpression() {
@Override
public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
if (pkNamePtr.get() == unsetValue) {
KeyValue kv = tuple.getValue(TABLE_FAMILY_BYTES, PK_NAME_BYTES);
if (kv == null) {
ptr.set(ByteUtil.EMPTY_BYTE_ARRAY);
pkNamePtr.set(ByteUtil.EMPTY_BYTE_ARRAY);
} else {
ptr.set(kv.getBuffer(),kv.getValueOffset(),kv.getValueLength());
pkNamePtr.set(kv.getBuffer(),kv.getValueOffset(),kv.getValueLength());
}
} else {
ptr.set(pkNamePtr.get(),pkNamePtr.getOffset(),pkNamePtr.getLength());
}
return true;
}
@Override
public PDataType getDataType() {
return PDataType.VARCHAR;
}
},
column.isCaseSensitive())
);
final RowProjector newProjector = new RowProjector(columns, projector.getEstimatedRowByteSize(), projector.isProjectEmptyKeyValue());
Scanner delegate = new DelegateScanner(scanner) {
@Override
public RowProjector getProjection() {