use of org.apache.kudu.client.PartitionSchema in project presto by prestodb.
the class KuduTableProperties method buildRangePartitionBound.
private static RangeBoundValue buildRangePartitionBound(KuduTable table, byte[] rangeKey) {
if (rangeKey.length == 0) {
return null;
} else {
Schema schema = table.getSchema();
PartitionSchema partitionSchema = table.getPartitionSchema();
PartitionSchema.RangeSchema rangeSchema = partitionSchema.getRangeSchema();
List<Integer> rangeColumns = rangeSchema.getColumns();
final int numColumns = rangeColumns.size();
PartialRow bound = KeyEncoderAccessor.decodeRangePartitionKey(schema, partitionSchema, rangeKey);
ArrayList<Object> list = new ArrayList<>();
for (int i = 0; i < numColumns; i++) {
Object obj = toValue(schema, bound, rangeColumns.get(i));
list.add(obj);
}
return new RangeBoundValue(list);
}
}
use of org.apache.kudu.client.PartitionSchema in project presto by prestodb.
the class KuduTableProperties method getPartitionDesign.
public static PartitionDesign getPartitionDesign(KuduTable table) {
Schema schema = table.getSchema();
PartitionDesign partitionDesign = new PartitionDesign();
PartitionSchema partitionSchema = table.getPartitionSchema();
List<HashPartitionDefinition> hashPartitions = partitionSchema.getHashBucketSchemas().stream().map(hashBucketSchema -> {
HashPartitionDefinition hash = new HashPartitionDefinition();
List<String> cols = hashBucketSchema.getColumnIds().stream().map(idx -> schema.getColumnByIndex(idx).getName()).collect(toImmutableList());
hash.setColumns(cols);
hash.setBuckets(hashBucketSchema.getNumBuckets());
return hash;
}).collect(toImmutableList());
partitionDesign.setHash(hashPartitions);
List<Integer> rangeColumns = partitionSchema.getRangeSchema().getColumns();
if (!rangeColumns.isEmpty()) {
RangePartitionDefinition definition = new RangePartitionDefinition();
definition.setColumns(rangeColumns.stream().map(i -> schema.getColumns().get(i).getName()).collect(ImmutableList.toImmutableList()));
partitionDesign.setRange(definition);
}
return partitionDesign;
}
Aggregations