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

    https://github.com/apache/incubator-hawq/pull/1225#discussion_r118130921
  
    --- Diff: 
pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/HiveORCBatchResolver.java
 ---
    @@ -0,0 +1,257 @@
    +package org.apache.hawq.pxf.plugins.hive;
    +
    +/*
    + * 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.
    + */
    +
    +import static org.apache.hawq.pxf.api.io.DataType.BIGINT;
    +import static org.apache.hawq.pxf.api.io.DataType.BOOLEAN;
    +import static org.apache.hawq.pxf.api.io.DataType.BPCHAR;
    +import static org.apache.hawq.pxf.api.io.DataType.BYTEA;
    +import static org.apache.hawq.pxf.api.io.DataType.DATE;
    +import static org.apache.hawq.pxf.api.io.DataType.FLOAT8;
    +import static org.apache.hawq.pxf.api.io.DataType.INTEGER;
    +import static org.apache.hawq.pxf.api.io.DataType.NUMERIC;
    +import static org.apache.hawq.pxf.api.io.DataType.REAL;
    +import static org.apache.hawq.pxf.api.io.DataType.SMALLINT;
    +import static org.apache.hawq.pxf.api.io.DataType.TEXT;
    +import static org.apache.hawq.pxf.api.io.DataType.TIMESTAMP;
    +import static org.apache.hawq.pxf.api.io.DataType.VARCHAR;
    +
    +import java.math.BigDecimal;
    +import java.util.ArrayList;
    +import java.util.Calendar;
    +import java.util.List;
    +import java.sql.Timestamp;
    +import java.sql.Date;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.hadoop.hive.common.type.HiveDecimal;
    +import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
    +import org.apache.hadoop.io.Writable;
    +import org.apache.hadoop.io.LongWritable;
    +import org.apache.hadoop.io.DoubleWritable;
    +import org.apache.hadoop.io.FloatWritable;
    +import org.apache.hadoop.io.Text;
    +import org.apache.hawq.pxf.api.OneField;
    +import org.apache.hawq.pxf.api.OneRow;
    +import org.apache.hawq.pxf.api.ReadVectorizedResolver;
    +import org.apache.hawq.pxf.api.UnsupportedTypeException;
    +import org.apache.hawq.pxf.api.io.DataType;
    +import org.apache.hawq.pxf.api.utilities.ColumnDescriptor;
    +import org.apache.hawq.pxf.api.utilities.InputData;
    +import org.apache.hawq.pxf.api.utilities.Plugin;
    +import org.apache.hawq.pxf.plugins.hive.utilities.HiveUtilities;
    +import org.apache.hadoop.hive.serde2.*;
    +import org.apache.hadoop.hive.serde2.objectinspector.*;
    +import org.apache.hadoop.hive.serde2.objectinspector.primitive.*;
    +import 
org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
    +import 
org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory;
    +import org.apache.hadoop.hive.ql.exec.vector.*;
    +
    +@SuppressWarnings("deprecation")
    +public class HiveORCBatchResolver extends Plugin implements 
ReadVectorizedResolver {
    +
    +    private static final Log LOG = 
LogFactory.getLog(HiveORCBatchResolver.class);
    +
    +    private List<List<OneField>> resolvedBatch;
    +    private StructObjectInspector soi;
    +
    +    public HiveORCBatchResolver(InputData input) throws Exception {
    +        super(input);
    +        try {
    +            soi = (StructObjectInspector) 
HiveUtilities.getOrcReader(input).getObjectInspector();
    +        } catch (Exception e) {
    +            LOG.error("Unable to create an object inspector.");
    +            throw e;
    +        }
    +    }
    +
    +    @Override
    +    public List<List<OneField>> getFieldsForBatch(OneRow batch) {
    +
    +        Writable writableObject = null;
    +        Object fieldValue = null;
    +        VectorizedRowBatch vectorizedBatch = (VectorizedRowBatch) 
batch.getData();
    +
    +        // Allocate empty result set
    +        resolvedBatch = new 
ArrayList<List<OneField>>(vectorizedBatch.size);
    +        for (int i = 0; i < vectorizedBatch.size; i++) {
    +            ArrayList<OneField> row = new 
ArrayList<OneField>(inputData.getColumns());
    +            resolvedBatch.add(row);
    +            for (int j = 0; j < inputData.getColumns(); j++) {
    +                row.add(null);
    --- End diff --
    
    probably not very efficient, it'd be better to have a template empty row 
that can be clone() using underlying Arrays.copy() or similar methods.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to