You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by bitblender <gi...@git.apache.org> on 2017/06/05 20:57:51 UTC

[GitHub] drill pull request #837: DRILL-5514: Enhance VectorContainer to merge two ro...

Github user bitblender commented on a diff in the pull request:

    https://github.com/apache/drill/pull/837#discussion_r120198724
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/record/BatchSchema.java ---
    @@ -157,4 +158,26 @@ private boolean majorTypeEqual(MajorType t1, MajorType t2) {
         return true;
       }
     
    +  /**
    +   * Merge two schema to produce a new, merged schema. The caller is responsible
    +   * for ensuring that column names are unique. The order of the fields in the
    +   * new schema is the same as that of this schema, with the other schema's fields
    +   * appended in the order defined in the other schema. The resulting selection
    +   * vector mode is the same as this schema. (That is, this schema is assumed to
    +   * be the main part of the batch, possibly with a selection vector, with the
    +   * other schema representing additional, new columns.)
    +   * @param otherSchema the schema to merge with this one
    +   * @return the new, merged, schema
    +   */
    +
    +  public BatchSchema merge(BatchSchema otherSchema) {
    +    if (otherSchema.selectionVectorMode != SelectionVectorMode.NONE &&
    +        selectionVectorMode != otherSchema.selectionVectorMode) {
    +      throw new IllegalArgumentException("Left schema must carry the selection vector mode");
    +    }
    +    List<MaterializedField> mergedFields = new ArrayList<>();
    --- End diff --
    
    List<MaterializedField> mergedFields = new ArrayList(this.fields.size() +  otherSchema.fields.size()) would avoid having to potentially grow the ArrayList twice.


---
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.
---