Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0006B200BBB for ; Thu, 27 Oct 2016 07:58:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F2B8F160AFD; Thu, 27 Oct 2016 05:58:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ED6CD160AEE for ; Thu, 27 Oct 2016 07:58:17 +0200 (CEST) Received: (qmail 32898 invoked by uid 500); 27 Oct 2016 05:58:17 -0000 Mailing-List: contact issues-help@carbondata.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@carbondata.incubator.apache.org Delivered-To: mailing list issues@carbondata.incubator.apache.org Received: (qmail 32889 invoked by uid 99); 27 Oct 2016 05:58:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2016 05:58:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id B574A1A9327 for ; Thu, 27 Oct 2016 05:58:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 6sLl9KeKphGp for ; Thu, 27 Oct 2016 05:58:14 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 1D6665FADB for ; Thu, 27 Oct 2016 05:58:14 +0000 (UTC) Received: (qmail 32094 invoked by uid 99); 27 Oct 2016 05:57:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Oct 2016 05:57:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7C79D2C1F56 for ; Thu, 27 Oct 2016 05:57:58 +0000 (UTC) Date: Thu, 27 Oct 2016 05:57:58 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@carbondata.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CARBONDATA-302) 7. Add DataWriterProcessorStep which reads the data from sort temp files and creates carbondata files. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 27 Oct 2016 05:58:19 -0000 [ https://issues.apache.org/jira/browse/CARBONDATA-302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15610795#comment-15610795 ] ASF GitHub Bot commented on CARBONDATA-302: ------------------------------------------- Github user ravipesala commented on a diff in the pull request: https://github.com/apache/incubator-carbondata/pull/251#discussion_r85270264 --- Diff: processing/src/main/java/org/apache/carbondata/processing/newflow/steps/writer/DataWriterProcessorStepImpl.java --- @@ -0,0 +1,360 @@ +/* + * 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.processing.newflow.steps.writer; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.carbondata.common.logging.LogService; +import org.apache.carbondata.common.logging.LogServiceFactory; +import org.apache.carbondata.core.carbon.CarbonTableIdentifier; +import org.apache.carbondata.core.carbon.datastore.block.SegmentProperties; +import org.apache.carbondata.core.carbon.metadata.CarbonMetadata; +import org.apache.carbondata.core.carbon.metadata.schema.table.CarbonTable; +import org.apache.carbondata.core.carbon.metadata.schema.table.column.ColumnSchema; +import org.apache.carbondata.core.carbon.path.CarbonStorePath; +import org.apache.carbondata.core.carbon.path.CarbonTablePath; +import org.apache.carbondata.core.constants.CarbonCommonConstants; +import org.apache.carbondata.core.constants.IgnoreDictionary; +import org.apache.carbondata.core.keygenerator.KeyGenerator; +import org.apache.carbondata.core.util.CarbonProperties; +import org.apache.carbondata.core.util.CarbonTimeStatisticsFactory; +import org.apache.carbondata.core.util.CarbonUtil; +import org.apache.carbondata.processing.datatypes.GenericDataType; +import org.apache.carbondata.processing.newflow.AbstractDataLoadProcessorStep; +import org.apache.carbondata.processing.newflow.CarbonDataLoadConfiguration; +import org.apache.carbondata.processing.newflow.DataField; +import org.apache.carbondata.processing.newflow.constants.DataLoadProcessorConstants; +import org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException; +import org.apache.carbondata.processing.newflow.row.CarbonRow; +import org.apache.carbondata.processing.newflow.row.CarbonRowBatch; +import org.apache.carbondata.processing.store.CarbonDataFileAttributes; +import org.apache.carbondata.processing.store.CarbonFactDataHandlerModel; +import org.apache.carbondata.processing.store.CarbonFactHandler; +import org.apache.carbondata.processing.store.CarbonFactHandlerFactory; +import org.apache.carbondata.processing.store.writer.exception.CarbonDataWriterException; +import org.apache.carbondata.processing.util.CarbonDataProcessorUtil; + +/** + * It reads data from sorted files which are generated in previous sort step. + * And it writes data to carbondata file. It also generates mdk key while writing to carbondata file + */ +public class DataWriterProcessorStepImpl extends AbstractDataLoadProcessorStep { + + private static final LogService LOGGER = + LogServiceFactory.getLogService(DataWriterProcessorStepImpl.class.getName()); + + private String storeLocation; + + private boolean[] isUseInvertedIndex; + + private int[] dimLens; + + private int dimensionCount; + + private List wrapperColumnSchema; + + private int[] colCardinality; + + private SegmentProperties segmentProperties; + + private KeyGenerator keyGenerator; + + private CarbonFactHandler dataHandler; + + private Map complexIndexMap; + + private int noDictionaryCount; + + private int complexDimensionCount; + + private int measureCount; + + private long readCounter; + + private long writeCounter; + + private int measureIndex = IgnoreDictionary.MEASURES_INDEX_IN_ROW.getIndex(); + + private int noDimByteArrayIndex = IgnoreDictionary.BYTE_ARRAY_INDEX_IN_ROW.getIndex(); + + private int dimsArrayIndex = IgnoreDictionary.DIMENSION_INDEX_IN_ROW.getIndex(); + + public DataWriterProcessorStepImpl(CarbonDataLoadConfiguration configuration, + AbstractDataLoadProcessorStep child) { + super(configuration, child); + } + + @Override public DataField[] getOutput() { + return child.getOutput(); + } + + @Override public void initialize() throws CarbonDataLoadingException { + CarbonTableIdentifier tableIdentifier = + configuration.getTableIdentifier().getCarbonTableIdentifier(); + + storeLocation = CarbonDataProcessorUtil + .getLocalDataFolderLocation(tableIdentifier.getDatabaseName(), + tableIdentifier.getTableName(), String.valueOf(configuration.getTaskNo()), + configuration.getPartitionId(), configuration.getSegmentId() + "", false); + isUseInvertedIndex = + CarbonDataProcessorUtil.getIsUseInvertedIndex(configuration.getDataFields()); + + if (!(new File(storeLocation).exists())) { + LOGGER.error("Local data load folder location does not exist: " + storeLocation); + return; + } + + int[] dimLensWithComplex = + (int[]) configuration.getDataLoadProperty(DataLoadProcessorConstants.DIMENSION_LENGTHS); + List dimsLenList = new ArrayList(); + for (int eachDimLen : dimLensWithComplex) { + if (eachDimLen != 0) dimsLenList.add(eachDimLen); + } + dimLens = new int[dimsLenList.size()]; + for (int i = 0; i < dimsLenList.size(); i++) { + dimLens[i] = dimsLenList.get(i); + } + + this.dimensionCount = configuration.getDimensionCount(); + this.noDictionaryCount = configuration.getNoDictionaryCount(); + this.complexDimensionCount = configuration.getComplexDimensionCount(); + this.measureCount = configuration.getMeasureCount(); + + int simpleDimsCount = this.dimensionCount - complexDimensionCount; + int[] simpleDimsLen = new int[simpleDimsCount]; + for (int i = 0; i < simpleDimsCount; i++) { + simpleDimsLen[i] = dimLens[i]; + } + + CarbonTable carbonTable = CarbonMetadata.getInstance().getCarbonTable( + tableIdentifier.getDatabaseName() + CarbonCommonConstants.UNDERSCORE + tableIdentifier + .getTableName()); + wrapperColumnSchema = CarbonUtil + .getColumnSchemaList(carbonTable.getDimensionByTableName(tableIdentifier.getTableName()), + carbonTable.getMeasureByTableName(tableIdentifier.getTableName())); + colCardinality = CarbonUtil.getFormattedCardinality(dimLensWithComplex, wrapperColumnSchema); + segmentProperties = new SegmentProperties(wrapperColumnSchema, colCardinality); + // Actual primitive dimension used to generate start & end key + + keyGenerator = segmentProperties.getDimensionKeyGenerator(); + + //To Set MDKey Index of each primitive type in complex type + int surrIndex = simpleDimsCount; + Iterator> complexMap = + CarbonDataProcessorUtil.getComplexTypesMap(configuration.getDataFields()).entrySet() + .iterator(); + complexIndexMap = new HashMap(complexDimensionCount); + while (complexMap.hasNext()) { + Map.Entry complexDataType = complexMap.next(); + complexDataType.getValue().setOutputArrayIndex(0); + complexIndexMap.put(simpleDimsCount, complexDataType.getValue()); + simpleDimsCount++; + List primitiveTypes = new ArrayList(); + complexDataType.getValue().getAllPrimitiveChildren(primitiveTypes); + for (GenericDataType eachPrimitive : primitiveTypes) { + eachPrimitive.setSurrogateIndex(surrIndex++); + } + } + } + + private void initDataHandler() { + int simpleDimsCount = dimensionCount - complexDimensionCount; + int[] simpleDimsLen = new int[simpleDimsCount]; + for (int i = 0; i < simpleDimsCount; i++) { + simpleDimsLen[i] = dimLens[i]; + } + CarbonDataFileAttributes carbonDataFileAttributes = + new CarbonDataFileAttributes(Integer.parseInt(configuration.getTaskNo()), + (String) configuration.getDataLoadProperty(DataLoadProcessorConstants.FACT_TIME_STAMP)); + String carbonDataDirectoryPath = getCarbonDataFolderLocation(); + CarbonFactDataHandlerModel carbonFactDataHandlerModel = getCarbonFactDataHandlerModel(); + carbonFactDataHandlerModel.setPrimitiveDimLens(simpleDimsLen); + carbonFactDataHandlerModel.setCarbonDataFileAttributes(carbonDataFileAttributes); + carbonFactDataHandlerModel.setCarbonDataDirectoryPath(carbonDataDirectoryPath); + carbonFactDataHandlerModel.setIsUseInvertedIndex(isUseInvertedIndex); + if (noDictionaryCount > 0 || complexDimensionCount > 0) { + carbonFactDataHandlerModel.setMdKeyIndex(measureCount + 1); + } else { + carbonFactDataHandlerModel.setMdKeyIndex(measureCount); + } + dataHandler = CarbonFactHandlerFactory.createCarbonFactHandler(carbonFactDataHandlerModel, --- End diff -- ok > 7. Add DataWriterProcessorStep which reads the data from sort temp files and creates carbondata files. > ------------------------------------------------------------------------------------------------------ > > Key: CARBONDATA-302 > URL: https://issues.apache.org/jira/browse/CARBONDATA-302 > Project: CarbonData > Issue Type: Sub-task > Reporter: Ravindra Pesala > Assignee: Ravindra Pesala > Fix For: 0.3.0-incubating > > > Add DataWriterProcessorStep which reads the data from sort temp files and merge sort it, and apply mdk generator on key and creates carbondata files. -- This message was sent by Atlassian JIRA (v6.3.4#6332)