15 package com.cloudera.impala.planner;
17 import java.util.List;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
25 import com.cloudera.impala.thrift.TDataPartition;
26 import com.cloudera.impala.thrift.TPartitionType;
27 import com.google.common.base.Joiner;
28 import com.google.common.base.Objects;
29 import com.google.common.base.Preconditions;
30 import com.google.common.collect.Lists;
40 private final static Logger
LOG = LoggerFactory.getLogger(DataPartition.class);
42 private final TPartitionType
type_;
48 Preconditions.checkNotNull(exprs);
49 Preconditions.checkState(!exprs.isEmpty());
50 Preconditions.checkState(type == TPartitionType.HASH_PARTITIONED
51 || type == TPartitionType.RANGE_PARTITIONED);
57 Preconditions.checkState(type == TPartitionType.UNPARTITIONED
58 || type == TPartitionType.RANDOM);
79 TDataPartition result =
new TDataPartition(
type_);
88 if (obj == null)
return false;
89 if (obj.getClass() != this.getClass())
return false;
96 return Objects.toStringHelper(
this)
103 StringBuilder str =
new StringBuilder();
106 List<String> strings = Lists.newArrayList();
108 strings.add(expr.toSql());
110 str.append(
"(" + Joiner.on(
",").join(strings) +
")");
112 return str.toString();
117 case RANDOM:
return "RANDOM";
118 case HASH_PARTITIONED:
return "HASH";
119 case RANGE_PARTITIONED:
return "RANGE";
String getExplainString()
List< Expr > getPartitionExprs()
static final DataPartition UNPARTITIONED
void substitute(ExprSubstitutionMap smap, Analyzer analyzer)
List< Expr > partitionExprs_
DataPartition(TPartitionType type)
DataPartition(TPartitionType type, List< Expr > exprs)
String getPartitionShortName(TPartitionType partition)
boolean equals(Object obj)
final TPartitionType type_
static final DataPartition RANDOM
boolean isHashPartitioned()
TDataPartition toThrift()