ColumnModifier.SORT_DESC.apply(values[i], 0, values[i], 0, values[i].length);
}
}
}
projectedTable.newKey(ptr, values);
PRow row = projectedTable.newRow(kvBuilder, ts, ptr);
for (; i < projectedColumns.size(); i++) {
Expression expression = selectExpressions.get(i);
if (expression.evaluate(result, ptr)) {
PColumn column = projectedColumns.get(i);
byte[] bytes = ptr.copyBytes();
Object value = expression.getDataType().toObject(bytes, column.getColumnModifier());
// If ColumnModifier from expression in SELECT doesn't match the
// column being projected into then invert the bits.
if (expression.getColumnModifier() != column.getColumnModifier()) {
ColumnModifier.SORT_DESC.apply(bytes, 0, bytes, 0, bytes.length);
}
// We are guaranteed that the two column will have the same type.
if (!column.getDataType().isSizeCompatible(column.getDataType(),
value, bytes,
expression.getMaxLength(), column.getMaxLength(),
expression.getScale(), column.getScale())) {
throw new ValueTypeIncompatibleException(column.getDataType(),
column.getMaxLength(), column.getScale());
}
bytes = column.getDataType().coerceBytes(bytes, value, expression.getDataType(),
expression.getMaxLength(), expression.getScale(), column.getMaxLength(), column.getScale());
row.setValue(column, bytes);
}
}
for (Mutation mutation : row.toRowMutations()) {
mutations.add(new Pair<Mutation,Integer>(mutation,null));
}
} else if (deleteCF != null && deleteCQ != null) {
// No need to search for delete column, since we project only it
// if no empty key value is being set