Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.sql.planner.plan;
 
 
 
 import java.util.List;
 import java.util.Map;
 
 import static com.facebook.presto.sql.planner.DomainUtils.columnHandleToSymbol;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
 public class TableScanNode
         extends PlanNode
 {
     private final TableHandle table;
     private final List<SymboloutputSymbols;
     private final Map<SymbolColumnHandleassignments// symbol -> column
     private final SummarizedPartition summarizedPartition;
     private final boolean partitionsDroppedBySerialization;
 
     // HACK!
     //
     // This field exists for the sole purpose of being able to print the original predicates (from the query) in
     // a human readable way. Predicates that get converted to and from TupleDomains might get more bulky and thus
     // more difficult to read when printed.
     // For example:
     // (ds > '2013-01-01') in the original query could easily become (ds IN ('2013-01-02', '2013-01-03', ...)) after the partitions are generated.
     // To make this work, the originalConstraint should be set exactly once after the first predicate push down and never adjusted after that.
     // In this way, we are always guaranteed to have a readable predicate that provides some kind of upper bound on the constraints.
     private final Expression originalConstraint;
 
     public TableScanNode(PlanNodeId idTableHandle tableList<SymboloutputSymbolsMap<SymbolColumnHandleassignments, @Nullable Expression originalConstraintOptional<GeneratedPartitionsgeneratedPartitions)
     {
         this(idtableoutputSymbolsassignmentsoriginalConstraintnew SummarizedPartition(generatedPartitions), false);
     }
 
     public TableScanNode(PlanNodeId idTableHandle tableList<SymboloutputSymbolsMap<SymbolColumnHandleassignments, @Nullable Expression originalConstraintSummarizedPartition summarizedPartition)
     {
         this(idtableoutputSymbolsassignmentsoriginalConstraintsummarizedPartitionfalse);
     }
 
     @JsonCreator
     public TableScanNode(@JsonProperty("id"PlanNodeId id,
             @JsonProperty("table"TableHandle table,
             @JsonProperty("outputSymbols"List<SymboloutputSymbols,
             @JsonProperty("assignments"Map<SymbolColumnHandleassignments,
             @JsonProperty("originalConstraint") @Nullable Expression originalConstraint)
     {
         this(idtableoutputSymbolsassignmentsoriginalConstraintnew SummarizedPartition(Optional.empty()), true);
     }
 
     private TableScanNode(PlanNodeId idTableHandle tableList<SymboloutputSymbolsMap<SymbolColumnHandleassignments, @Nullable Expression originalConstraintSummarizedPartition summarizedPartitionboolean partitionsDroppedBySerialization)
     {
         super(id);
 
         checkNotNull(table"table is null");
         checkNotNull(outputSymbols"outputSymbols is null");
         checkNotNull(assignments"assignments is null");
         checkArgument(assignments.keySet().containsAll(outputSymbols), "assignments does not cover all of outputSymbols");
         checkNotNull(summarizedPartition"summarizedPartition is null");
 
         this. = table;
         this. = ImmutableList.copyOf(outputSymbols);
         this. = ImmutableMap.copyOf(assignments);
         this. = originalConstraint;
         this. = summarizedPartition;
        this. = partitionsDroppedBySerialization;
        checkArgument(summarizedPartition.getPartitionDomainSummary().isNone() || ImmutableSet.copyOf(assignments.values()).containsAll(summarizedPartition.getPartitionDomainSummary().getDomains().keySet()), "Assignments do not include all of the ColumnHandles specified by the Partitions");
    }
    @JsonProperty("table")
    public TableHandle getTable()
    {
        return ;
    }
    @Override
    @JsonProperty("outputSymbols")
    public List<SymbolgetOutputSymbols()
    {
        return ;
    }
    @JsonProperty("assignments")
    {
        return ;
    }
    @Nullable
    @JsonProperty("originalConstraint")
    {
        return ;
    }
    {
        // If this exception throws, then we might want to consider making Partitions serializable by Jackson
        checkState(!"Can't access partitions after passing through serialization");
    }
    {
    }
    {
        return ;
    }
    @JsonProperty("partitionDomainSummary")
    {
        // Since partitions are not serializable, we can provide an additional jackson field purely for information purposes (i.e. for logging)
        // If partitions ever become serializable, we can get rid of this method
        StringBuilder builder = new StringBuilder()
                .append("TupleDomain:");
            builder.append("ALL");
        }
        else if (.getPartitionDomainSummary().isNone()) {
            builder.append("NONE");
        }
        else {
        }
        return builder.toString();
    }
    @Override
    public List<PlanNodegetSources()
    {
        return ImmutableList.of();
    }
    @Override
    public <C, R> R accept(PlanVisitor<C, R> visitor, C context)
    {
        return visitor.visitTableScan(thiscontext);
    }
    public static final class SummarizedPartition
    {
        private final Optional<GeneratedPartitionsgeneratedPartitions;
        private final TupleDomain<ColumnHandlepartitionDomainSummary;
        public SummarizedPartition(Optional<GeneratedPartitionsgeneratedPartitions)
        {
            this. = checkNotNull(generatedPartitions"generatedPartitions is null");
            this. = computePartitionsDomainSummary(generatedPartitions);
        }
        private static TupleDomain<ColumnHandlecomputePartitionsDomainSummary(Optional<GeneratedPartitionsgeneratedPartitions)
        {
            if (!generatedPartitions.isPresent()) {
                return TupleDomain.all();
            }
            if (generatedPartitions.get().getPartitions().isEmpty()) {
                return TupleDomain.none();
            }
            List<TupleDomain<ColumnHandle>> domains = FluentIterable.from(generatedPartitions.get().getPartitions()).transform(Partition::getTupleDomain).toList();
            return TupleDomain.columnWiseUnion(domains);
        }
        {
            return ;
        }
        {
            return ;
        }
    }
    public static final class GeneratedPartitions
    {
        private final TupleDomain<ColumnHandletupleDomainInput// The TupleDomain used to generate the current list of Partitions
        private final List<Partitionpartitions;
        public GeneratedPartitions(TupleDomain<ColumnHandletupleDomainInputList<Partitionpartitions)
        {
            this. = checkNotNull(tupleDomainInput"tupleDomainInput is null");
            this. = ImmutableList.copyOf(checkNotNull(partitions"partitions is null"));
        }
        public TupleDomain<ColumnHandlegetTupleDomainInput()
        {
            return ;
        }
        public List<PartitiongetPartitions()
        {
            return ;
        }
        @Override
        public int hashCode()
        {
            return Objects.hashCode();
        }
        @Override
        public boolean equals(Object obj)
        {
            if (this == obj) {
                return true;
            }
            if (obj == null || getClass() != obj.getClass()) {
                return false;
            }
            final GeneratedPartitions other = (GeneratedPartitionsobj;
            return Objects.equal(this.other.tupleDomainInput) && Objects.equal(this.other.partitions);
        }
    }
New to GrepCode? Check out our FAQ X