final int primaryKeyColumnCount = table.getSchema().getPrimaryKeyColumnCount(); KuduScanToken.KuduScanTokenBuilder builder = client.newScanTokenBuilder(table);
public static void copyPrimaryKey(Schema schema, RowResult from, PartialRow to) for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING:
public static void copyPrimaryKey(Schema schema, PartialRow from, PartialRow to) for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING:
/** * Transforms the row key into a string representation where each column is in the format: * "type col_name=value". * @return a string representation of the operation's row key */ public String stringifyRowKey() { int numRowKeys = schema.getPrimaryKeyColumnCount(); List<Integer> idxs = new ArrayList<>(numRowKeys); for (int i = 0; i < numRowKeys; i++) { idxs.add(i); } StringBuilder sb = new StringBuilder(); sb.append("("); appendDebugString(idxs, sb); sb.append(")"); return sb.toString(); }
/** * Decodes a primary key into a row * * @param schema the table schema * @param key the encoded key * @return the decoded primary key as a row */ public static PartialRow decodePrimaryKey(Schema schema, byte[] key) { PartialRow row = schema.newPartialRow(); ByteBuffer buf = ByteBuffer.wrap(key); buf.order(ByteOrder.BIG_ENDIAN); for (int idx = 0; idx < schema.getPrimaryKeyColumnCount(); idx++) { decodeColumn(buf, row, idx, idx + 1 == schema.getPrimaryKeyColumnCount()); } if (buf.hasRemaining()) { throw new IllegalArgumentException("Unable to decode all primary key bytes"); } return row; }
/** * Creates a new partition schema from the range and hash bucket schemas. * * @param rangeSchema the range schema * @param hashBucketSchemas the hash bucket schemas * @param schema the table schema */ PartitionSchema(RangeSchema rangeSchema, List<HashBucketSchema> hashBucketSchemas, Schema schema) { this.rangeSchema = rangeSchema; this.hashBucketSchemas = hashBucketSchemas; boolean isSimple = hashBucketSchemas.isEmpty() && rangeSchema.columns.size() == schema.getPrimaryKeyColumnCount(); if (isSimple) { int i = 0; for (Integer id : rangeSchema.columns) { if (schema.getColumnIndex(id) != i++) { isSimple = false; break; } } } this.isSimple = isSimple; }
/** * 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(); }
final int primaryKeyColumnCount = table.getSchema().getPrimaryKeyColumnCount(); KuduScanToken.KuduScanTokenBuilder builder = client.newScanTokenBuilder(table);
KuduTableHandle tableHandle = layoutHandle.getTableHandle(); KuduTable table = tableHandle.getTable(this); final int primaryKeyColumnCount = table.getSchema().getPrimaryKeyColumnCount(); KuduScanToken.KuduScanTokenBuilder builder = client.newScanTokenBuilder(table);
/** * Builds the default partition schema for a schema. * @param schema the schema * @return a default partition schema */ private PartitionSchema defaultPartitionSchema(Schema schema) { List<Integer> columnIds = new ArrayList<>(); for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { // Schema does not provide a way to lookup a column ID by column index, // so instead we assume that the IDs for the primary key columns match // their respective index, which holds up when the schema is created // with buildSchema. columnIds.add(i); } return new PartitionSchema( new PartitionSchema.RangeSchema(columnIds), ImmutableList.<PartitionSchema.HashBucketSchema>of(), schema); }
public static void copyPrimaryKey(Schema schema, RowResult from, PartialRow to) for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING:
public static void copyPrimaryKey(Schema schema, PartialRow from, PartialRow to) for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING:
public static void copyPrimaryKey(Schema schema, RowResult from, PartialRow to) { for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING:
public static void copyPrimaryKey(Schema schema, PartialRow from, PartialRow to) { for (int i = 0; i < schema.getPrimaryKeyColumnCount(); i++) { switch (schema.getColumnByIndex(i).getType()) { case STRING: