drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] arina-ielchiieva commented on a change in pull request #1690: DRILL-7086: Output schema for row set mechanism
Date Tue, 12 Mar 2019 13:53:14 GMT
arina-ielchiieva commented on a change in pull request #1690: DRILL-7086: Output schema for
row set mechanism
URL: https://github.com/apache/drill/pull/1690#discussion_r264644430
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/physical/rowSet/impl/AbstractSchemaTransformer.java
 ##########
 @@ -0,0 +1,230 @@
+/*
+ * 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.physical.rowSet.impl;
+
+import org.apache.drill.exec.record.metadata.ColumnMetadata;
+import org.apache.drill.exec.record.metadata.ProjectionType;
+import org.apache.drill.exec.record.metadata.TupleMetadata;
+import org.apache.drill.exec.vector.accessor.ScalarWriter;
+import org.apache.drill.exec.vector.accessor.convert.AbstractWriteConverter;
+import org.apache.drill.exec.vector.accessor.convert.ColumnConversionFactory;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToDate;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToDouble;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToInt;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToInterval;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToLong;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToTime;
+import org.apache.drill.exec.vector.accessor.convert.ConvertStringToTimeStamp;
+
+/**
+ * Base class for plugin-specific type transforms. Handles basic type
+ * checking. Assumes a type conversion is needed only if the output
+ * column is defined and has a type or mode different than the input.
+ * Else, assumes no transform is needed. Subclases can change or enhance
+ * this policy. The subclass provides the actual per-column transform logic.
+ */
+
+public abstract class AbstractSchemaTransformer implements SchemaTransformer {
+
+  /**
+   * A no-op transform that simply keeps the input column schema and
+   * writer without any changes.
+   */
+  public static class PassThroughColumnTransform implements ColumnTransformer {
+
+    private final ColumnMetadata colDefn;
+    private final ProjectionType projType;
+
+    public PassThroughColumnTransform(ColumnMetadata colDefn, ProjectionType projType) {
+      this.colDefn = colDefn;
+      this.projType = projType;
+    }
+
+    @Override
+    public AbstractWriteConverter newWriter(ScalarWriter baseWriter) {
+      return null;
+    }
+
+    @Override
+    public ProjectionType projectionType() { return projType; }
+
+    @Override
+    public ColumnMetadata inputSchema() { return colDefn; }
+
+    @Override
+    public ColumnMetadata outputSchema() { return colDefn; }
+  }
+
+  /**
+   * Full column transform that has separate input and output types
+   * and provides a type conversion writer to convert between the
+   * two. The conversion writer factory is provided via composition,
+   * not by subclassing this class.
+   */
+  public static class ColumnTransformImpl implements ColumnTransformer {
+
+    private final ColumnMetadata inputSchema;
+    private final ColumnMetadata outputSchema;
+    private final ProjectionType projType;
+    private final ColumnConversionFactory conversionFactory;
+
+    public ColumnTransformImpl(ColumnMetadata inputSchema, ColumnMetadata outputSchema,
+        ProjectionType projType, ColumnConversionFactory conversionFactory) {
+      this.inputSchema = inputSchema;
+      this.outputSchema = outputSchema;
+      this.projType = projType;
+      this.conversionFactory = conversionFactory;
+    }
+
+    @Override
+    public AbstractWriteConverter newWriter(ScalarWriter baseWriter) {
+      if (conversionFactory == null) {
+        return null;
+      }
+      return conversionFactory.newWriter(baseWriter);
+    }
+
+    @Override
+    public ProjectionType projectionType() { return projType; }
+
+    @Override
+    public ColumnMetadata inputSchema() { return inputSchema; }
+
+    @Override
+    public ColumnMetadata outputSchema() { return outputSchema; }
+  }
+
+  protected final TupleMetadata outputSchema;
+
+  public AbstractSchemaTransformer(TupleMetadata outputSchema) {
+    this.outputSchema = outputSchema;
+  }
+
+  protected ColumnTransformer nullTransform(ColumnMetadata inputSchema,
 
 Review comment:
   Maybe rename to `noTransform` to avoid confusion with null handling?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message