carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] incubator-carbondata git commit: Refactor dictionary based result collector class. Initialization of variables is moved to constructor. So that initialization is done only once on object creation instead of running a business logic.
Date Thu, 23 Mar 2017 16:58:25 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 10f6bf832 -> 25115c3f8


Refactor dictionary based result collector class.
Initialization of variables is moved to constructor. So that initialization is done only once
on object creation instead of running a business logic.


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/542fcb92
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/542fcb92
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/542fcb92

Branch: refs/heads/master
Commit: 542fcb921ac32eeb8b26e484dbd60b9b5fb16e8c
Parents: 10f6bf8
Author: thotasrinath <srinath.thota@outlook.com>
Authored: Thu Mar 23 19:14:13 2017 +0530
Committer: thotasrinath <srinath.thota@outlook.com>
Committed: Thu Mar 23 19:18:47 2017 +0530

----------------------------------------------------------------------
 .../impl/DictionaryBasedResultCollector.java    | 36 +++++++++++---------
 ...structureBasedDictionaryResultCollector.java | 11 +++---
 2 files changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/542fcb92/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
index 6077d13..e5e4b3c 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/DictionaryBasedResultCollector.java
@@ -65,8 +65,17 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
   protected int noDictionaryColumnIndex;
   protected int complexTypeColumnIndex;
 
+  protected boolean isDimensionExists;
+
+  protected Map<Integer, GenericQueryType> comlexDimensionInfoMap;
+
   public DictionaryBasedResultCollector(BlockExecutionInfo blockExecutionInfos) {
     super(blockExecutionInfos);
+    queryDimensions = tableBlockExecutionInfos.getQueryDimensions();
+    queryMeasures = tableBlockExecutionInfos.getQueryMeasures();
+    initDimensionAndMeasureIndexesForFillingData();
+    isDimensionExists = queryDimensions.length > 0;
+    this.comlexDimensionInfoMap = tableBlockExecutionInfos.getComlexDimensionInfoMap();
   }
 
   /**
@@ -74,23 +83,18 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
    * it will keep track of how many record is processed, to handle limit scenario
    */
   @Override public List<Object[]> collectData(AbstractScannedResult scannedResult,
int batchSize) {
-    queryDimensions = tableBlockExecutionInfos.getQueryDimensions();
-    queryMeasures = tableBlockExecutionInfos.getQueryMeasures();
-    initDimensionAndMeasureIndexesForFillingData();
+
     // scan the record and add to list
     List<Object[]> listBasedResult = new ArrayList<>(batchSize);
     int rowCounter = 0;
     int[] surrogateResult;
     String[] noDictionaryKeys;
     byte[][] complexTypeKeyArray;
-    boolean isDimensionsExist = queryDimensions.length > 0;
     BlockletLevelDeleteDeltaDataCache deleteDeltaDataCache =
         scannedResult.getDeleteDeltaDataCache();
-    Map<Integer, GenericQueryType> comlexDimensionInfoMap =
-        tableBlockExecutionInfos.getComlexDimensionInfoMap();
     while (scannedResult.hasNext() && rowCounter < batchSize) {
       Object[] row = new Object[queryDimensions.length + queryMeasures.length];
-      if (isDimensionsExist) {
+      if (isDimensionExists) {
         surrogateResult = scannedResult.getDictionaryKeyIntegerArray();
         noDictionaryKeys = scannedResult.getNoDictionaryKeyStringArray();
         complexTypeKeyArray = scannedResult.getComplexTypeKeyArray();
@@ -123,11 +127,11 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
         if (CarbonCommonConstants.CARBON_IMPLICIT_COLUMN_TUPLEID
             .equals(queryDimensions[i].getDimension().getColName())) {
           row[order[i]] = DataTypeUtil.getDataBasedOnDataType(
-              scannedResult.getBlockletId() + CarbonCommonConstants.FILE_SEPARATOR
-                  + scannedResult.getCurrentRowId(), DataType.STRING);
+              scannedResult.getBlockletId() + CarbonCommonConstants.FILE_SEPARATOR + scannedResult
+                  .getCurrentRowId(), DataType.STRING);
         } else {
-          row[order[i]] = DataTypeUtil
-              .getDataBasedOnDataType(scannedResult.getBlockletId(), DataType.STRING);
+          row[order[i]] =
+              DataTypeUtil.getDataBasedOnDataType(scannedResult.getBlockletId(), DataType.STRING);
         }
       } else {
         row[order[i]] = DataTypeUtil
@@ -140,10 +144,9 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
             surrogateResult[actualIndexInSurrogateKey[dictionaryColumnIndex++]]);
       }
     } else if (complexDataTypeArray[i]) {
-      row[order[i]] =
-          comlexDimensionInfoMap.get(queryDimensions[i].getDimension().getOrdinal())
-              .getDataBasedOnDataTypeFromSurrogates(
-                  ByteBuffer.wrap(complexTypeKeyArray[complexTypeColumnIndex++]));
+      row[order[i]] = comlexDimensionInfoMap.get(queryDimensions[i].getDimension().getOrdinal())
+          .getDataBasedOnDataTypeFromSurrogates(
+              ByteBuffer.wrap(complexTypeKeyArray[complexTypeColumnIndex++]));
     } else {
       row[order[i]] = surrogateResult[actualIndexInSurrogateKey[dictionaryColumnIndex++]];
     }
