/** * Encodes a sequence of columns from the row. * @param row the row containing the columns to encode * @param columnIds the IDs of each column to encode */ private static void encodeColumns(PartialRow row, List<Integer> columnIds, ByteVec buf) { for (int i = 0; i < columnIds.size(); i++) { boolean isLast = i + 1 == columnIds.size(); encodeColumn(row, row.getSchema().getColumnIndex(columnIds.get(i)), isLast, buf); } }
/** * Encodes the primary key of the row. * * @param row the row to encode * @return the encoded primary key of the row */ public static byte[] encodePrimaryKey(final PartialRow row) { ByteVec buf = ByteVec.create(); final Schema schema = row.getSchema(); for (int columnIdx = 0; columnIdx < schema.getPrimaryKeyColumnCount(); columnIdx++) { final boolean isLast = columnIdx + 1 == schema.getPrimaryKeyColumnCount(); encodeColumn(row, columnIdx, isLast, buf); } return buf.toArray(); }