Search in sources :

Example 1 with ImmutableList.toImmutableList

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;
}
Also used : Predicates(org.apache.kudu.shaded.com.google.common.base.Predicates) DateTimeZone(org.joda.time.DateTimeZone) Iterators(org.apache.kudu.shaded.com.google.common.collect.Iterators) Type(org.apache.kudu.Type) HashMap(java.util.HashMap) PrestoException(com.facebook.presto.spi.PrestoException) PropertyMetadata(com.facebook.presto.spi.session.PropertyMetadata) Schema(org.apache.kudu.Schema) LocatedTablet(org.apache.kudu.client.LocatedTablet) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) PropertyMetadata.booleanProperty(com.facebook.presto.spi.session.PropertyMetadata.booleanProperty) ImmutableList(com.google.common.collect.ImmutableList) Partition(org.apache.kudu.client.Partition) Locale(java.util.Locale) TypeManager(com.facebook.presto.common.type.TypeManager) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) PropertyMetadata.stringProperty(com.facebook.presto.spi.session.PropertyMetadata.stringProperty) ENGLISH(java.util.Locale.ENGLISH) ColumnSchema(org.apache.kudu.ColumnSchema) PartitionSchema(org.apache.kudu.client.PartitionSchema) PartialRow(org.apache.kudu.client.PartialRow) ISODateTimeFormat(org.joda.time.format.ISODateTimeFormat) Iterator(java.util.Iterator) Collection(java.util.Collection) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) KuduTable(org.apache.kudu.client.KuduTable) Collectors(java.util.stream.Collectors) KeyEncoderAccessor(org.apache.kudu.client.KeyEncoderAccessor) Base64(java.util.Base64) List(java.util.List) TypeSignature.parseTypeSignature(com.facebook.presto.common.type.TypeSignature.parseTypeSignature) PropertyMetadata.integerProperty(com.facebook.presto.spi.session.PropertyMetadata.integerProperty) Optional(java.util.Optional) GENERIC_USER_ERROR(com.facebook.presto.spi.StandardErrorCode.GENERIC_USER_ERROR) PartitionSchema(org.apache.kudu.client.PartitionSchema) Schema(org.apache.kudu.Schema) ColumnSchema(org.apache.kudu.ColumnSchema) PartitionSchema(org.apache.kudu.client.PartitionSchema) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List)

Aggregations

TypeManager (com.facebook.presto.common.type.TypeManager)1 TypeSignature.parseTypeSignature (com.facebook.presto.common.type.TypeSignature.parseTypeSignature)1 PrestoException (com.facebook.presto.spi.PrestoException)1 GENERIC_USER_ERROR (com.facebook.presto.spi.StandardErrorCode.GENERIC_USER_ERROR)1 PropertyMetadata (com.facebook.presto.spi.session.PropertyMetadata)1 PropertyMetadata.booleanProperty (com.facebook.presto.spi.session.PropertyMetadata.booleanProperty)1 PropertyMetadata.integerProperty (com.facebook.presto.spi.session.PropertyMetadata.integerProperty)1 PropertyMetadata.stringProperty (com.facebook.presto.spi.session.PropertyMetadata.stringProperty)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Base64 (java.util.Base64)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1