use of com.google.common.collect.ImmutableList.toImmutableList 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