carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [2/7] incubator-carbondata git commit: Added support for offheap storage in query
Date Sun, 08 Jan 2017 14:30:20 GMT
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/ExcludeFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/ExcludeFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/ExcludeFilterExecuterImpl.java
index b3136b6..9077ef3 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/ExcludeFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/ExcludeFilterExecuterImpl.java
@@ -20,13 +20,11 @@ package org.apache.carbondata.scan.filter.executer;
 
 import java.io.IOException;
 import java.util.BitSet;
-import java.util.List;
 
 import org.apache.carbondata.core.carbon.datastore.block.SegmentProperties;
 import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
 import org.apache.carbondata.core.carbon.datastore.chunk.impl.FixedLengthDimensionDataChunk;
 import org.apache.carbondata.core.carbon.datastore.chunk.impl.VariableLengthDimensionDataChunk;
-import org.apache.carbondata.core.util.ByteUtil;
 import org.apache.carbondata.core.util.CarbonUtil;
 import org.apache.carbondata.scan.filter.FilterUtil;
 import org.apache.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
@@ -51,10 +49,6 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
     int blockIndex = segmentProperties.getDimensionOrdinalToBlockMapping()
         .get(dimColEvaluatorInfo.getColumnIndex());
     if (null == blockChunkHolder.getDimensionDataChunk()[blockIndex]) {
-      blockChunkHolder.getDataBlock()
-          .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex);
-    }
-    if (null == blockChunkHolder.getDimensionDataChunk()[blockIndex]) {
       blockChunkHolder.getDimensionDataChunk()[blockIndex] = blockChunkHolder.getDataBlock()
           .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex);
     }
