drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul-rogers <...@git.apache.org>
Subject [GitHub] drill pull request #729: Drill 1328: Support table statistics for Parquet
Date Fri, 24 Feb 2017 03:53:43 GMT
Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/729#discussion_r102872722
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/statistics/ColTypeMergedStatistic.java
---
    @@ -0,0 +1,93 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you 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
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * 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 org.apache.drill.exec.physical.impl.statistics;
    +
    +import org.apache.drill.common.types.TypeProtos;
    +import org.apache.drill.exec.expr.holders.IntHolder;
    +import org.apache.drill.exec.expr.holders.ValueHolder;
    +import org.apache.drill.exec.vector.IntVector;
    +import org.apache.drill.exec.vector.ValueVector;
    +import org.apache.drill.exec.vector.complex.MapVector;
    +
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +public class ColTypeMergedStatistic extends AbstractMergedStatistic {
    +  private String name;
    +  private String inputName;
    +  private boolean mergeComplete = false;
    +  private Map<String, ValueHolder> typeHolder;
    +
    +
    +  public ColTypeMergedStatistic (String name, String inputName) {
    +    this.name = name;
    +    this.inputName = inputName;
    +    typeHolder = new HashMap<>();
    +  }
    +
    +  @Override
    +  public String getName() {
    +    return name;
    +  }
    +
    +  @Override
    +  public String getInput() {
    +    return inputName;
    +  }
    +
    +  @Override
    +  public void merge(ValueVector input) {
    +    // Check the input is a Map Vector
    +    assert (input.getField().getType().getMinorType() == TypeProtos.MinorType.MAP);
    +    MapVector inputMap = (MapVector) input;
    +    for (ValueVector vv : inputMap) {
    +      String colName = vv.getField().getLastName();
    +      if (typeHolder.get(colName) == null) {
    +        IntHolder colType = new IntHolder();
    +        ((IntVector) vv).getAccessor().get(0, colType);
    +        typeHolder.put(colName, colType);
    +      }
    +    }
    +  }
    +
    +  @Override
    +  public Object getStat(String colName) {
    --- End diff --
    
    I see. Some stats are longs, some are ints?
    
    Then, the getStat() should not be on the base class, it should be defined, with a specific
return type, on each subclass. Why? I have to know the subclass to know how to interpret the
returned Object. So, I might as well just use the subclass directly and get the unboxed primitive.
That is, rather than:
    
    ```
    AbstractMergedStatistic stat = ...
    Object value = stat.getStat();
    if (stat instanceof ColTypeMergedStatistic) {
      int colType = (int) value;
    }
    ```
    Just do:
    
    ```
    ColTypeMergedStatistic colTypeStat = ...;
    int colType = colTypeStat.getType(colName);
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message