You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by cenyuhai <gi...@git.apache.org> on 2017/08/13 12:33:31 UTC

[GitHub] carbondata pull request #1005: [CARBONDATA-1139] Added testcases for CarbonH...

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

    https://github.com/apache/carbondata/pull/1005#discussion_r132841087
  
    --- Diff: integration/hive/src/test/java/org/apache/carbondata/hive/TestCarbonHiveRecordReader.java ---
    @@ -0,0 +1,687 @@
    +/*
    + * 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.carbondata.hive;
    +
    +import mockit.Mock;
    +import mockit.MockUp;
    +import org.apache.carbondata.core.datastore.DataRefNode;
    +import org.apache.carbondata.core.datastore.IndexKey;
    +import org.apache.carbondata.core.datastore.block.BlockIndex;
    +import org.apache.carbondata.core.datastore.block.SegmentProperties;
    +import org.apache.carbondata.core.datastore.block.TableBlockInfo;
    +import org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder;
    +import org.apache.carbondata.core.datastore.impl.btree.BTreeNonLeafNode;
    +import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
    +import org.apache.carbondata.core.metadata.CarbonTableIdentifier;
    +import org.apache.carbondata.core.metadata.ColumnarFormatVersion;
    +import org.apache.carbondata.core.metadata.blocklet.DataFileFooter;
    +import org.apache.carbondata.core.metadata.schema.table.CarbonTable;
    +import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
    +import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
    +import org.apache.carbondata.core.reader.CarbonFooterReaderV3;
    +import org.apache.carbondata.core.reader.CarbonHeaderReader;
    +import org.apache.carbondata.core.reader.ThriftReader;
    +import org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo;
    +import org.apache.carbondata.core.scan.executor.util.QueryUtil;
    +import org.apache.carbondata.core.scan.model.QueryModel;
    +import org.apache.carbondata.core.scan.processor.impl.DataBlockIteratorImpl;
    +import org.apache.carbondata.core.util.CarbonUtil;
    +import org.apache.carbondata.core.util.DataFileFooterConverterV3;
    +import org.apache.carbondata.core.util.path.CarbonStorePath;
    +import org.apache.carbondata.core.util.path.CarbonTablePath;
    +import org.apache.carbondata.format.FileFooter3;
    +import org.apache.carbondata.format.FileHeader;
    +import org.apache.carbondata.hadoop.readsupport.CarbonReadSupport;
    +import org.apache.carbondata.hadoop.readsupport.impl.DictionaryDecodeReadSupport;
    +import org.apache.hadoop.hive.common.type.HiveDecimal;
    +import org.apache.hadoop.hive.conf.HiveConf;
    +import org.apache.hadoop.hive.serde.serdeConstants;
    +import org.apache.hadoop.hive.serde2.io.DateWritable;
    +import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
    +import org.apache.hadoop.hive.serde2.io.TimestampWritable;
    +import org.apache.hadoop.io.*;
    +import org.apache.hadoop.mapred.InputSplit;
    +import org.apache.hadoop.mapred.JobConf;
    +import org.apache.spark.sql.types.Decimal;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +
    +import java.io.IOException;
    +import java.lang.reflect.Field;
    +import java.sql.Date;
    +import java.sql.Timestamp;
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +import static org.junit.Assert.*;
    +
    +public class TestCarbonHiveRecordReader {
    +
    +    private static CarbonHiveRecordReader carbonHiveRecordReader;
    +    private static QueryModel queryModel;
    +    private static CarbonReadSupport carbonReadSupport;
    +    private static InputSplit inputSplit;
    +    private static JobConf jobConf;
    +    private static HiveConf configuration;
    +    private static CarbonStorePath path;
    +    private static String[] locations;
    +    private static ColumnarFormatVersion version;
    +    private static CarbonTableIdentifier carbonTableIdentifier;
    +    private static Void avoid;
    +
    +    @BeforeClass
    +    public static void setUp() throws IOException {
    +        carbonTableIdentifier = new CarbonTableIdentifier("Default", "Sample", "t1");
    +        queryModel = new QueryModel();
    +        carbonReadSupport = new DictionaryDecodeReadSupport();
    +        inputSplit = new CarbonHiveInputSplit();
    +        jobConf = new JobConf();
    +        configuration = new HiveConf();
    +        path = new CarbonStorePath("CarbonStorePath");
    +        locations = new String[]{"location1, location2, location3"};
    +        version = ColumnarFormatVersion.V3;
    +        jobConf.set("hive.io.file.readcolumn.ids", "0,1");
    +        jobConf.set("hive.io.file.readcolumn.names", "id,name");
    +        jobConf.set(serdeConstants.LIST_COLUMN_TYPES, "int,string");
    +
    +        new MockUp<CarbonTablePath.DataFileUtil>() {
    +            @Mock
    +            public String getTaskNo(String carbonDataFileName) {
    +                return "CarbondataFileName";
    +            }
    +
    +        };
    +
    +        new MockUp<QueryModel>() {
    --- End diff --
    
    why just new a object ?


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