@@ -65,12 +59,12 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
   protected BitSet getFilteredIndexes(DimensionColumnDataChunk dimColumnDataChunk,
       int numerOfRows) {
     // For high cardinality dimensions.
-    if (dimColumnDataChunk.getAttributes().isNoDictionary()
+    if (dimColumnDataChunk.isNoDicitionaryColumn()
         && dimColumnDataChunk instanceof VariableLengthDimensionDataChunk) {
       return setDirectKeyFilterIndexToBitSet((VariableLengthDimensionDataChunk) dimColumnDataChunk,
           numerOfRows);
     }
-    if (null != dimColumnDataChunk.getAttributes().getInvertedIndexes()
+    if (dimColumnDataChunk.isExplicitSorted()
         && dimColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
       return setFilterdIndexToBitSetWithColumnIndex(
           (FixedLengthDimensionDataChunk) dimColumnDataChunk, numerOfRows);
@@ -82,44 +76,21 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
       VariableLengthDimensionDataChunk dimColumnDataChunk, int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
     bitSet.flip(0, numerOfRows);
-    List<byte[]> listOfColumnarKeyBlockDataForNoDictionaryVal =
-        dimColumnDataChunk.getCompleteDataChunk();
     byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
-    int[] columnIndexArray = dimColumnDataChunk.getAttributes().getInvertedIndexes();
-    int[] columnReverseIndexArray = dimColumnDataChunk.getAttributes().getInvertedIndexesReverse();
     for (int i = 0; i < filterValues.length; i++) {
       byte[] filterVal = filterValues[i];
-      if (null != listOfColumnarKeyBlockDataForNoDictionaryVal) {
-
-        if (null != columnReverseIndexArray) {
-          for (int index : columnIndexArray) {
-            byte[] noDictionaryVal =
-                listOfColumnarKeyBlockDataForNoDictionaryVal.get(columnReverseIndexArray[index]);
-            if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, noDictionaryVal) == 0) {
-              bitSet.flip(index);
-            }
-          }
-        } else if (null != columnIndexArray) {
-
-          for (int index : columnIndexArray) {
-            byte[] noDictionaryVal =
-                listOfColumnarKeyBlockDataForNoDictionaryVal.get(columnIndexArray[index]);
-            if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, noDictionaryVal) == 0) {
-              bitSet.flip(index);
-            }
+      if (dimColumnDataChunk.isExplicitSorted()) {
+        for (int index = 0; index < numerOfRows; index++) {
+          if (dimColumnDataChunk.compareTo(index, filterVal) == 0) {
+            bitSet.flip(dimColumnDataChunk.getInvertedIndex(index));
           }
-        } else {
-          for (int index = 0;
-               index < listOfColumnarKeyBlockDataForNoDictionaryVal.size(); index++) {
-            if (ByteUtil.UnsafeComparer.INSTANCE
-                .compareTo(filterVal, listOfColumnarKeyBlockDataForNoDictionaryVal.get(index))
-                == 0) {
-              bitSet.flip(index);
-            }
+        }
+      } else {
+        for (int index = 0; index < numerOfRows; index++) {
+          if (dimColumnDataChunk.compareTo(index, filterVal) == 0) {
+            bitSet.flip(index);
           }
-
         }
-
       }
     }
     return bitSet;
@@ -128,7 +99,6 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
 
   private BitSet setFilterdIndexToBitSetWithColumnIndex(
       FixedLengthDimensionDataChunk dimColumnDataChunk, int numerOfRows) {
-    int[] columnIndex = dimColumnDataChunk.getAttributes().getInvertedIndexes();
     int startKey = 0;
     int last = 0;
     int startIndex = 0;
@@ -142,13 +112,11 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
       if (startKey < 0) {
         continue;
       }
-      bitSet.flip(columnIndex[startKey]);
+      bitSet.flip(dimColumnDataChunk.getInvertedIndex(startKey));
       last = startKey;
       for (int j = startKey + 1; j < numerOfRows; j++) {
-        if (ByteUtil.UnsafeComparer.INSTANCE
-            .compareTo(dimColumnDataChunk.getCompleteDataChunk(), j * filterValues[i].length,
-                filterValues[i].length, filterValues[i], 0, filterValues[i].length) == 0) {
-          bitSet.flip(columnIndex[j]);
+        if (dimColumnDataChunk.compareTo(j, filterValues[i]) == 0) {
+          bitSet.flip(dimColumnDataChunk.getInvertedIndex(j));
           last++;
         } else {
           break;
@@ -169,9 +137,7 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
     byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
     for (int k = 0; k < filterValues.length; k++) {
       for (int j = 0; j < numerOfRows; j++) {
-        if (ByteUtil.UnsafeComparer.INSTANCE
-            .compareTo(dimColumnDataChunk.getCompleteDataChunk(), j * filterValues[k].length,
-                filterValues[k].length, filterValues[k], 0, filterValues[k].length) == 0) {
+        if (dimColumnDataChunk.compareTo(j, filterValues[k]) == 0) {
           bitSet.flip(j);
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/IncludeFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/IncludeFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/IncludeFilterExecuterImpl.java
index becec63..0de0a4d 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/IncludeFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/IncludeFilterExecuterImpl.java
@@ -20,7 +20,6 @@ package org.apache.carbondata.scan.filter.executer;
 
 import java.io.IOException;
 import java.util.BitSet;
-import java.util.List;
 
 import org.apache.carbondata.core.carbon.datastore.block.SegmentProperties;
 import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
@@ -61,11 +60,11 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
 
   protected BitSet getFilteredIndexes(DimensionColumnDataChunk dimensionColumnDataChunk,
       int numerOfRows) {
-    if (dimensionColumnDataChunk.getAttributes().isNoDictionary()
+    if (dimensionColumnDataChunk.isNoDicitionaryColumn()
         && dimensionColumnDataChunk instanceof VariableLengthDimensionDataChunk) {
       return setDirectKeyFilterIndexToBitSet(
           (VariableLengthDimensionDataChunk) dimensionColumnDataChunk, numerOfRows);
-    } else if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexes()
+    } else if (dimensionColumnDataChunk.isExplicitSorted()
         && dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
       return setFilterdIndexToBitSetWithColumnIndex(
           (FixedLengthDimensionDataChunk) dimensionColumnDataChunk, numerOfRows);
@@ -77,39 +76,19 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
   private BitSet setDirectKeyFilterIndexToBitSet(
       VariableLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
-    List<byte[]> listOfColumnarKeyBlockDataForNoDictionaryVals =
-        dimensionColumnDataChunk.getCompleteDataChunk();
     byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
-    int[] columnIndexArray = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
-    int[] columnReverseIndexArray =
-        dimensionColumnDataChunk.getAttributes().getInvertedIndexesReverse();
     for (int i = 0; i < filterValues.length; i++) {
       byte[] filterVal = filterValues[i];
-      if (null != listOfColumnarKeyBlockDataForNoDictionaryVals) {
-        if (null != columnIndexArray) {
-          for (int index : columnIndexArray) {
-            byte[] noDictionaryVal =
-                listOfColumnarKeyBlockDataForNoDictionaryVals.get(columnReverseIndexArray[index]);
-            if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, noDictionaryVal) == 0) {
-              bitSet.set(index);
-            }
+      if (dimensionColumnDataChunk.isExplicitSorted()) {
+        for (int index = 0; index < numerOfRows; index++) {
+          if (dimensionColumnDataChunk.compareTo(index, filterVal) == 0) {
+            bitSet.set(dimensionColumnDataChunk.getInvertedIndex(index));
           }
-        } else if (null != columnReverseIndexArray) {
-          for (int index : columnReverseIndexArray) {
-            byte[] noDictionaryVal =
-                listOfColumnarKeyBlockDataForNoDictionaryVals.get(columnReverseIndexArray[index]);
-            if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, noDictionaryVal) == 0) {
-              bitSet.set(index);
-            }
-          }
-        } else {
-          for (int index = 0;
-               index < listOfColumnarKeyBlockDataForNoDictionaryVals.size(); index++) {
-            if (ByteUtil.UnsafeComparer.INSTANCE
-                .compareTo(filterVal, listOfColumnarKeyBlockDataForNoDictionaryVals.get(index))
-                == 0) {
-              bitSet.set(index);
-            }
+        }
+      } else {
+        for (int index = 0; index < numerOfRows; index++) {
+          if (dimensionColumnDataChunk.compareTo(index, filterVal) == 0) {
+            bitSet.set(index);
           }
         }
       }
@@ -121,7 +100,6 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
   private BitSet setFilterdIndexToBitSetWithColumnIndex(
       FixedLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
-    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
     int start = 0;
     int last = 0;
     int startIndex = 0;
@@ -133,13 +111,11 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
       if (start < 0) {
         continue;
       }
-      bitSet.set(columnIndex[start]);
+      bitSet.set(dimensionColumnDataChunk.getInvertedIndex(start));
       last = start;
       for (int j = start + 1; j < numerOfRows; j++) {
-        if (ByteUtil.UnsafeComparer.INSTANCE
-            .compareTo(dimensionColumnDataChunk.getCompleteDataChunk(), j * filterValues[i].length,
-                filterValues[i].length, filterValues[i], 0, filterValues[i].length) == 0) {
-          bitSet.set(columnIndex[j]);
+        if (dimensionColumnDataChunk.compareTo(j, filterValues[i]) == 0) {
+          bitSet.set(dimensionColumnDataChunk.getInvertedIndex(j));
           last++;
         } else {
           break;
@@ -157,14 +133,10 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
       int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
     if (dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
-      FixedLengthDimensionDataChunk fixedDimensionChunk =
-          (FixedLengthDimensionDataChunk) dimensionColumnDataChunk;
       byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
       for (int k = 0; k < filterValues.length; k++) {
         for (int j = 0; j < numerOfRows; j++) {
-          if (ByteUtil.UnsafeComparer.INSTANCE
-              .compareTo(fixedDimensionChunk.getCompleteDataChunk(), j * filterValues[k].length,
-                  filterValues[k].length, filterValues[k], 0, filterValues[k].length) == 0) {
+          if (dimensionColumnDataChunk.compareTo(j, filterValues[k]) == 0) {
             bitSet.set(j);
           }
         }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelFilterExecuterImpl.java
index 678cf51..6464c5c 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelFilterExecuterImpl.java
@@ -111,8 +111,8 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
     // CHECKSTYLE:OFF Approval No:Approval-V1R2C10_001
     if (null != msrColEvalutorInfoList) {
       for (MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo : msrColEvalutorInfoList) {
-        if (null == blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()])
-        {
+        if (null == blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo
+            .getColumnIndex()]) {
           blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()] =
               blockChunkHolder.getDataBlock().getMeasureChunk(blockChunkHolder.getFileReader(),
                   msrColumnEvalutorInfo.getColumnIndex());
@@ -171,14 +171,10 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
           VariableLengthDimensionDataChunk dimensionColumnDataChunk =
               (VariableLengthDimensionDataChunk) blockChunkHolder
                   .getDimensionDataChunk()[blocksIndex[i]];
-          if (null != dimensionColumnDataChunk.getCompleteDataChunk()) {
-            memberString =
-                readMemberBasedOnNoDictionaryVal(dimensionColumnDataChunk,
-                    index);
-            if (null != memberString) {
-              if (memberString.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
-                memberString = null;
-              }
+          memberString = readMemberBasedOnNoDictionaryVal(dimensionColumnDataChunk, index);
+          if (null != memberString) {
+            if (memberString.equals(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
+              memberString = null;
             }
             record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil
                 .getDataBasedOnDataType(memberString,
@@ -241,19 +237,16 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
       switch (msrType) {
         case INT:
         case LONG:
-          msrValue =
-              blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
-                  .getMeasureDataHolder().getReadableLongValueByIndex(index);
+          msrValue = blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
+              .getMeasureDataHolder().getReadableLongValueByIndex(index);
           break;
         case DECIMAL:
-          msrValue =
-              blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
-                  .getMeasureDataHolder().getReadableBigDecimalValueByIndex(index);
+          msrValue = blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
+              .getMeasureDataHolder().getReadableBigDecimalValueByIndex(index);
           break;
         default:
-          msrValue =
-              blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
-                  .getMeasureDataHolder().getReadableDoubleValueByIndex(index);
+          msrValue = blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
+              .getMeasureDataHolder().getReadableDoubleValueByIndex(index);
       }
       record[msrColumnEvalutorInfo.getRowIndex()] =
           blockChunkHolder.getMeasureDataChunk()[msrColumnEvalutorInfo.getColumnIndex()]
@@ -293,8 +286,8 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
   private String getFilterActualValueFromDictionaryValue(
       DimColumnResolvedFilterInfo dimColumnEvaluatorInfo, int dictionaryValue) throws IOException {
     String memberString;
-    Dictionary forwardDictionary = FilterUtil.getForwardDictionaryCache(
-        tableIdentifier, dimColumnEvaluatorInfo.getDimension());
+    Dictionary forwardDictionary = FilterUtil
+        .getForwardDictionaryCache(tableIdentifier, dimColumnEvaluatorInfo.getDimension());
 
     memberString = forwardDictionary.getDictionaryValueForKey(dictionaryValue);
     if (null != memberString) {
@@ -363,15 +356,8 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
    */
   private String readMemberBasedOnNoDictionaryVal(
       VariableLengthDimensionDataChunk dimensionColumnDataChunk, int index) {
-    byte[] noDictionaryVals;
-    if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexesReverse()) {
-      // Getting the data for direct surrogates.
-      noDictionaryVals = dimensionColumnDataChunk.getCompleteDataChunk()
-          .get(dimensionColumnDataChunk.getAttributes().getInvertedIndexesReverse()[index]);
-    } else {
-      noDictionaryVals = dimensionColumnDataChunk.getCompleteDataChunk().get(index);
-    }
-    return new String(noDictionaryVals, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+    return new String(dimensionColumnDataChunk.getChunkData(index),
+        Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
   }
 
   @Override public BitSet isScanRequired(byte[][] blockMaxValue, byte[][] blockMinValue) {

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java
index cb21c88..7a2c195 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java
@@ -90,7 +90,7 @@ public class RowLevelRangeGrtThanFiterExecuterImpl extends RowLevelFilterExecute
 
   private BitSet getFilteredIndexes(DimensionColumnDataChunk dimensionColumnDataChunk,
       int numerOfRows) {
-    if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexes()
+    if (dimensionColumnDataChunk.isExplicitSorted()
         && dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
       return setFilterdIndexToBitSetWithColumnIndex(
           (FixedLengthDimensionDataChunk) dimensionColumnDataChunk, numerOfRows);
@@ -111,7 +111,6 @@ public class RowLevelRangeGrtThanFiterExecuterImpl extends RowLevelFilterExecute
   private BitSet setFilterdIndexToBitSetWithColumnIndex(
       FixedLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
-    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
     int start = 0;
     int last = 0;
     int startIndex = 0;
@@ -136,8 +135,8 @@ public class RowLevelRangeGrtThanFiterExecuterImpl extends RowLevelFilterExecute
         // Method will compare the tentative index value after binary search, this tentative
         // index needs to be compared by the filter member if its > filter then from that
         // index the bitset will be considered for filtering process.
-        if (ByteUtil
-            .compare(filterValues[i], dimensionColumnDataChunk.getChunkData(columnIndex[start]))
+        if (ByteUtil.compare(filterValues[i],
+            dimensionColumnDataChunk.getChunkData(dimensionColumnDataChunk.getInvertedIndex(start)))
             > 0) {
           start = start + 1;
         }
@@ -145,7 +144,7 @@ public class RowLevelRangeGrtThanFiterExecuterImpl extends RowLevelFilterExecute
 
       last = start;
       for (int j = start; j < numerOfRows; j++) {
-        bitSet.set(columnIndex[j]);
+        bitSet.set(dimensionColumnDataChunk.getInvertedIndex(j));
         last++;
       }
       startIndex = last;

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java
index 7f4cc7c..9bb6c12 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java
@@ -91,7 +91,7 @@ public class RowLevelRangeGrtrThanEquaToFilterExecuterImpl extends RowLevelFilte
 
   private BitSet getFilteredIndexes(DimensionColumnDataChunk dimensionColumnDataChunk,
       int numerOfRows) {
-    if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexes()
+    if (dimensionColumnDataChunk.isExplicitSorted()
         && dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
       return setFilterdIndexToBitSetWithColumnIndex(
           (FixedLengthDimensionDataChunk) dimensionColumnDataChunk, numerOfRows);
@@ -112,7 +112,6 @@ public class RowLevelRangeGrtrThanEquaToFilterExecuterImpl extends RowLevelFilte
   private BitSet setFilterdIndexToBitSetWithColumnIndex(
       FixedLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows) {
     BitSet bitSet = new BitSet(numerOfRows);
-    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
     int start = 0;
     int last = 0;
     int startIndex = 0;
@@ -129,16 +128,15 @@ public class RowLevelRangeGrtrThanEquaToFilterExecuterImpl extends RowLevelFilte
         // Method will compare the tentative index value after binary search, this tentative
         // index needs to be compared by the filter member if its >= filter then from that
         // index the bitset will be considered for filtering process.
-        if (ByteUtil
-            .compare(filterValues[i], dimensionColumnDataChunk.getChunkData(columnIndex[start]))
+        if (ByteUtil.compare(filterValues[i],
+            dimensionColumnDataChunk.getChunkData(dimensionColumnDataChunk.getInvertedIndex(start)))
             >= 0) {
           start = start + 1;
         }
       }
       last = start;
       for (int j = start; j < numerOfRows; j++) {
-
-        bitSet.set(columnIndex[j]);
+        bitSet.set(dimensionColumnDataChunk.getInvertedIndex(j));
         last++;
       }
       startIndex = last;

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
index 4d7284d..8f47af2 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
@@ -102,7 +102,7 @@ public class RowLevelRangeLessThanEqualFilterExecuterImpl extends RowLevelFilter
       defaultValue = FilterUtil.getMaskKey(key, dimColEvaluatorInfoList.get(0).getDimension(),
           this.segmentProperties.getDimensionKeyGenerator());
     }
-    if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexes()
+    if (dimensionColumnDataChunk.isExplicitSorted()
         && dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
 
       return setFilterdIndexToBitSetWithColumnIndex(
@@ -126,7 +126,6 @@ public class RowLevelRangeLessThanEqualFilterExecuterImpl extends RowLevelFilter
       FixedLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows,
       byte[] defaultValue) {
     BitSet bitSet = new BitSet(numerOfRows);
-    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
     int start = 0;
     int last = 0;
     int skip = 0;
@@ -160,15 +159,15 @@ public class RowLevelRangeLessThanEqualFilterExecuterImpl extends RowLevelFilter
         // Method will compare the tentative index value after binary search, this tentative
         // index needs to be compared by the filter member if its >= filter then from that
         // index the bitset will be considered for filtering process.
-        if (ByteUtil
-            .compare(filterValues[i], dimensionColumnDataChunk.getChunkData(columnIndex[start]))
+        if (ByteUtil.compare(filterValues[i],
+            dimensionColumnDataChunk.getChunkData(dimensionColumnDataChunk.getInvertedIndex(start)))
             <= 0) {
           start = start - 1;
         }
       }
       last = start;
       for (int j = start; j >= skip; j--) {
-        bitSet.set(columnIndex[j]);
+        bitSet.set(dimensionColumnDataChunk.getInvertedIndex(j));
         last--;
       }
       startIndex = last;

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
index 4819cb5..05c39ff 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
@@ -102,7 +102,7 @@ public class RowLevelRangeLessThanFiterExecuterImpl extends RowLevelFilterExecut
       defaultValue = FilterUtil.getMaskKey(key, dimColEvaluatorInfoList.get(0).getDimension(),
           this.segmentProperties.getDimensionKeyGenerator());
     }
-    if (null != dimensionColumnDataChunk.getAttributes().getInvertedIndexes()
+    if (dimensionColumnDataChunk.isExplicitSorted()
         && dimensionColumnDataChunk instanceof FixedLengthDimensionDataChunk) {
       return setFilterdIndexToBitSetWithColumnIndex(
           (FixedLengthDimensionDataChunk) dimensionColumnDataChunk, numerOfRows, defaultValue);
@@ -124,7 +124,6 @@ public class RowLevelRangeLessThanFiterExecuterImpl extends RowLevelFilterExecut
       FixedLengthDimensionDataChunk dimensionColumnDataChunk, int numerOfRows,
       byte[] defaultValue) {
     BitSet bitSet = new BitSet(numerOfRows);
-    int[] columnIndex = dimensionColumnDataChunk.getAttributes().getInvertedIndexes();
     int start = 0;
     int last = 0;
     int startIndex = 0;
@@ -165,15 +164,15 @@ public class RowLevelRangeLessThanFiterExecuterImpl extends RowLevelFilterExecut
         // Method will compare the tentative index value after binary search, this tentative
         // index needs to be compared by the filter member if its < filter then from that
         // index the bitset will be considered for filtering process.
-        if (ByteUtil
-            .compare(filterValues[i], dimensionColumnDataChunk.getChunkData(columnIndex[start]))
+        if (ByteUtil.compare(filterValues[i],
+            dimensionColumnDataChunk.getChunkData(dimensionColumnDataChunk.getInvertedIndex(start)))
             < 0) {
           start = start - 1;
         }
       }
       last = start;
       for (int j = start; j >= skip; j--) {
-        bitSet.set(columnIndex[j]);
+        bitSet.set(dimensionColumnDataChunk.getInvertedIndex(j));
         last--;
       }
       startIndex = last;

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java b/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
index 8f22f89..0b0fd88 100644
--- a/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
+++ b/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
@@ -254,8 +254,8 @@ public abstract class AbstractScannedResult {
    * Just increment the counter incase of query only on measures.
    */
   public void incrementCounter() {
-    rowCounter ++;
-    currentRow ++;
+    rowCounter++;
+    currentRow++;
   }
 
   /**
@@ -380,7 +380,11 @@ public abstract class AbstractScannedResult {
    * @return
    */
   public boolean hasNext() {
-    return rowCounter < this.totalNumberOfRows;
+    if (rowCounter < this.totalNumberOfRows) {
+      return true;
+    }
+    CarbonUtil.freeMemory(dataChunks, measureDataChunks);
+    return false;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/main/java/org/apache/carbondata/scan/scanner/impl/FilterScanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/scanner/impl/FilterScanner.java b/core/src/main/java/org/apache/carbondata/scan/scanner/impl/FilterScanner.java
index 850a03f..c0364ee 100644
--- a/core/src/main/java/org/apache/carbondata/scan/scanner/impl/FilterScanner.java
+++ b/core/src/main/java/org/apache/carbondata/scan/scanner/impl/FilterScanner.java
@@ -32,6 +32,7 @@ import org.apache.carbondata.core.carbon.querystatistics.QueryStatisticsModel;
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.datastorage.store.FileHolder;
 import org.apache.carbondata.core.util.CarbonProperties;
+import org.apache.carbondata.core.util.CarbonUtil;
 import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
 import org.apache.carbondata.scan.expression.exception.FilterUnsupportedException;
 import org.apache.carbondata.scan.filter.executer.FilterExecuter;
@@ -122,6 +123,8 @@ public class FilterScanner extends AbstractBlockletScanner {
       if (bitSet.isEmpty()) {
         scannedResult.setNumberOfRows(0);
         scannedResult.setIndexes(new int[0]);
+        CarbonUtil.freeMemory(blocksChunkHolder.getDimensionDataChunk(),
+            blocksChunkHolder.getMeasureDataChunk());
         return;
       }
     }
@@ -148,8 +151,8 @@ public class FilterScanner extends AbstractBlockletScanner {
     }
     // loading delete data cache in blockexecutioninfo instance
     DeleteDeltaCacheLoaderIntf deleteCacheLoader =
-        new BlockletDeleteDeltaCacheLoader(scannedResult.getBlockletId(), blocksChunkHolder
-            .getDataBlock(), blockExecutionInfo.getAbsoluteTableIdentifier());
+        new BlockletDeleteDeltaCacheLoader(scannedResult.getBlockletId(),
+            blocksChunkHolder.getDataBlock(), blockExecutionInfo.getAbsoluteTableIdentifier());
     deleteCacheLoader.loadDeleteDeltaFileDataToCache();
     scannedResult
         .setBlockletDeleteDeltaCache(blocksChunkHolder.getDataBlock().getDeleteDeltaDataCache());

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/CompressedDataMeasureWrapperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/CompressedDataMeasureWrapperTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/CompressedDataMeasureWrapperTest.java
index 2bd99eb..0c3cb84 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/CompressedDataMeasureWrapperTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/CompressedDataMeasureWrapperTest.java
@@ -33,7 +33,7 @@ public class CompressedDataMeasureWrapperTest {
   private static CarbonReadDataHolder[] carbonReadDataHolders;
 
   @BeforeClass public static void setUp() {
-    carbonReadDataHolder = new CarbonReadDataHolder();
+    carbonReadDataHolder = new CarbonReadDataHolder(null);
     carbonReadDataHolders = new CarbonReadDataHolder[] { carbonReadDataHolder };
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
index dca9e08..0266e83 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
@@ -19,62 +19,100 @@
 
 package org.apache.carbondata.core.carbon.datastore.chunk.impl;
 
-import org.apache.carbondata.core.carbon.datastore.chunk.DimensionChunkAttributes;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.carbondata.core.keygenerator.KeyGenException;
+import org.apache.carbondata.core.keygenerator.KeyGenerator;
 import org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator;
+import org.apache.carbondata.core.util.CarbonUtil;
 import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
-
+import org.apache.carbondata.scan.executor.util.QueryUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.util.Arrays;
-
-import static junit.framework.TestCase.assertEquals;
-
 public class ColumnGroupDimensionDataChunkTest {
 
   static ColumnGroupDimensionDataChunk columnGroupDimensionDataChunk;
-  static byte[] data;
+  static KeyGenerator keyGenerator;
 
   @BeforeClass public static void setup() {
-    data = "dummy string".getBytes();
-    DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
-    dimensionChunkAttributes.setEachRowSize(4);
-
-    int invertedIndex[] = { 1, 3, 5, 7, 8 };
-    dimensionChunkAttributes.setInvertedIndexes(invertedIndex);
+    int[] bitLength = CarbonUtil.getDimensionBitLength(new int[] { 10, 10, 10 }, new int[] { 3 });
+    // create a key generator
+    keyGenerator = new MultiDimKeyVarLengthGenerator(bitLength);
+    byte[] data = new byte[keyGenerator.getKeySizeInBytes() * 3];
+    int position = 0;
+    for (int i = 1; i <= 3; i++) {
+      try {
+        System.arraycopy(keyGenerator.generateKey(new int[] { i, i, i }), 0, data, position,
+            keyGenerator.getKeySizeInBytes());
+      } catch (KeyGenException e) {
+        assertTrue(false);
+      }
+      position += keyGenerator.getKeySizeInBytes();
+    }
     columnGroupDimensionDataChunk =
-        new ColumnGroupDimensionDataChunk(data, dimensionChunkAttributes);
+        new ColumnGroupDimensionDataChunk(data, keyGenerator.getKeySizeInBytes(), 3);
   }
 
   @Test public void fillChunkDataTest() {
-    KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
-    int[] maskByteRanges = { 1, 2, 4, 6 };
-    keyStructureInfo.setMaskByteRanges(maskByteRanges);
-    keyStructureInfo.setMaxKey("1234567".getBytes());
-
-    int res = columnGroupDimensionDataChunk.fillChunkData(data, 2, 1, keyStructureInfo);
-    int expectedResult = 4;
-    assertEquals(res, expectedResult);
+    List<Integer> ordinals = new ArrayList<Integer>();
+    ordinals.add(1);
+    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
+    byte[] buffer = new byte[1];
+    columnGroupDimensionDataChunk.fillChunkData(buffer, 0, 1, keyStructureInfo);
+    assertEquals(buffer[0], 2);
   }
 
   @Test public void getChunkDataTest() {
-    byte expected[] = { 121, 32, 115, 116 };
+    byte[] b = { 34, 2 };
     byte res[] = columnGroupDimensionDataChunk.getChunkData(1);
-    assert (Arrays.equals(res, expected));
+    assert (Arrays.equals(res, b));
   }
 
   @Test public void fillConvertedChunkDataTest() {
-    int[] row = { 1, 2, 4, 6 };
-    int[] lens = { 3, 5, 7, 9 };
-    int[] mdkeyQueryDimensionOrdinal = { 0, 1, 2, 3 };
-
-    KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
-    keyStructureInfo.setKeyGenerator(new MultiDimKeyVarLengthGenerator(lens));
-    keyStructureInfo.setMdkeyQueryDimensionOrdinal(mdkeyQueryDimensionOrdinal);
+    int[] row = new int[3];
+    int[] expected = { 0, 0, 3 };
+    List<Integer> ordinals = new ArrayList<Integer>();
+    ordinals.add(2);
+    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
+    keyStructureInfo.setMdkeyQueryDimensionOrdinal(new int[] { 2 });
+    int res = columnGroupDimensionDataChunk.fillConvertedChunkData(2, 2, row, keyStructureInfo);
+    assert (Arrays.equals(row, expected));
+  }
 
-    int res = columnGroupDimensionDataChunk.fillConvertedChunkData(0, 0, row, keyStructureInfo);
-    int expectedresult = 4;
-    assertEquals(res, expectedresult);
+  /**
+   * Below method will be used to get the key structure info for the query
+   *
+   * @param queryModel   query model
+   * @param keyGenerator
+   * @return key structure info
+   */
+  private KeyStructureInfo getKeyStructureInfo(List<Integer> ordinals, KeyGenerator keyGenerator) {
+    // getting the masked byte range for dictionary column
+    int[] maskByteRanges = QueryUtil.getMaskedByteRangeBasedOrdinal(ordinals, keyGenerator);
+
+    // getting the masked bytes for query dimension dictionary column
+    int[] maskedBytes = QueryUtil.getMaskedByte(keyGenerator.getKeySizeInBytes(), maskByteRanges);
+
+    // max key for the dictionary dimension present in the query
+    byte[] maxKey = null;
+    try {
+      // getting the max key which will be used to masked and get the
+      // masked key
+      maxKey = QueryUtil.getMaxKeyBasedOnOrinal(ordinals, keyGenerator);
+    } catch (KeyGenException e) {
+    }
+
+    KeyStructureInfo restructureInfos = new KeyStructureInfo();
+    restructureInfos.setKeyGenerator(keyGenerator);
+    restructureInfos.setMaskByteRanges(maskByteRanges);
+    restructureInfos.setMaxKey(maxKey);
+    return restructureInfos;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
index 0b24685..c1dd83e 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
@@ -19,35 +19,28 @@
 
 package org.apache.carbondata.core.carbon.datastore.chunk.impl;
 
-import org.apache.carbondata.core.carbon.datastore.chunk.DimensionChunkAttributes;
-import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
 
+import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.util.Arrays;
-
-import static junit.framework.TestCase.assertEquals;
 
 public class FixedLengthDimensionDataChunkTest {
 
   static FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk;
-  static DimensionChunkAttributes dimensionChunkAttributes;
   static byte[] data;
 
   @BeforeClass public static void setup() {
     data = "dummy string".getBytes();
-    dimensionChunkAttributes = new DimensionChunkAttributes();
-    dimensionChunkAttributes.setEachRowSize(4);
 
     int invertedIndex[] = { 1, 3, 5, 7, 8 };
-    dimensionChunkAttributes.setInvertedIndexes(invertedIndex);
 
     int invertedIndexReverse[] = { 1, 0, 5, 7, 8 };
-    dimensionChunkAttributes.setInvertedIndexesReverse(invertedIndexReverse);
-
     fixedLengthDimensionDataChunk =
-        new FixedLengthDimensionDataChunk(data, dimensionChunkAttributes);
+        new FixedLengthDimensionDataChunk(data, invertedIndex, invertedIndexReverse, 5, 4);
   }
 
   @Test public void fillChunkDataTest() {

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
index 5a043b0..2815b93 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
@@ -19,137 +19,116 @@
 
 package org.apache.carbondata.core.carbon.datastore.chunk.reader.dimension;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import mockit.Mock;
-import mockit.MockUp;
-import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
-import org.apache.carbondata.core.carbon.datastore.chunk.reader.dimension
-    .v1.CompressedDimensionChunkFileBasedReaderV1;
-import org.apache.carbondata.core.carbon.metadata.blocklet.BlockletInfo;
-import org.apache.carbondata.core.carbon.metadata.blocklet.datachunk.DataChunk;
-import org.apache.carbondata.core.carbon.metadata.encoder.Encoding;
-import org.apache.carbondata.core.datastorage.store.FileHolder;
-import org.apache.carbondata.core.datastorage.store.columnar.UnBlockIndexer;
-import org.apache.carbondata.core.datastorage.store.compression.SnappyCompressor;
-import org.apache.carbondata.core.keygenerator.mdkey.NumberCompressor;
-import org.apache.carbondata.core.util.CarbonUtil;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertEquals;
 
 public class CompressedDimensionChunkFileBasedReaderTest {
 
-  static CompressedDimensionChunkFileBasedReaderV1 compressedDimensionChunkFileBasedReader;
-  static List<DataChunk> dataChunkList;
-
-  @BeforeClass public static void setup() {
-    int eachColumnBlockSize[] = { 1, 2, 4, 5 };
-    dataChunkList = new ArrayList<>();
-
-    DataChunk dataChunk = new DataChunk();
-    dataChunkList.add(dataChunk);
-    BlockletInfo info = new BlockletInfo();
-    info.setDimensionColumnChunk(dataChunkList);
-    compressedDimensionChunkFileBasedReader =
-        new CompressedDimensionChunkFileBasedReaderV1(info, eachColumnBlockSize, "filePath");
-  }
-
-  @Test public void readDimensionChunksTest() throws IOException {
-    FileHolder fileHolder = new MockUp<FileHolder>() {
-      @Mock public byte[] readByteArray(String filePath, long offset, int length) {
-        byte mockedValue[] = { 1, 5, 4, 8, 7 };
-        return mockedValue;
-      }
-    }.getMockInstance();
-
-    new MockUp<CarbonUtil>() {
-      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
-        return true;
-      }
-
-      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
-          NumberCompressor numberCompressor) {
-        int mockedValue[] = { 1, 1 };
-        return mockedValue;
-      }
-    };
-
-    new MockUp<SnappyCompressor>() {
-      @Mock public byte[] unCompressByte(byte[] compInput) {
-        byte mockedValue[] = { 1 };
-        return mockedValue;
-      }
-    };
-
-    new MockUp<UnBlockIndexer>() {
-      @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
-        byte mockedValue[] = { 1, 5, 4, 8, 7 };
-        return mockedValue;
-      }
-    };
-
-    int[][] blockIndexes = {{0,0}};
-    DimensionColumnDataChunk dimensionColumnDataChunk[] =
-        compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
-    byte expectedResult[] = { 1 };
-    assertEquals(dimensionColumnDataChunk[0].getAttributes().getColumnValueSize(), 1);
-    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
-      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
-    }
-  }
-
-  @Test public void readDimensionChunksTestForIfStatement() throws IOException {
-    FileHolder fileHolder = new MockUp<FileHolder>() {
-      @Mock public byte[] readByteArray(String filePath, long offset, int length) {
-        byte mockedValue[] = { 1, 5, 4, 8, 7 };
-        return mockedValue;
-      }
-    }.getMockInstance();
-
-    new MockUp<CarbonUtil>() {
-      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
-        return true;
-      }
-
-      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
-          NumberCompressor numberCompressor) {
-        int mockedValue[] = { 1, 1 };
-        return mockedValue;
-      }
-    };
-
-    new MockUp<SnappyCompressor>() {
-      @Mock public byte[] unCompressByte(byte[] compInput) {
-        byte mockedValue[] = { 1 };
-        return mockedValue;
-      }
-    };
-
-    new MockUp<UnBlockIndexer>() {
-      @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
-        byte mockedValue[] = { 1, 5, 4, 8, 7 };
-        return mockedValue;
-      }
-    };
-
-    new MockUp<DataChunk>() {
-      @Mock public boolean isRowMajor() {
-        return true;
-      }
-    };
-    int[][] blockIndexes = {{0,0}};
-    DimensionColumnDataChunk dimensionColumnDataChunk[] =
-        compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
-
-    byte expectedResult[] = { 1 };
-    assertEquals(dimensionColumnDataChunk[0].getAttributes().getColumnValueSize(), 1);
-
-    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
-      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
-    }
-  }
+//  static CompressedDimensionChunkFileBasedReaderV1 compressedDimensionChunkFileBasedReader;
+//  static List<DataChunk> dataChunkList;
+//
+//  @BeforeClass public static void setup() {
+//    int eachColumnBlockSize[] = { 1, 2, 4, 5 };
+//    dataChunkList = new ArrayList<>();
+//
+//    DataChunk dataChunk = new DataChunk();
+//    dataChunkList.add(dataChunk);
+//    BlockletInfo info = new BlockletInfo();
+//    info.setDimensionColumnChunk(dataChunkList);
+//    compressedDimensionChunkFileBasedReader =
+//        new CompressedDimensionChunkFileBasedReaderV1(info, eachColumnBlockSize, "filePath");
+//  }
+//
+//  @Test public void readDimensionChunksTest() {
+//    FileHolder fileHolder = new MockUp<FileHolder>() {
+//      @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    }.getMockInstance();
+//
+//    new MockUp<CarbonUtil>() {
+//      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
+//        return true;
+//      }
+//
+//      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
+//          NumberCompressor numberCompressor,int offset) {
+//        int mockedValue[] = { 1, 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<SnappyCompressor>() {
+//      @Mock public byte[] unCompressByte(byte[] compInput) {
+//        byte mockedValue[] = { 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<UnBlockIndexer>() {
+//      @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    int[][] blockIndexes = {{0,0}};
+//    DimensionColumnDataChunk dimensionColumnDataChunk[] =
+//        compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
+//    byte expectedResult[] = { 1 };
+//    assertEquals(dimensionColumnDataChunk[0].getColumnValueSize(), 1);
+//    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
+//      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
+//    }
+//  }
+//
+//  @Test public void readDimensionChunksTestForIfStatement() {
+//    FileHolder fileHolder = new MockUp<FileHolder>() {
+//      @Mock public byte[] readByteArray(String filePath, long offset, int length) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    }.getMockInstance();
+//
+//    new MockUp<CarbonUtil>() {
+//      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding encoding) {
+//        return true;
+//      }
+//
+//      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] columnIndexData,
+//          NumberCompressor numberCompressor, int offset) {
+//        int mockedValue[] = { 1, 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<SnappyCompressor>() {
+//      @Mock public byte[] unCompressByte(byte[] compInput) {
+//        byte mockedValue[] = { 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<UnBlockIndexer>() {
+//      @Mock public byte[] uncompressData(byte[] data, int[] index, int keyLen) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<DataChunk>() {
+//      @Mock public boolean isRowMajor() {
+//        return true;
+//      }
+//    };
+//    int[][] blockIndexes = {{0,0}};
+//    DimensionColumnDataChunk dimensionColumnDataChunk[] =
+//        compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, blockIndexes);
+//
+//    byte expectedResult[] = { 1 };
+//    assertEquals(dimensionColumnDataChunk[0].getColumnValueSize(), 1);
+//
+//    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; i++) {
+//      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], expectedResult[i]);
+//    }
+//  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
index 0080690..1e88671 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
@@ -32,8 +32,9 @@ public class CompressedMeasureChunkFileBasedReaderTest {
   static WriterCompressModel writerCompressModel;
   @BeforeClass public static void setup() {
     List<DataChunk> dataChunkList = new ArrayList<>();
-    dataChunkList.add(new DataChunk());
-
+    DataChunk dataChunk = new DataChunk();
+    dataChunkList.add(dataChunk);
+    dataChunk.setDataPageLength(10);
     writerCompressModel = new WriterCompressModel();
     Object maxValue[] = new Object[]{new Long[]{8L, 0L}};
     Object minValue[] = new Object[]{new Long[]{1L,0L}};

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
index 1c5749b..ead1d54 100644
--- a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
@@ -28,7 +28,6 @@ import static junit.framework.TestCase.assertNotNull;
 import static org.pentaho.di.core.util.Assert.assertNull;
 
 public class DriverQueryStatisticsRecorderImplTest {
-
   private static DriverQueryStatisticsRecorderImpl driverQueryStatisticsRecorderImpl = null;
   private static QueryStatistic queryStasticsWithSQL_PARSE = null;
   private static QueryStatistic queryStasticsWithLoadMetaData = null;

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/keygenerator/mdkey/NumberCompressorUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/keygenerator/mdkey/NumberCompressorUnitTest.java b/core/src/test/java/org/apache/carbondata/core/keygenerator/mdkey/NumberCompressorUnitTest.java
index e6cd599..3dd3310 100644
--- a/core/src/test/java/org/apache/carbondata/core/keygenerator/mdkey/NumberCompressorUnitTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/keygenerator/mdkey/NumberCompressorUnitTest.java
@@ -19,13 +19,12 @@
 
 package org.apache.carbondata.core.keygenerator.mdkey;
 
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 
+import org.junit.Test;
+
 public class NumberCompressorUnitTest {
 
   private NumberCompressor numberCompressor;
@@ -75,7 +74,7 @@ public class NumberCompressorUnitTest {
     numberCompressor = new NumberCompressor(cardinality);
     int[] expected_result = new int[] { 6, 4, 0, 2 };
     byte[] keys = new byte[] { 100, 2 };
-    int[] result = numberCompressor.unCompress(keys);
+    int[] result = numberCompressor.unCompress(keys, 0, keys.length);
     assertThat(result, is(equalTo(expected_result)));
   }
 
@@ -85,7 +84,7 @@ public class NumberCompressorUnitTest {
     int[] expected_result =
         new int[] { 0, 10, 0, 2, 0, 10, 0, 2, 0, 10, 0, 2, 0, 10, 0, 2, 0, 10, 0, 2 };
     byte[] keys = new byte[] { 10, 2, 10, 2, 10, 2, 10, 2, 10, 2 };
-    int[] result = numberCompressor.unCompress(keys);
+    int[] result = numberCompressor.unCompress(keys, 0, keys.length);
     System.out.println(result);
     assertThat(result, is(equalTo(expected_result)));
   }
@@ -95,7 +94,7 @@ public class NumberCompressorUnitTest {
     numberCompressor = new NumberCompressor(cardinality);
     int[] expected_result = new int[] { 16, 4, 10, 1, 2, 64, 32, 80, 8, 20, 11 };
     byte[] keys = new byte[] { 100, 2, 10, 2, 10, 2, 10, 2, 10, 11 };
-    int[] result = numberCompressor.unCompress(keys);
+    int[] result = numberCompressor.unCompress(keys, 0, keys.length);
     assertThat(result, is(equalTo(expected_result)));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java b/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java
index 78d3185..412f1f3 100644
--- a/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/util/CarbonUtilTest.java
@@ -23,7 +23,6 @@ import mockit.MockUp;
 
 import org.apache.carbondata.core.carbon.ColumnarFormatVersion;
 import org.apache.carbondata.core.carbon.datastore.block.TableBlockInfo;
-import org.apache.carbondata.core.carbon.datastore.chunk.DimensionChunkAttributes;
 import org.apache.carbondata.core.carbon.datastore.chunk.impl.FixedLengthDimensionDataChunk;
 import org.apache.carbondata.core.carbon.metadata.blocklet.DataFileFooter;
 import org.apache.carbondata.core.carbon.metadata.blocklet.datachunk.DataChunk;
@@ -38,6 +37,7 @@ import org.apache.carbondata.core.datastorage.store.filesystem.LocalCarbonFile;
 import org.apache.carbondata.core.datastorage.store.impl.FileFactory;
 import org.apache.carbondata.core.metadata.ValueEncoderMeta;
 import org.apache.carbondata.scan.model.QueryDimension;
+
 import org.apache.hadoop.security.UserGroupInformation;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -57,12 +57,9 @@ import static org.hamcrest.CoreMatchers.is;
 
 public class CarbonUtilTest {
 
-  private static DimensionChunkAttributes chunkAttribute;
-
   @BeforeClass public static void setUp() throws Exception {
     new File("../core/src/test/resources/testFile.txt").createNewFile();
     new File("../core/src/test/resources/testDatabase").mkdirs();
-    chunkAttribute = new DimensionChunkAttributes();
   }
 
   @Test public void testGetBitLengthForDimensionGiveProperValue() {
@@ -262,51 +259,30 @@ public class CarbonUtilTest {
   }
 
   @Test public void testToGetNextLesserValue() {
-    byte[] dataChunks = { new Byte("5"), new Byte("15"), new Byte("30"), new Byte("50") };
-    byte[] compareValues = { new Byte("5"), new Byte("15"), new Byte("30") };
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock
-      public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return -1;
-      }
-    };
+    byte[] dataChunks = { 5, 6, 7, 8, 9 };
+    byte[] compareValues = { 7 };
     FixedLengthDimensionDataChunk fixedLengthDataChunk =
-        new FixedLengthDimensionDataChunk(dataChunks, chunkAttribute);
-    int result = CarbonUtil.nextLesserValueToTarget(1, fixedLengthDataChunk, compareValues);
-    assertEquals(result, 0);
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 5, 1);
+    int result = CarbonUtil.nextLesserValueToTarget(2, fixedLengthDataChunk, compareValues);
+    assertEquals(result, 1);
   }
 
   @Test public void testToGetNextLesserValueToTarget() {
-    byte[] dataChunks = { new Byte("5"), new Byte("15"), new Byte("30"), new Byte("50") };
-    byte[] compareValues = { new Byte("5"), new Byte("15"), new Byte("30") };
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock
-      public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 1;
-      }
-    };
+    byte[] dataChunks = { 7, 7, 7, 8, 9 };
+    byte[] compareValues = { 7 };
     FixedLengthDimensionDataChunk fixedLengthDataChunk =
-        new FixedLengthDimensionDataChunk(dataChunks, chunkAttribute);
-    int result = CarbonUtil.nextLesserValueToTarget(1, fixedLengthDataChunk, compareValues);
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 5, 1);
+    int result = CarbonUtil.nextLesserValueToTarget(2, fixedLengthDataChunk, compareValues);
     assertEquals(result, -1);
   }
 
   @Test public void testToGetnextGreaterValue() {
-    byte[] dataChunks = { new Byte("5"), new Byte("15"), new Byte("30"), new Byte("50") };
-    byte[] compareValues = { new Byte("5"), new Byte("15"), new Byte("30") };
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock
-      public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 1;
-      }
-    };
+    byte[] dataChunks = { 5, 6, 7, 8, 9 };
+    byte[] compareValues = { 7 };
     FixedLengthDimensionDataChunk fixedLengthDataChunk =
-        new FixedLengthDimensionDataChunk(dataChunks, chunkAttribute);
-    int result = CarbonUtil.nextGreaterValueToTarget(1, fixedLengthDataChunk, compareValues, 4);
-    assertEquals(result, 2);
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 5, 1);
+    int result = CarbonUtil.nextGreaterValueToTarget(2, fixedLengthDataChunk, compareValues, 5);
+    assertEquals(result, 3);
   }
 
   @Test public void testToConvertToIntegerList() {
@@ -318,19 +294,12 @@ public class CarbonUtilTest {
   }
 
   @Test public void testToGetnextGreaterValueToTarget() {
-    byte[] dataChunks = { new Byte("5"), new Byte("15"), new Byte("30"), new Byte("50") };
-    byte[] compareValues = { new Byte("5"), new Byte("15"), new Byte("30") };
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock
-      public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 0;
-      }
-    };
+    byte[] dataChunks = { 5, 6, 7, 7, 7 };
+    byte[] compareValues = { 7 };
     FixedLengthDimensionDataChunk fixedLengthDataChunk =
-        new FixedLengthDimensionDataChunk(dataChunks, chunkAttribute);
-    int result = CarbonUtil.nextGreaterValueToTarget(1, fixedLengthDataChunk, compareValues, 4);
-    assertEquals(result, 4);
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 5, 1);
+    int result = CarbonUtil.nextGreaterValueToTarget(2, fixedLengthDataChunk, compareValues, 5);
+    assertEquals(result, 5);
   }
 
   @Test public void testToWriteLevelCardinalityFile() throws KettleException {
@@ -560,15 +529,17 @@ public class CarbonUtilTest {
         return fileFooter;
       }
     };
-    TableBlockInfo info = new TableBlockInfo("file:/", 1, "0", new String[0], 1, ColumnarFormatVersion.V1);
-    
+    TableBlockInfo info =
+        new TableBlockInfo("file:/", 1, "0", new String[0], 1, ColumnarFormatVersion.V1);
+
     assertEquals(CarbonUtil.readMetadatFile(info).getVersionId().number(), 1);
   }
 
   @Test(expected = IOException.class)
   public void testToReadMetadatFileWithException()
       throws Exception {
-	TableBlockInfo info = new TableBlockInfo("file:/", 1, "0", new String[0], 1, ColumnarFormatVersion.V1);
+    TableBlockInfo info =
+        new TableBlockInfo("file:/", 1, "0", new String[0], 1, ColumnarFormatVersion.V1);
     CarbonUtil.readMetadatFile(info);
   }
 
@@ -747,72 +718,53 @@ public class CarbonUtilTest {
     column3Schema.setColumnName("Column3");
     column3Schema.setColumnar(true);
     column3Schema.setEncodingList(Arrays.asList(Encoding.DELTA, Encoding.INVERTED_INDEX));
-    CarbonDimension carbonDimension = new CarbonDimension(column1Schema,1,1,1,1);
-    CarbonDimension carbonDimension2 = new CarbonDimension(column2Schema,2,2,2,2);
-    CarbonDimension carbonDimension3 = new CarbonDimension(column3Schema,3,3,3,3);
-    List<CarbonDimension> carbonDimensions = Arrays.asList(carbonDimension, carbonDimension2, carbonDimension3);
+    CarbonDimension carbonDimension = new CarbonDimension(column1Schema, 1, 1, 1, 1);
+    CarbonDimension carbonDimension2 = new CarbonDimension(column2Schema, 2, 2, 2, 2);
+    CarbonDimension carbonDimension3 = new CarbonDimension(column3Schema, 3, 3, 3, 3);
+    List<CarbonDimension> carbonDimensions =
+        Arrays.asList(carbonDimension, carbonDimension2, carbonDimension3);
     boolean[] result = CarbonUtil.identifyDimensionType(carbonDimensions);
-    assertThat(result, is(equalTo(new boolean[]{true, true, false})));
+    assertThat(result, is(equalTo(new boolean[] { true, true, false })));
   }
 
   @Test public void testToGetFirstIndexUsingBinarySearchWithCompareTo1() {
-    DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 1;
-      }
-    };
-    byte[] dataChunks = {10,20,30};
-    byte[] compareValue = {1,20,30};
-    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk = new FixedLengthDimensionDataChunk(dataChunks, dimensionChunkAttributes);
-    int result = CarbonUtil.getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk,1, 3, compareValue, false);
+    byte[] dataChunks = { 10, 20, 30, 40, 50, 60 };
+    byte[] compareValue = { 5 };
+    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk =
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 6, 1);
+    int result = CarbonUtil
+        .getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk, 1, 3, compareValue, false);
     assertEquals(-2, result);
   }
 
   @Test public void testToGetFirstIndexUsingBinarySearchWithCompareToLessThan0() {
-    DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return -1;
-      }
-    };
-    byte[] dataChunks = {10,20,30};
-    byte[] compareValue = {1,20,30};
-    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk = new FixedLengthDimensionDataChunk(dataChunks, dimensionChunkAttributes);
-    int result = CarbonUtil.getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk,1, 3, compareValue, false);
-    assertEquals(-5, result);
+    byte[] dataChunks = { 10, 20, 30, 40, 50, 60 };
+    byte[] compareValue = { 30 };
+    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk =
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 6, 1);
+    int result = CarbonUtil
+        .getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk, 1, 3, compareValue, false);
+    assertEquals(2, result);
   }
 
   @Test public void testToGetFirstIndexUsingBinarySearchWithCompareTo0() {
-    DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 0;
-      }
-    };
-    byte[] dataChunks = {10,20,30};
-    byte[] compareValue = {1,20,30};
-    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk = new FixedLengthDimensionDataChunk(dataChunks, dimensionChunkAttributes);
-    int result = CarbonUtil.getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk,1, 3, compareValue, false);
+    byte[] dataChunks = { 10, 10, 10, 40, 50, 60 };
+    byte[] compareValue = { 10 };
+    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk =
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 6, 1);
+    int result = CarbonUtil
+        .getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk, 1, 3, compareValue, false);
     assertEquals(0, result);
   }
 
   @Test public void testToGetFirstIndexUsingBinarySearchWithMatchUpLimitTrue() {
-    DimensionChunkAttributes dimensionChunkAttributes = new DimensionChunkAttributes();
-    new MockUp<ByteUtil.UnsafeComparer>() {
-      @SuppressWarnings("unused") @Mock public int compareTo(byte[] buffer1, int offset1, int length1, byte[] buffer2, int offset2,
-          int length2) {
-        return 0;
-      }
-    };
-    byte[] dataChunks = {10,20,30};
-    byte[] compareValue = {1,20,30};
-    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk = new FixedLengthDimensionDataChunk(dataChunks, dimensionChunkAttributes);
-    int result = CarbonUtil.getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk,1, 3, compareValue, true);
-    assertEquals(3, result);
+    byte[] dataChunks = { 10, 10, 10, 40, 50, 60 };
+    byte[] compareValue = { 10 };
+    FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk =
+        new FixedLengthDimensionDataChunk(dataChunks, null, null, 6, 1);
+    int result = CarbonUtil
+        .getFirstIndexUsingBinarySearch(fixedLengthDimensionDataChunk, 1, 3, compareValue, true);
+    assertEquals(2, result);
   }
 
   @AfterClass public static void testcleanUp() {

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/8d9babe3/core/src/test/java/org/apache/carbondata/core/util/ValueCompressionUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/util/ValueCompressionUtilTest.java b/core/src/test/java/org/apache/carbondata/core/util/ValueCompressionUtilTest.java
index 21cf2d6..bfcbdb1 100644
--- a/core/src/test/java/org/apache/carbondata/core/util/ValueCompressionUtilTest.java
+++ b/core/src/test/java/org/apache/carbondata/core/util/ValueCompressionUtilTest.java
@@ -18,20 +18,21 @@
  */
 package org.apache.carbondata.core.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.nio.ByteBuffer;
+
 import org.apache.carbondata.core.datastorage.store.compression.MeasureMetaDataModel;
-import org.apache.carbondata.core.datastorage.store.compression.WriterCompressModel;
 import org.apache.carbondata.core.datastorage.store.compression.ValueCompressonHolder;
+import org.apache.carbondata.core.datastorage.store.compression.WriterCompressModel;
 import org.apache.carbondata.core.datastorage.store.compression.decimal.*;
 import org.apache.carbondata.core.datastorage.store.compression.nondecimal.*;
 import org.apache.carbondata.core.datastorage.store.compression.none.*;
-
+import org.apache.carbondata.core.util.ValueCompressionUtil.DataType;
 
 import org.junit.Test;
 
-import java.nio.ByteBuffer;
-
-import static junit.framework.TestCase.*;
-import static org.apache.carbondata.core.util.ValueCompressionUtil.DataType;
 
 public class ValueCompressionUtilTest {
 
@@ -96,7 +97,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_FLOAT, 22.345, 3);
     float[] expectedResult = { 2.224f, 1.122f, 0f };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+    	assertTrue(result[i]-expectedResult[i]==0);
     }
   }
 
@@ -107,7 +108,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_DOUBLE, 102.345, 3);
     double[] expectedResult = { 82.224, 81.122, 80.0 };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertTrue(result[i]-expectedResult[i]==0);
     }
   }
 
@@ -173,7 +174,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_FLOAT, 22, 3);
     float[] expectedResult = { 20.121f, 21.223f, 22.345f };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],3);
     }
   }
 
@@ -184,7 +185,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_DOUBLE, 22, 3);
     double[] expectedResult = { 20.121, 21.223, 22.345 };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],3);
     }
   }
 
@@ -195,7 +196,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_FLOAT, 22, 1);
     float[] expectedResult = { 201f, 212f, 223f };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],0);
     }
   }
 
@@ -250,7 +251,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_DOUBLE, 22, 1);
     double[] expectedResult = { 201, 212, 223 };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],0);
     }
   }
 