@@ -191,8 +194,7 @@ public class DictionaryBasedResultCollector extends AbstractScannedResultCollect
     for (int i = 0; i < queryMeasures.length; i++) {
       order[i + queryDimensions.length] = queryMeasures[i].getQueryOrder();
     }
-    directDictionaryGenerators =
-        new DirectDictionaryGenerator[queryDimensions.length];
+    directDictionaryGenerators = new DirectDictionaryGenerator[queryDimensions.length];
     for (int i = 0; i < queryDimensions.length; i++) {
       directDictionaryGenerators[i] = DirectDictionaryKeyGeneratorFactory
           .getDirectDictionaryGenerator(queryDimensions[i].getDimension().getDataType());

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/542fcb92/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedDictionaryResultCollector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedDictionaryResultCollector.java
b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedDictionaryResultCollector.java
index 89fa7c3..71045ff 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedDictionaryResultCollector.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/collector/impl/RestructureBasedDictionaryResultCollector.java
@@ -32,6 +32,11 @@ public class RestructureBasedDictionaryResultCollector extends DictionaryBasedRe
 
   public RestructureBasedDictionaryResultCollector(BlockExecutionInfo blockExecutionInfos)
{
     super(blockExecutionInfos);
+    queryDimensions = tableBlockExecutionInfos.getActualQueryDimensions();
+    queryMeasures = tableBlockExecutionInfos.getActualQueryMeasures();
+    initDimensionAndMeasureIndexesForFillingData();
+    initDimensionAndMeasureIndexesForFillingData();
+    isDimensionExists = queryDimensions.length > 0;
   }
 
   /**
@@ -39,23 +44,19 @@ public class RestructureBasedDictionaryResultCollector extends DictionaryBasedRe
    * it will keep track of how many record is processed, to handle limit scenario
    */
   @Override public List<Object[]> collectData(AbstractScannedResult scannedResult,
int batchSize) {
-    queryDimensions = tableBlockExecutionInfos.getActualQueryDimensions();
-    queryMeasures = tableBlockExecutionInfos.getActualQueryMeasures();
-    initDimensionAndMeasureIndexesForFillingData();
     // scan the record and add to list
     List<Object[]> listBasedResult = new ArrayList<>(batchSize);
     int rowCounter = 0;
     int[] surrogateResult;
     String[] noDictionaryKeys;
     byte[][] complexTypeKeyArray;
-    boolean isDimensionsExist = queryDimensions.length > 0;
     BlockletLevelDeleteDeltaDataCache deleteDeltaDataCache =
         scannedResult.getDeleteDeltaDataCache();
     Map<Integer, GenericQueryType> comlexDimensionInfoMap =
         tableBlockExecutionInfos.getComlexDimensionInfoMap();
     while (scannedResult.hasNext() && rowCounter < batchSize) {
       Object[] row = new Object[queryDimensions.length + queryMeasures.length];
-      if (isDimensionsExist) {
+      if (isDimensionExists) {
         surrogateResult = scannedResult.getDictionaryKeyIntegerArray();
         noDictionaryKeys = scannedResult.getNoDictionaryKeyStringArray();
         complexTypeKeyArray = scannedResult.getComplexTypeKeyArray();


Mime
View raw message