[ 
https://issues.apache.org/jira/browse/DRILL-6114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16366643#comment-16366643
 ] 

ASF GitHub Bot commented on DRILL-6114:
---------------------------------------

Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/1112#discussion_r168681901
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/record/metadata/AbstractColumnMetadata.java
 ---
    @@ -0,0 +1,206 @@
    +/*
    + * 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
    + *
    + * 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 org.apache.drill.exec.record.metadata;
    +
    +import org.apache.drill.common.types.TypeProtos.DataMode;
    +import org.apache.drill.common.types.TypeProtos.MajorType;
    +import org.apache.drill.common.types.TypeProtos.MinorType;
    +import org.apache.drill.exec.record.MaterializedField;
    +
    +/**
    + * Abstract definition of column metadata. Allows applications to create
    + * specialized forms of a column metadata object by extending from this
    + * abstract class.
    + * <p>
    + * Note that, by design, primitive columns do not have a link to their
    + * tuple parent, or their index within that parent. This allows the same
    + * metadata to be shared between two views of a tuple, perhaps physical
    + * and projected views. This restriction does not apply to map columns,
    + * since maps (and the row itself) will, by definition, differ between
    + * the two views.
    + */
    +
    +public abstract class AbstractColumnMetadata implements ColumnMetadata {
    +
    +  // Capture the key schema information. We cannot use the 
MaterializedField
    +  // or MajorType because then encode child information that we encode here
    +  // as a child schema. Keeping the two in sync is nearly impossible.
    +
    +  protected final String name;
    +  protected final MinorType type;
    +  protected final DataMode mode;
    +  protected final int precision;
    +  protected final int scale;
    +  protected boolean projected = true;
    +
    +  /**
    +   * Predicted number of elements per array entry. Default is
    +   * taken from the often hard-coded value of 10.
    +   */
    +
    +  protected int expectedElementCount = 1;
    +
    +  public AbstractColumnMetadata(MaterializedField schema) {
    +    name = schema.getName();
    +    MajorType majorType = schema.getType();
    +    type = majorType.getMinorType();
    +    mode = majorType.getMode();
    +    precision = majorType.getPrecision();
    +    scale = majorType.getScale();
    +    if (isArray()) {
    +      expectedElementCount = DEFAULT_ARRAY_SIZE;
    +    }
    +  }
    +
    +  public AbstractColumnMetadata(String name, MinorType type, DataMode 
mode) {
    +    this.name = name;
    +    this.type = type;
    +    this.mode = mode;
    +    precision = 0;
    +    scale = 0;
    +    if (isArray()) {
    +      expectedElementCount = DEFAULT_ARRAY_SIZE;
    +    }
    +  }
    +
    +  public AbstractColumnMetadata(AbstractColumnMetadata from) {
    +    name = from.name;
    +    type = from.type;
    +    mode = from.mode;
    +    precision = from.precision;
    +    scale = from.scale;
    +    expectedElementCount = from.expectedElementCount;
    +  }
    +
    +  protected void bind(TupleSchema parentTuple) { }
    +
    +  @Override
    +  public String name() { return name; }
    +
    +  @Override
    +  public MinorType type() { return type; }
    +
    +  @Override
    +  public MajorType majorType() {
    +    return MajorType.newBuilder()
    +        .setMinorType(type())
    +        .setMode(mode())
    +        .build();
    +  }
    +
    +  @Override
    +  public DataMode mode() { return mode; }
    +
    +  @Override
    +  public boolean isNullable() { return mode() == DataMode.OPTIONAL; }
    +
    +  @Override
    +  public boolean isArray() { return mode() == DataMode.REPEATED; }
    +
    +  @Override
    +  public int dimensions() { return isArray() ? 1 : 0; }
    +
    +  @Override
    +  public boolean isMap() { return false; }
    +
    +  @Override
    +  public boolean isVariant() { return false; }
    --- End diff --
    
    I think there is a write-up somewhere about this. "Variant" is an old term 
from Visual Basic for a tagged union (which is what our "Union" type really 
is.) It is used here because both a (non-repeated) List and a Union are both 
unions, which is confusing, so I used a separate term. Also, the "Union" term 
is confusing since there is also a UNION operator in SQL. `See 
VariantMetadata.java`.


> Complete internal metadata layer for improved batch handling
> ------------------------------------------------------------
>
>                 Key: DRILL-6114
>                 URL: https://issues.apache.org/jira/browse/DRILL-6114
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Major
>             Fix For: 1.13.0
>
>
> Slice of the ["batch handling" 
> project.|https://github.com/paul-rogers/drill/wiki/Batch-Handling-Upgrades] 
> that includes enhancements to the internal metadata system.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to