@@ -283,7 +284,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_DOUBLE, 22, 1);
     double[] expectedResult = { 20, 10, 0 };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],0);
     }
   }
 
@@ -316,7 +317,7 @@ public class ValueCompressionUtilTest {
             DataType.DATA_FLOAT, 22, 1);
     float[] expectedResult = { 20f, 10f, 0f };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(result[i], expectedResult[i]);
+      assertEquals(result[i], expectedResult[i],0);
     }
   }
 
@@ -344,12 +345,6 @@ public class ValueCompressionUtilTest {
     assertEquals(result.getClass(), UnCompressNoneShort.class);
   }
 
-  @Test public void testToUnCompressNoneForFloat() {
-    ValueCompressonHolder.UnCompressValue result =
-        ValueCompressionUtil.getUnCompressNone(DataType.DATA_FLOAT, DataType.DATA_FLOAT);
-    assertEquals(result.getClass(), UnCompressNoneFloat.class);
-  }
-
   @Test public void testToUnCompressNoneForInt() {
     ValueCompressonHolder.UnCompressValue result =
         ValueCompressionUtil.getUnCompressNone(DataType.DATA_INT, DataType.DATA_FLOAT);
@@ -374,12 +369,6 @@ public class ValueCompressionUtilTest {
     assertEquals(result.getClass(), UnCompressMaxMinInt.class);
   }
 
-  @Test public void testToUnCompressMaxMinForFloat() {
-    ValueCompressonHolder.UnCompressValue result =
-        ValueCompressionUtil.getUnCompressDecimalMaxMin(DataType.DATA_FLOAT, null);
-    assertEquals(result.getClass(), UnCompressMaxMinFloat.class);
-  }
-
   @Test public void testToUnCompressMaxMinForLong() {
     ValueCompressonHolder.UnCompressValue result =
         ValueCompressionUtil.getUnCompressDecimalMaxMin(DataType.DATA_LONG, null);
@@ -410,12 +399,6 @@ public class ValueCompressionUtilTest {
     assertEquals(result.getClass(), UnCompressNonDecimalInt.class);
   }
 
-  @Test public void testToUnCompressNonDecimalForFloat() {
-    ValueCompressonHolder.UnCompressValue result =
-        ValueCompressionUtil.getUnCompressNonDecimal(DataType.DATA_FLOAT);
-    assertEquals(result.getClass(), UnCompressNonDecimalFloat.class);
-  }
-
   @Test public void testToUnCompressNonDecimalForLong() {
     ValueCompressonHolder.UnCompressValue result =
         ValueCompressionUtil.getUnCompressNonDecimal(DataType.DATA_LONG);
@@ -446,12 +429,6 @@ public class ValueCompressionUtilTest {
     assertEquals(result.getClass(), UnCompressNonDecimalMaxMinInt.class);
   }
 
-  @Test public void testToUnCompressNonDecimalMaxMinForFloat() {
-    ValueCompressonHolder.UnCompressValue result =
-        ValueCompressionUtil.getUnCompressNonDecimalMaxMin(DataType.DATA_FLOAT);
-    assertEquals(result.getClass(), UnCompressNonDecimalMaxMinFloat.class);
-  }
-
   @Test public void testToUnCompressNonDecimalMaxMinForLong() {
     ValueCompressonHolder.UnCompressValue result =
         ValueCompressionUtil.getUnCompressNonDecimalMaxMin(DataType.DATA_LONG);
@@ -504,7 +481,7 @@ public class ValueCompressionUtilTest {
     float[] result = ValueCompressionUtil.convertToFloatArray(byteBuffer, 4);
     float[] expectedResult = { 123.23f };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(expectedResult[i], result[i]);
+      assertEquals(expectedResult[i], result[i],2);
     }
   }
 
@@ -561,7 +538,7 @@ public class ValueCompressionUtilTest {
     double[] result = ValueCompressionUtil.convertToDoubleArray(byteBuffer, 8);
     double[] expectedResult = { 3216.54987 };
     for (int i = 0; i < result.length; i++) {
-      assertEquals(expectedResult[i], result[i]);
+      assertEquals(expectedResult[i], result[i],5);
     }
   }
 


Mime
View raw message