carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [06/10] carbondata git commit: [CARBONDATA-1539] Change data type from enum to class
Date Fri, 13 Oct 2017 09:26:55 GMT
http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java
index e8488f9..cfe2cc8 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java
@@ -54,6 +54,7 @@ import org.apache.carbondata.core.keygenerator.KeyGenException;
 import org.apache.carbondata.core.keygenerator.KeyGenerator;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.CarbonTable;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
@@ -329,7 +330,7 @@ public final class FilterUtil {
     if (expression.getFilterExpressionType() == ExpressionType.LITERAL
         && expression instanceof LiteralExpression) {
       DataType dataType = ((LiteralExpression) expression).getLiteralExpDataType();
-      if (!(dataType == DataType.TIMESTAMP || dataType == DataType.DATE)) {
+      if (!(dataType == DataTypes.TIMESTAMP || dataType == DataTypes.DATE)) {
         return true;
       }
     }
@@ -420,7 +421,7 @@ public final class FilterUtil {
       for (int i = 0; i < length; i++) {
         result = evaluateResultListFinal.get(i);
         if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(result)) {
-          if (dataType == DataType.STRING) {
+          if (dataType == DataTypes.STRING) {
             filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY);
           } else {
             filterValuesList.add(CarbonCommonConstants.EMPTY_BYTE_ARRAY);
@@ -1295,39 +1296,33 @@ public final class FilterUtil {
   public static int compareFilterKeyBasedOnDataType(String dictionaryVal, String memberVal,
       DataType dataType) {
     try {
-      switch (dataType) {
-        case SHORT:
-          return Short.compare((Short.parseShort(dictionaryVal)), (Short.parseShort(memberVal)));
-        case INT:
-          return Integer.compare((Integer.parseInt(dictionaryVal)), (Integer.parseInt(memberVal)));
-        case DOUBLE:
-          return Double
-              .compare((Double.parseDouble(dictionaryVal)), (Double.parseDouble(memberVal)));
-        case LONG:
-          return Long.compare((Long.parseLong(dictionaryVal)), (Long.parseLong(memberVal)));
-        case BOOLEAN:
-          return Boolean
-              .compare((Boolean.parseBoolean(dictionaryVal)), (Boolean.parseBoolean(memberVal)));
-        case DATE:
-        case TIMESTAMP:
-          String format = CarbonUtil.getFormatFromProperty(dataType);
-          SimpleDateFormat parser = new SimpleDateFormat(format);
-          Date dateToStr;
-          Date dictionaryDate;
-          dateToStr = parser.parse(memberVal);
-          dictionaryDate = parser.parse(dictionaryVal);
-          return dictionaryDate.compareTo(dateToStr);
-
-        case DECIMAL:
-          java.math.BigDecimal javaDecValForDictVal = new java.math.BigDecimal(dictionaryVal);
-          java.math.BigDecimal javaDecValForMemberVal = new java.math.BigDecimal(memberVal);
-          return javaDecValForDictVal.compareTo(javaDecValForMemberVal);
-        default:
-          return -1;
+      if (dataType == DataTypes.SHORT) {
+        return Short.compare((Short.parseShort(dictionaryVal)), (Short.parseShort(memberVal)));
+      } else if (dataType == DataTypes.INT) {
+        return Integer.compare((Integer.parseInt(dictionaryVal)), (Integer.parseInt(memberVal)));
+      } else if (dataType == DataTypes.DOUBLE) {
+        return Double.compare((Double.parseDouble(dictionaryVal)), (Double.parseDouble(memberVal)));
+      } else if (dataType == DataTypes.LONG) {
+        return Long.compare((Long.parseLong(dictionaryVal)), (Long.parseLong(memberVal)));
+      } else if (dataType == DataTypes.BOOLEAN) {
+        return Boolean.compare(
+            (Boolean.parseBoolean(dictionaryVal)), (Boolean.parseBoolean(memberVal)));
+      } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+        String format = CarbonUtil.getFormatFromProperty(dataType);
+        SimpleDateFormat parser = new SimpleDateFormat(format);
+        Date dateToStr;
+        Date dictionaryDate;
+        dateToStr = parser.parse(memberVal);
+        dictionaryDate = parser.parse(dictionaryVal);
+        return dictionaryDate.compareTo(dateToStr);
+      } else if (dataType == DataTypes.DECIMAL) {
+        java.math.BigDecimal javaDecValForDictVal = new java.math.BigDecimal(dictionaryVal);
+        java.math.BigDecimal javaDecValForMemberVal = new java.math.BigDecimal(memberVal);
+        return javaDecValForDictVal.compareTo(javaDecValForMemberVal);
+      } else {
+        return -1;
       }
-    } catch (ParseException e) {
-      return -1;
-    } catch (NumberFormatException e) {
+    } catch (ParseException | NumberFormatException e) {
       return -1;
     }
   }
@@ -1422,53 +1417,47 @@ public final class FilterUtil {
   private static int compareFilterMembersBasedOnActualDataType(String filterMember1,
       String filterMember2, DataType dataType) {
     try {
-      switch (dataType) {
-        case SHORT:
-        case INT:
-        case LONG:
-        case DOUBLE:
-
-          if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
-            return 1;
-          }
-          Double d1 = Double.parseDouble(filterMember1);
-          Double d2 = Double.parseDouble(filterMember2);
-          return d1.compareTo(d2);
-        case DECIMAL:
-          if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
-            return 1;
-          }
-          java.math.BigDecimal val1 = new BigDecimal(filterMember1);
-          java.math.BigDecimal val2 = new BigDecimal(filterMember2);
-          return val1.compareTo(val2);
-        case DATE:
-        case TIMESTAMP:
-          if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
-            return 1;
-          }
-          String format = null;
-          if (dataType == DataType.DATE) {
-            format = CarbonProperties.getInstance()
-                .getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
-                    CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
-          } else {
-            format = CarbonProperties.getInstance()
-                .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
-                    CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
-          }
-          SimpleDateFormat parser = new SimpleDateFormat(format);
-          Date date1 = null;
-          Date date2 = null;
-          date1 = parser.parse(filterMember1);
-          date2 = parser.parse(filterMember2);
-          return date1.compareTo(date2);
-        case STRING:
-        default:
-          return filterMember1.compareTo(filterMember2);
+      if (dataType == DataTypes.SHORT ||
+          dataType == DataTypes.INT ||
+          dataType == DataTypes.LONG ||
+          dataType == DataTypes.DOUBLE) {
+        if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
+          return 1;
+        }
+        Double d1 = Double.parseDouble(filterMember1);
+        Double d2 = Double.parseDouble(filterMember2);
+        return d1.compareTo(d2);
+      } else if (dataType == DataTypes.DECIMAL) {
+        if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
+          return 1;
+        }
+        java.math.BigDecimal val1 = new BigDecimal(filterMember1);
+        java.math.BigDecimal val2 = new BigDecimal(filterMember2);
+        return val1.compareTo(val2);
+      } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
+        if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
+          return 1;
+        }
+        String format = null;
+        if (dataType == DataTypes.DATE) {
+          format = CarbonProperties.getInstance()
+              .getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
+                  CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
+        } else {
+          format = CarbonProperties.getInstance()
+              .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+                  CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
+        }
+        SimpleDateFormat parser = new SimpleDateFormat(format);
+        Date date1 = null;
+        Date date2 = null;
+        date1 = parser.parse(filterMember1);
+        date2 = parser.parse(filterMember2);
+        return date1.compareTo(date2);
+      } else {
+        return filterMember1.compareTo(filterMember2);
       }
-    } catch (ParseException e) {
-      return -1;
-    } catch (NumberFormatException e) {
+    } catch (ParseException | NumberFormatException e) {
       return -1;
     }
   }
@@ -1562,7 +1551,7 @@ public final class FilterUtil {
    */
   public static boolean isExpressionNeedsToResolved(Expression rightExp, boolean isIncludeFilter) {
     if (!isIncludeFilter && rightExp instanceof LiteralExpression && (
-        DataType.NULL == ((LiteralExpression) rightExp)
+        DataTypes.NULL == ((LiteralExpression) rightExp)
             .getLiteralExpDataType())) {
       return true;
     }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/ExcludeFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/ExcludeFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/ExcludeFilterExecuterImpl.java
index 841ecdc..4013578 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/ExcludeFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/ExcludeFilterExecuterImpl.java
@@ -25,6 +25,7 @@ import org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk;
 import org.apache.carbondata.core.datastore.chunk.impl.MeasureRawColumnChunk;
 import org.apache.carbondata.core.datastore.page.ColumnPage;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.filter.FilterUtil;
 import org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
 import org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo;
@@ -123,17 +124,16 @@ public class ExcludeFilterExecuterImpl implements FilterExecuter {
   }
 
   private DataType getMeasureDataType(MeasureColumnResolvedFilterInfo msrColumnEvaluatorInfo) {
-    switch (msrColumnEvaluatorInfo.getType()) {
-      case SHORT:
-        return DataType.SHORT;
-      case INT:
-        return DataType.INT;
-      case LONG:
-        return DataType.LONG;
-      case DECIMAL:
-        return DataType.DECIMAL;
-      default:
-        return DataType.DOUBLE;
+    if (msrColumnEvaluatorInfo.getType() == DataTypes.SHORT) {
+      return DataTypes.SHORT;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.INT) {
+      return DataTypes.INT;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.LONG) {
+      return DataTypes.LONG;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.DECIMAL) {
+      return DataTypes.DECIMAL;
+    } else {
+      return DataTypes.DOUBLE;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java
index 7d6fd4f..04fce4a 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java
@@ -25,6 +25,7 @@ import org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk;
 import org.apache.carbondata.core.datastore.chunk.impl.MeasureRawColumnChunk;
 import org.apache.carbondata.core.datastore.page.ColumnPage;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.filter.FilterUtil;
 import org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
 import org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo;
@@ -147,17 +148,16 @@ public class IncludeFilterExecuterImpl implements FilterExecuter {
   }
 
   private DataType getMeasureDataType(MeasureColumnResolvedFilterInfo msrColumnEvaluatorInfo) {
-    switch (msrColumnEvaluatorInfo.getType()) {
-      case SHORT:
-        return DataType.SHORT;
-      case INT:
-        return DataType.INT;
-      case LONG:
-        return DataType.LONG;
-      case DECIMAL:
-        return DataType.DECIMAL;
-      default:
-        return DataType.DOUBLE;
+    if (msrColumnEvaluatorInfo.getType() == DataTypes.SHORT) {
+      return DataTypes.SHORT;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.INT) {
+      return DataTypes.INT;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.LONG) {
+      return DataTypes.LONG;
+    } else if (msrColumnEvaluatorInfo.getType() == DataTypes.DECIMAL) {
+      return DataTypes.DECIMAL;
+    } else {
+      return DataTypes.DOUBLE;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecuterImpl.java
index acce53e..0cfa198 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecuterImpl.java
@@ -27,7 +27,7 @@ import org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.scan.expression.Expression;
@@ -564,7 +564,7 @@ public class RangeValueFilterExecuterImpl extends ValueBasedFilterExecuterImpl {
           defaultValue = ByteUtil.toBytes(key);
         }
       } else {
-        if (dimColEvaluatorInfo.getDimension().getDataType() == DataType.STRING) {
+        if (dimColEvaluatorInfo.getDimension().getDataType() == DataTypes.STRING) {
           defaultValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY;
         } else {
           defaultValue = CarbonCommonConstants.EMPTY_BYTE_ARRAY;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RestructureEvaluatorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RestructureEvaluatorImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RestructureEvaluatorImpl.java
index c570ed2..cf3c11e 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RestructureEvaluatorImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RestructureEvaluatorImpl.java
@@ -21,7 +21,7 @@ import java.nio.charset.Charset;
 import java.util.List;
 
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -54,7 +54,7 @@ public abstract class RestructureEvaluatorImpl implements FilterExecuter {
     if (!dimension.hasEncoding(Encoding.DICTIONARY)) {
       // for no dictionary cases
       // 3 cases: is NUll, is Not Null and filter on default value of newly added column
-      if (null == defaultValue && dimension.getDataType() == DataType.STRING) {
+      if (null == defaultValue && dimension.getDataType() == DataTypes.STRING) {
         // default value for case where user gives is Null condition
         defaultValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL
             .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
index 08ce565..c243368 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelFilterExecuterImpl.java
@@ -42,6 +42,7 @@ import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionary
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -143,9 +144,9 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
     this.tableIdentifier = tableIdentifier;
     this.complexDimensionInfoMap = complexDimensionInfoMap;
     this.dateDictionaryGenerator =
-        DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataType.DATE);
+        DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataTypes.DATE);
     this.timestampDictionaryGenerator =
-        DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataType.TIMESTAMP);
+        DirectDictionaryKeyGeneratorFactory.getDirectDictionaryGenerator(DataTypes.TIMESTAMP);
     initDimensionBlockIndexes();
     initMeasureBlockIndexes();
   }
@@ -287,8 +288,8 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
             getDimensionDefaultValue(dimColumnEvaluatorInfo);
         continue;
       }
-      if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.ARRAY
-          && dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.STRUCT) {
+      if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataTypes.ARRAY
+          && dimColumnEvaluatorInfo.getDimension().getDataType() != DataTypes.STRUCT) {
         if (!dimColumnEvaluatorInfo.isDimensionExistsInCurrentSilce()) {
           record[dimColumnEvaluatorInfo.getRowIndex()] =
               dimColumnEvaluatorInfo.getDimension().getDefaultValue();
@@ -311,8 +312,6 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
             record[dimColumnEvaluatorInfo.getRowIndex()] = DataTypeUtil
                 .getDataBasedOnDataTypeForNoDictionaryColumn(memberBytes,
                     dimColumnEvaluatorInfo.getDimension().getDataType());
-          } else {
-            continue;
           }
         } else {
           int dictionaryValue = readSurrogatesFromColumnBlock(blockChunkHolder, index, pageIndex,
@@ -351,21 +350,17 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
     DataType msrType;
     for (int i = 0; i < msrColEvalutorInfoList.size(); i++) {
       MeasureColumnResolvedFilterInfo msrColumnEvalutorInfo = msrColEvalutorInfoList.get(i);
-      switch (msrColumnEvalutorInfo.getType()) {
-        case SHORT:
-          msrType = DataType.SHORT;
-          break;
-        case INT:
-          msrType = DataType.INT;
-          break;
-        case LONG:
-          msrType = DataType.LONG;
-          break;
-        case DECIMAL:
-          msrType = DataType.DECIMAL;
-          break;
-        default:
-          msrType = DataType.DOUBLE;
+      DataType dataType = msrColumnEvalutorInfo.getType();
+      if (dataType == DataTypes.SHORT) {
+        msrType = DataTypes.SHORT;
+      } else if (dataType == DataTypes.INT) {
+        msrType = DataTypes.INT;
+      } else if (dataType == DataTypes.LONG) {
+        msrType = DataTypes.LONG;
+      } else if (dataType == DataTypes.DECIMAL) {
+        msrType = DataTypes.DECIMAL;
+      } else {
+        msrType = DataTypes.DOUBLE;
       }
       // add default value for the measure in case filter measure is not present
       // in the current block measure list
@@ -381,30 +376,24 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
       ColumnPage columnPage =
           blockChunkHolder.getMeasureRawDataChunk()[measureBlocksIndex[0]]
               .convertToColumnPage(pageIndex);
-      switch (msrType) {
-        case SHORT:
-          msrValue = (short) columnPage.getLong(index);
-          break;
-        case INT:
-          msrValue = (int) columnPage.getLong(index);
-          break;
-        case LONG:
-          msrValue = columnPage.getLong(index);
-          break;
-        case DECIMAL:
-          BigDecimal bigDecimalValue = columnPage.getDecimal(index);
-          if (null != bigDecimalValue &&
-              msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale() >
-                  bigDecimalValue.scale()) {
-            bigDecimalValue =
-                bigDecimalValue.setScale(
-                    msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale(),
-                    RoundingMode.HALF_UP);
-          }
-          msrValue = bigDecimalValue;
-          break;
-        default:
-          msrValue = columnPage.getDouble(index);
+      if (msrType == DataTypes.SHORT) {
+        msrValue = (short) columnPage.getLong(index);
+      } else if (msrType == DataTypes.INT) {
+        msrValue = (int) columnPage.getLong(index);
+      } else if (msrType == DataTypes.LONG) {
+        msrValue = columnPage.getLong(index);
+      } else if (msrType == DataTypes.DECIMAL) {
+        BigDecimal bigDecimalValue = columnPage.getDecimal(index);
+        if (null != bigDecimalValue
+            && msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale()
+            > bigDecimalValue.scale()) {
+          bigDecimalValue = bigDecimalValue
+              .setScale(msrColumnEvalutorInfo.getCarbonColumn().getColumnSchema().getScale(),
+                  RoundingMode.HALF_UP);
+        }
+        msrValue = bigDecimalValue;
+      } else {
+        msrValue = columnPage.getDouble(index);
       }
       record[msrColumnEvalutorInfo.getRowIndex()] =
           columnPage.getNullBits().get(index) ? null : msrValue;
@@ -444,13 +433,12 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
    */
   private Object getFilterActualValueFromDirectDictionaryValue(
       DimColumnResolvedFilterInfo dimColumnEvaluatorInfo, int dictionaryValue) {
-    switch (dimColumnEvaluatorInfo.getDimension().getDataType()) {
-      case DATE:
-        return dateDictionaryGenerator.getValueFromSurrogate(dictionaryValue);
-      case TIMESTAMP:
-        return timestampDictionaryGenerator.getValueFromSurrogate(dictionaryValue);
-      default:
-        throw new RuntimeException("Invalid data type for dierct dictionary");
+    if (dimColumnEvaluatorInfo.getDimension().getDataType() == DataTypes.DATE) {
+      return dateDictionaryGenerator.getValueFromSurrogate(dictionaryValue);
+    } else if (dimColumnEvaluatorInfo.getDimension().getDataType() == DataTypes.TIMESTAMP) {
+      return timestampDictionaryGenerator.getValueFromSurrogate(dictionaryValue);
+    } else {
+      throw new RuntimeException("Invalid data type for dierct dictionary");
     }
   }
 
@@ -533,8 +521,8 @@ public class RowLevelFilterExecuterImpl implements FilterExecuter {
   @Override public void readBlocks(BlocksChunkHolder blockChunkHolder) throws IOException {
     for (int i = 0; i < dimColEvaluatorInfoList.size(); i++) {
       DimColumnResolvedFilterInfo dimColumnEvaluatorInfo = dimColEvaluatorInfoList.get(i);
-      if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.ARRAY
-          && dimColumnEvaluatorInfo.getDimension().getDataType() != DataType.STRUCT) {
+      if (dimColumnEvaluatorInfo.getDimension().getDataType() != DataTypes.ARRAY
+          && dimColumnEvaluatorInfo.getDimension().getDataType() != DataTypes.STRUCT) {
         if (null == blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]]) {
           blockChunkHolder.getDimensionRawDataChunk()[dimensionBlocksIndex[i]] =
               blockChunkHolder.getDataBlock()

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
index 67fe848..5e0bb41 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java
@@ -30,6 +30,7 @@ import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionary
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -275,7 +276,7 @@ public class RowLevelRangeLessThanEqualFilterExecuterImpl extends RowLevelFilter
       } else {
         defaultValue = ByteUtil.toBytes(key);
       }
-    } else if (dimColEvaluatorInfoList.get(0).getDimension().getDataType() != DataType.STRING) {
+    } else if (dimColEvaluatorInfoList.get(0).getDimension().getDataType() != DataTypes.STRING) {
       defaultValue = CarbonCommonConstants.EMPTY_BYTE_ARRAY;
     }
     BitSet bitSet = null;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
index 8db37c4..74162f6 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java
@@ -30,6 +30,7 @@ import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionary
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -277,7 +278,7 @@ public class RowLevelRangeLessThanFiterExecuterImpl extends RowLevelFilterExecut
       } else {
         defaultValue = ByteUtil.toBytes(key);
       }
-    } else if (dimColEvaluatorInfoList.get(0).getDimension().getDataType() != DataType.STRING) {
+    } else if (dimColEvaluatorInfoList.get(0).getDimension().getDataType() != DataTypes.STRING) {
       defaultValue = CarbonCommonConstants.EMPTY_BYTE_ARRAY;
     }
     BitSet bitSet = null;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java
index 6dd59fd..bd78e08 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java
@@ -22,7 +22,7 @@ import java.util.SortedMap;
 
 import org.apache.carbondata.core.datastore.block.SegmentProperties;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.scan.expression.ColumnExpression;
 import org.apache.carbondata.core.scan.expression.Expression;
@@ -122,8 +122,8 @@ public class ConditionalFilterResolverImpl implements FilterResolverIntf {
         metadata.setExpression(leftExp);
         metadata.setIncludeFilter(isIncludeFilter);
         metadata.setTableProvider(tableProvider);
-        if (columnExpression.getDataType().equals(DataType.TIMESTAMP) ||
-            columnExpression.getDataType().equals(DataType.DATE)) {
+        if (columnExpression.getDataType().equals(DataTypes.TIMESTAMP) ||
+            columnExpression.getDataType().equals(DataTypes.DATE)) {
           isExpressionResolve = true;
         } else {
           // if imei=imei comes in filter condition then we need to
@@ -169,9 +169,9 @@ public class ConditionalFilterResolverImpl implements FilterResolverIntf {
       } else if ((null != columnList.get(0).getDimension()) && (
           columnList.get(0).getDimension().hasEncoding(Encoding.DICTIONARY) && !(
               columnList.get(0).getDimension().getDataType()
-                  == org.apache.carbondata.core.metadata.datatype.DataType.STRUCT
+                  == org.apache.carbondata.core.metadata.datatype.DataTypes.STRUCT
                   || columnList.get(0).getDimension().getDataType()
-                  == org.apache.carbondata.core.metadata.datatype.DataType.ARRAY))) {
+                  == org.apache.carbondata.core.metadata.datatype.DataTypes.ARRAY))) {
         dimColResolvedFilterInfo.setFilterValues(FilterUtil
             .getFilterListForAllValues(absoluteTableIdentifier, exp, columnList.get(0),
                 isIncludeFilter, tableProvider));

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
index c4df001..425c725 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/RowLevelRangeFilterResolverImpl.java
@@ -28,7 +28,7 @@ import org.apache.carbondata.core.datastore.block.SegmentProperties;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
-import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
@@ -167,7 +167,7 @@ public class RowLevelRangeFilterResolverImpl extends ConditionalFilterResolverIm
     for (ExpressionResult result : listOfExpressionResults) {
       try {
         if (result.getString() == null) {
-          if (result.getDataType() == DataType.STRING) {
+          if (result.getDataType() == DataTypes.STRING) {
             filterValuesList.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY);
           } else {
             filterValuesList.add(CarbonCommonConstants.EMPTY_BYTE_ARRAY);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
index 221d243..496cf6a 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/resolverinfo/visitor/CustomTypeDictionaryVisitor.java
@@ -24,6 +24,7 @@ import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.scan.expression.ColumnExpression;
 import org.apache.carbondata.core.scan.expression.exception.FilterIllegalMemberException;
 import org.apache.carbondata.core.scan.expression.exception.FilterUnsupportedException;
@@ -96,7 +97,7 @@ public class CustomTypeDictionaryVisitor implements ResolvedFilterInfoVisitorInt
       List<Integer> surrogates, DirectDictionaryGenerator directDictionaryGenerator,
       DataType dataType) {
     String timeFormat = null;
-    if (dataType == DataType.DATE) {
+    if (dataType == DataTypes.DATE) {
       timeFormat = CarbonProperties.getInstance()
           .getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
               CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/partition/PartitionUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/partition/PartitionUtil.java b/core/src/main/java/org/apache/carbondata/core/scan/partition/PartitionUtil.java
index 5921326..85e6cef 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/partition/PartitionUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/partition/PartitionUtil.java
@@ -22,6 +22,7 @@ import java.text.DateFormat;
 import java.util.BitSet;
 
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.schema.PartitionInfo;
 
 import org.apache.commons.lang.StringUtils;
@@ -47,29 +48,28 @@ public class PartitionUtil {
     if (data == null) {
       return null;
     }
-    if (actualDataType != DataType.STRING && StringUtils.isEmpty(data)) {
+    if (actualDataType != DataTypes.STRING && StringUtils.isEmpty(data)) {
       return null;
     }
     try {
-      switch (actualDataType) {
-        case STRING:
-          return data;
-        case INT:
-          return Integer.parseInt(data);
-        case SHORT:
-          return Short.parseShort(data);
-        case DOUBLE:
-          return Double.parseDouble(data);
-        case LONG:
-          return Long.parseLong(data);
-        case DATE:
-          return dateFormatter.parse(data).getTime();
-        case TIMESTAMP:
-          return timestampFormatter.parse(data).getTime();
-        case DECIMAL:
-          return new BigDecimal(data);
-        default:
-          return data;
+      if (actualDataType == DataTypes.STRING) {
+        return data;
+      } else if (actualDataType == DataTypes.INT) {
+        return Integer.parseInt(data);
+      } else if (actualDataType == DataTypes.SHORT) {
+        return Short.parseShort(data);
+      } else if (actualDataType == DataTypes.DOUBLE) {
+        return Double.parseDouble(data);
+      } else if (actualDataType == DataTypes.LONG) {
+        return Long.parseLong(data);
+      } else if (actualDataType == DataTypes.DATE) {
+        return dateFormatter.parse(data).getTime();
+      } else if (actualDataType == DataTypes.TIMESTAMP) {
+        return timestampFormatter.parse(data).getTime();
+      } else if (actualDataType == DataTypes.DECIMAL) {
+        return new BigDecimal(data);
+      } else {
+        return data;
       }
     } catch (Exception ex) {
       return null;
@@ -86,28 +86,26 @@ public class PartitionUtil {
     if (data == null) {
       return null;
     }
-    if (actualDataType != DataType.STRING && StringUtils.isEmpty(data)) {
+    if (actualDataType != DataTypes.STRING && StringUtils.isEmpty(data)) {
       return null;
     }
     try {
-      switch (actualDataType) {
-        case STRING:
-          return data;
-        case INT:
-          return Integer.parseInt(data);
-        case SHORT:
-          return Short.parseShort(data);
-        case DOUBLE:
-          return Double.parseDouble(data);
-        case LONG:
-          return Long.parseLong(data);
-        case DATE:
-        case TIMESTAMP:
-          return Long.parseLong(data) / 1000;
-        case DECIMAL:
-          return new BigDecimal(data);
-        default:
-          return data;
+      if (actualDataType == DataTypes.STRING) {
+        return data;
+      } else if (actualDataType == DataTypes.INT) {
+        return Integer.parseInt(data);
+      } else if (actualDataType == DataTypes.SHORT) {
+        return Short.parseShort(data);
+      } else if (actualDataType == DataTypes.DOUBLE) {
+        return Double.parseDouble(data);
+      } else if (actualDataType == DataTypes.LONG) {
+        return Long.parseLong(data);
+      } else if (actualDataType == DataTypes.DATE || actualDataType == DataTypes.TIMESTAMP) {
+        return Long.parseLong(data) / 1000;
+      } else if (actualDataType == DataTypes.DECIMAL) {
+        return new BigDecimal(data);
+      } else {
+        return data;
       }
     } catch (Exception ex) {
       return null;

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/partition/RangePartitioner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/partition/RangePartitioner.java b/core/src/main/java/org/apache/carbondata/core/scan/partition/RangePartitioner.java
index 50f609a..e61aefd 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/partition/RangePartitioner.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/partition/RangePartitioner.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.apache.carbondata.core.constants.CarbonCommonConstants;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.schema.PartitionInfo;
 import org.apache.carbondata.core.util.ByteUtil;
 import org.apache.carbondata.core.util.CarbonProperties;
@@ -50,7 +51,7 @@ public class RangePartitioner implements Partitioner {
     DataType partitionColumnDataType = partitionInfo.getColumnSchemaList().get(0).getDataType();
     numPartitions = values.size();
     bounds = new Object[numPartitions];
-    if (partitionColumnDataType == DataType.STRING) {
+    if (partitionColumnDataType == DataTypes.STRING) {
       for (int i = 0; i < numPartitions; i++) {
         bounds[i] = ByteUtil.toBytes(values.get(i));
       }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/scan/result/vector/MeasureDataVectorProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/result/vector/MeasureDataVectorProcessor.java b/core/src/main/java/org/apache/carbondata/core/scan/result/vector/MeasureDataVectorProcessor.java
index c145055..9b01e1f 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/result/vector/MeasureDataVectorProcessor.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/result/vector/MeasureDataVectorProcessor.java
@@ -21,6 +21,7 @@ import java.util.BitSet;
 
 import org.apache.carbondata.core.datastore.page.ColumnPage;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 
 import org.apache.spark.sql.types.Decimal;
 
@@ -306,17 +307,16 @@ public class MeasureDataVectorProcessor {
   public static class MeasureVectorFillerFactory {
 
     public static MeasureVectorFiller getMeasureVectorFiller(DataType dataType) {
-      switch (dataType) {
-        case SHORT:
-          return new ShortMeasureVectorFiller();
-        case INT:
-          return new IntegralMeasureVectorFiller();
-        case LONG:
-          return new LongMeasureVectorFiller();
-        case DECIMAL:
-          return new DecimalMeasureVectorFiller();
-        default:
-          return new DefaultMeasureVectorFiller();
+      if (dataType == DataTypes.SHORT) {
+        return new ShortMeasureVectorFiller();
+      } else if (dataType == DataTypes.INT) {
+        return new IntegralMeasureVectorFiller();
+      } else if (dataType == DataTypes.LONG) {
+        return new LongMeasureVectorFiller();
+      } else if (dataType == DataTypes.DECIMAL) {
+        return new DecimalMeasureVectorFiller();
+      } else {
+        return new DefaultMeasureVectorFiller();
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/util/AbstractDataFileFooterConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/AbstractDataFileFooterConverter.java b/core/src/main/java/org/apache/carbondata/core/util/AbstractDataFileFooterConverter.java
index c1cf8e8..1020e5b 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/AbstractDataFileFooterConverter.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/AbstractDataFileFooterConverter.java
@@ -36,6 +36,7 @@ import org.apache.carbondata.core.metadata.blocklet.index.BlockletBTreeIndex;
 import org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex;
 import org.apache.carbondata.core.metadata.blocklet.index.BlockletMinMaxIndex;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
 import org.apache.carbondata.core.reader.CarbonIndexFileReader;
@@ -352,27 +353,27 @@ public abstract class AbstractDataFileFooterConverter {
       org.apache.carbondata.format.DataType dataTypeThrift) {
     switch (dataTypeThrift) {
       case STRING:
-        return DataType.STRING;
+        return DataTypes.STRING;
       case SHORT:
-        return DataType.SHORT;
+        return DataTypes.SHORT;
       case INT:
-        return DataType.INT;
+        return DataTypes.INT;
       case LONG:
-        return DataType.LONG;
+        return DataTypes.LONG;
       case DOUBLE:
-        return DataType.DOUBLE;
+        return DataTypes.DOUBLE;
       case DECIMAL:
-        return DataType.DECIMAL;
+        return DataTypes.DECIMAL;
       case DATE:
-        return DataType.DATE;
+        return DataTypes.DATE;
       case TIMESTAMP:
-        return DataType.TIMESTAMP;
+        return DataTypes.TIMESTAMP;
       case ARRAY:
-        return DataType.ARRAY;
+        return DataTypes.ARRAY;
       case STRUCT:
-        return DataType.STRUCT;
+        return DataTypes.STRUCT;
       default:
-        return DataType.STRING;
+        return DataTypes.STRING;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/util/CarbonMetadataUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/CarbonMetadataUtil.java b/core/src/main/java/org/apache/carbondata/core/util/CarbonMetadataUtil.java
index ece97fe..2c9ef66 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonMetadataUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonMetadataUtil.java
@@ -27,6 +27,7 @@ import org.apache.carbondata.core.datastore.page.EncodedTablePage;
 import org.apache.carbondata.core.datastore.page.statistics.TablePageStatistics;
 import org.apache.carbondata.core.metadata.ColumnarFormatVersion;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.index.BlockIndexInfo;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
 import org.apache.carbondata.format.BlockIndex;
@@ -340,33 +341,30 @@ public class CarbonMetadataUtil {
     return CarbonMetadataUtil.getDataChunk3(dataChunksList);
   }
 
-  public static int compareMeasureData(byte[] first, byte[] second, DataType dataType) {
+  private static int compareMeasureData(byte[] first, byte[] second, DataType dataType) {
     ByteBuffer firstBuffer = null;
     ByteBuffer secondBuffer = null;
-    switch (dataType) {
-      case DOUBLE:
-        firstBuffer = ByteBuffer.allocate(8);
-        firstBuffer.put(first);
-        secondBuffer = ByteBuffer.allocate(8);
-        secondBuffer.put(second);
-        firstBuffer.flip();
-        secondBuffer.flip();
-        return (int) (firstBuffer.getDouble() - secondBuffer.getDouble());
-      case LONG:
-      case INT:
-      case SHORT:
-        firstBuffer = ByteBuffer.allocate(8);
-        firstBuffer.put(first);
-        secondBuffer = ByteBuffer.allocate(8);
-        secondBuffer.put(second);
-        firstBuffer.flip();
-        secondBuffer.flip();
-        return (int) (firstBuffer.getLong() - secondBuffer.getLong());
-      case DECIMAL:
-        return DataTypeUtil.byteToBigDecimal(first)
-            .compareTo(DataTypeUtil.byteToBigDecimal(second));
-      default:
-        throw new IllegalArgumentException("Invalid data type");
+    if (dataType == DataTypes.DOUBLE) {
+      firstBuffer = ByteBuffer.allocate(8);
+      firstBuffer.put(first);
+      secondBuffer = ByteBuffer.allocate(8);
+      secondBuffer.put(second);
+      firstBuffer.flip();
+      secondBuffer.flip();
+      return (int) (firstBuffer.getDouble() - secondBuffer.getDouble());
+    } else if (dataType == DataTypes.LONG || dataType == DataTypes.INT
+        || dataType == DataTypes.SHORT) {
+      firstBuffer = ByteBuffer.allocate(8);
+      firstBuffer.put(first);
+      secondBuffer = ByteBuffer.allocate(8);
+      secondBuffer.put(second);
+      firstBuffer.flip();
+      secondBuffer.flip();
+      return (int) (firstBuffer.getLong() - secondBuffer.getLong());
+    } else if (dataType == DataTypes.DECIMAL) {
+      return DataTypeUtil.byteToBigDecimal(first).compareTo(DataTypeUtil.byteToBigDecimal(second));
+    } else {
+      throw new IllegalArgumentException("Invalid data type");
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
index b5b3e63..2924c09 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
@@ -62,6 +62,7 @@ import org.apache.carbondata.core.metadata.ValueEncoderMeta;
 import org.apache.carbondata.core.metadata.blocklet.DataFileFooter;
 import org.apache.carbondata.core.metadata.blocklet.SegmentInfo;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.TableInfo;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
@@ -853,23 +854,6 @@ public final class CarbonUtil {
     return false;
   }
 
-  /**
-   * below method is to check whether it is complex data type
-   *
-   * @param dataType data type to be searched
-   * @return if data type is present
-   */
-  public static boolean hasComplexDataType(DataType dataType) {
-    switch (dataType) {
-      case ARRAY:
-      case STRUCT:
-      case MAP:
-        return true;
-      default:
-        return false;
-    }
-  }
-
   public static boolean[] getDictionaryEncodingArray(QueryDimension[] queryDimensions) {
     boolean[] dictionaryEncodingArray = new boolean[queryDimensions.length];
     for (int i = 0; i < queryDimensions.length; i++) {
@@ -900,7 +884,7 @@ public final class CarbonUtil {
     boolean[] dictionaryEncodingArray = new boolean[queryDimensions.length];
     for (int i = 0; i < queryDimensions.length; i++) {
       dictionaryEncodingArray[i] =
-          CarbonUtil.hasComplexDataType(queryDimensions[i].getDimension().getDataType());
+          queryDimensions[i].getDimension().getDataType().isComplexType();
     }
     return dictionaryEncodingArray;
   }
@@ -1619,16 +1603,15 @@ public final class CarbonUtil {
    * @return format
    */
   public static String getFormatFromProperty(DataType dataType) {
-    switch (dataType) {
-      case DATE:
-        return CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
-            CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
-      case TIMESTAMP:
-        return CarbonProperties.getInstance()
-            .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
-                CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
-      default:
-        return null;
+    if (dataType.equals(DataTypes.DATE)) {
+      return CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
+          CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
+    } else if (dataType.equals(DataTypes.TIMESTAMP)) {
+      return CarbonProperties.getInstance()
+          .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+              CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
+    } else {
+      return null;
     }
   }
 
@@ -1955,42 +1938,40 @@ public final class CarbonUtil {
    */
   public static byte[] getValueAsBytes(DataType dataType, Object value) {
     ByteBuffer b;
-    switch (dataType) {
-      case BYTE:
-        b = ByteBuffer.allocate(8);
-        b.putLong((byte) value);
-        b.flip();
-        return b.array();
-      case SHORT:
-        b = ByteBuffer.allocate(8);
-        b.putLong((short) value);
-        b.flip();
-        return b.array();
-      case INT:
-        b = ByteBuffer.allocate(8);
-        b.putLong((int) value);
-        b.flip();
-        return b.array();
-      case LONG:
-        b = ByteBuffer.allocate(8);
-        b.putLong((long) value);
-        b.flip();
-        return b.array();
-      case DOUBLE:
-        b = ByteBuffer.allocate(8);
-        b.putDouble((double) value);
-        b.flip();
-        return b.array();
-      case DECIMAL:
-        return DataTypeUtil.bigDecimalToByte((BigDecimal)value);
-      case BYTE_ARRAY:
-        return (byte[]) value;
-      case STRING:
-      case TIMESTAMP:
-      case DATE:
-        return (byte[]) value;
-      default:
-        throw new IllegalArgumentException("Invalid data type: " + dataType);
+    if (dataType == DataTypes.BYTE) {
+      b = ByteBuffer.allocate(8);
+      b.putLong((byte) value);
+      b.flip();
+      return b.array();
+    } else if (dataType == DataTypes.SHORT) {
+      b = ByteBuffer.allocate(8);
+      b.putLong((short) value);
+      b.flip();
+      return b.array();
+    } else if (dataType == DataTypes.INT) {
+      b = ByteBuffer.allocate(8);
+      b.putLong((int) value);
+      b.flip();
+      return b.array();
+    } else if (dataType == DataTypes.LONG) {
+      b = ByteBuffer.allocate(8);
+      b.putLong((long) value);
+      b.flip();
+      return b.array();
+    } else if (dataType == DataTypes.DOUBLE) {
+      b = ByteBuffer.allocate(8);
+      b.putDouble((double) value);
+      b.flip();
+      return b.array();
+    } else if (dataType == DataTypes.DECIMAL) {
+      return DataTypeUtil.bigDecimalToByte((BigDecimal) value);
+    } else if (dataType == DataTypes.BYTE_ARRAY) {
+      return (byte[]) value;
+    } else if (dataType == DataTypes.STRING || dataType == DataTypes.TIMESTAMP ||
+        dataType == DataTypes.DATE) {
+      return (byte[]) value;
+    } else {
+      throw new IllegalArgumentException("Invalid data type: " + dataType);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/carbondata/blob/956833e5/core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java b/core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java
index 2e65983..b8cd59d 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java
@@ -37,13 +37,12 @@ import org.apache.carbondata.core.datastore.page.ColumnPage;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryGenerator;
 import org.apache.carbondata.core.keygenerator.directdictionary.DirectDictionaryKeyGeneratorFactory;
 import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.datatype.DataTypes;
 import org.apache.carbondata.core.metadata.encoder.Encoding;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension;
 import org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure;
 import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
 
-
-
 public final class DataTypeUtil {
 
   /**
@@ -73,19 +72,19 @@ public final class DataTypeUtil {
 
   static {
     dataTypeDisplayNames = new HashMap<String, String>(16);
-    dataTypeDisplayNames.put(DataType.DATE.toString(), DataType.DATE.getName());
-    dataTypeDisplayNames.put(DataType.LONG.toString(), DataType.LONG.getName());
-    dataTypeDisplayNames.put(DataType.INT.toString(), DataType.INT.getName());
-    dataTypeDisplayNames.put(DataType.FLOAT.toString(), DataType.FLOAT.getName());
-    dataTypeDisplayNames.put(DataType.BOOLEAN.toString(), DataType.BOOLEAN.getName());
-    dataTypeDisplayNames.put(DataType.NULL.toString(), DataType.NULL.getName());
-    dataTypeDisplayNames.put(DataType.DECIMAL.toString(), DataType.DECIMAL.getName());
-    dataTypeDisplayNames.put(DataType.ARRAY.toString(), DataType.ARRAY.getName());
-    dataTypeDisplayNames.put(DataType.STRUCT.toString(), DataType.STRUCT.getName());
-    dataTypeDisplayNames.put(DataType.TIMESTAMP.toString(), DataType.TIMESTAMP.getName());
-    dataTypeDisplayNames.put(DataType.DATE.toString(), DataType.DATE.getName());
-    dataTypeDisplayNames.put(DataType.SHORT.toString(), DataType.SHORT.getName());
-    dataTypeDisplayNames.put(DataType.STRING.toString(), DataType.STRING.getName());
+    dataTypeDisplayNames.put(DataTypes.DATE.toString(), DataTypes.DATE.getName());
+    dataTypeDisplayNames.put(DataTypes.LONG.toString(), DataTypes.LONG.getName());
+    dataTypeDisplayNames.put(DataTypes.INT.toString(), DataTypes.INT.getName());
+    dataTypeDisplayNames.put(DataTypes.FLOAT.toString(), DataTypes.FLOAT.getName());
+    dataTypeDisplayNames.put(DataTypes.BOOLEAN.toString(), DataTypes.BOOLEAN.getName());
+    dataTypeDisplayNames.put(DataTypes.NULL.toString(), DataTypes.NULL.getName());
+    dataTypeDisplayNames.put(DataTypes.DECIMAL.toString(), DataTypes.DECIMAL.getName());
+    dataTypeDisplayNames.put(DataTypes.ARRAY.toString(), DataTypes.ARRAY.getName());
+    dataTypeDisplayNames.put(DataTypes.STRUCT.toString(), DataTypes.STRUCT.getName());
+    dataTypeDisplayNames.put(DataTypes.TIMESTAMP.toString(), DataTypes.TIMESTAMP.getName());
+    dataTypeDisplayNames.put(DataTypes.DATE.toString(), DataTypes.DATE.getName());
+    dataTypeDisplayNames.put(DataTypes.SHORT.toString(), DataTypes.SHORT.getName());
+    dataTypeDisplayNames.put(DataTypes.STRING.toString(), DataTypes.STRING.getName());
   }
 
   /**
@@ -103,23 +102,22 @@ public final class DataTypeUtil {
    */
   public static Object getMeasureValueBasedOnDataType(String msrValue, DataType dataType,
       CarbonMeasure carbonMeasure) {
-    switch (dataType) {
-      case DECIMAL:
-        BigDecimal bigDecimal =
-            new BigDecimal(msrValue).setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
-        return normalizeDecimalValue(bigDecimal, carbonMeasure.getPrecision());
-      case SHORT:
-        return Short.parseShort(msrValue);
-      case INT:
-        return Integer.parseInt(msrValue);
-      case LONG:
-        return Long.valueOf(msrValue);
-      default:
-        Double parsedValue = Double.valueOf(msrValue);
-        if (Double.isInfinite(parsedValue) || Double.isNaN(parsedValue)) {
-          return null;
-        }
-        return parsedValue;
+    if (dataType == DataTypes.DECIMAL) {
+      BigDecimal bigDecimal =
+          new BigDecimal(msrValue).setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
+      return normalizeDecimalValue(bigDecimal, carbonMeasure.getPrecision());
+    } else if (dataType == DataTypes.SHORT) {
+      return Short.parseShort(msrValue);
+    } else if (dataType == DataTypes.INT) {
+      return Integer.parseInt(msrValue);
+    } else if (dataType == DataTypes.LONG) {
+      return Long.valueOf(msrValue);
+    } else {
+      Double parsedValue = Double.valueOf(msrValue);
+      if (Double.isInfinite(parsedValue) || Double.isNaN(parsedValue)) {
+        return null;
+      }
+      return parsedValue;
     }
   }
 
@@ -128,42 +126,40 @@ public final class DataTypeUtil {
       return null;
     }
     ByteBuffer bb = ByteBuffer.wrap(data);
-    switch (dataType) {
-      case SHORT:
-        return (short)bb.getLong();
-      case INT:
-        return (int)bb.getLong();
-      case LONG:
-        return bb.getLong();
-      case DECIMAL:
-        return byteToBigDecimal(data);
-      default:
-        return bb.getDouble();
+    if (dataType == DataTypes.SHORT) {
+      return (short) bb.getLong();
+    } else if (dataType == DataTypes.INT) {
+      return (int) bb.getLong();
+    } else if (dataType == DataTypes.LONG) {
+      return bb.getLong();
+    } else if (dataType == DataTypes.DECIMAL) {
+      return byteToBigDecimal(data);
+    } else {
+      return bb.getDouble();
     }
   }
 
   public static Object getMeasureObjectBasedOnDataType(ColumnPage measurePage, int index,
       DataType dataType, CarbonMeasure carbonMeasure) {
-    switch (dataType) {
-      case SHORT:
-        return (short)measurePage.getLong(index);
-      case INT:
-        return (int)measurePage.getLong(index);
-      case LONG:
-        return measurePage.getLong(index);
-      case DECIMAL:
-        BigDecimal bigDecimalMsrValue = measurePage.getDecimal(index);
-        if (null != bigDecimalMsrValue && carbonMeasure.getScale() > bigDecimalMsrValue.scale()) {
-          bigDecimalMsrValue =
-              bigDecimalMsrValue.setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
-        }
-        if (null != bigDecimalMsrValue) {
-          return normalizeDecimalValue(bigDecimalMsrValue, carbonMeasure.getPrecision());
-        } else {
-          return bigDecimalMsrValue;
-        }
-      default:
-        return measurePage.getDouble(index);
+    if (dataType == DataTypes.SHORT) {
+      return (short) measurePage.getLong(index);
+    } else if (dataType == DataTypes.INT) {
+      return (int) measurePage.getLong(index);
+    } else if (dataType == DataTypes.LONG) {
+      return measurePage.getLong(index);
+    } else if (dataType == DataTypes.DECIMAL) {
+      BigDecimal bigDecimalMsrValue = measurePage.getDecimal(index);
+      if (null != bigDecimalMsrValue && carbonMeasure.getScale() > bigDecimalMsrValue.scale()) {
+        bigDecimalMsrValue =
+            bigDecimalMsrValue.setScale(carbonMeasure.getScale(), RoundingMode.HALF_UP);
+      }
+      if (null != bigDecimalMsrValue) {
+        return normalizeDecimalValue(bigDecimalMsrValue, carbonMeasure.getPrecision());
+      } else {
+        return bigDecimalMsrValue;
+      }
+    } else {
+      return measurePage.getDouble(index);
     }
   }
 
@@ -245,38 +241,38 @@ public final class DataTypeUtil {
     DataType dataType = null;
     switch (dataTypeStr) {
       case "DATE":
-        dataType = DataType.DATE;
+        dataType = DataTypes.DATE;
         break;
       case "TIMESTAMP":
-        dataType = DataType.TIMESTAMP;
+        dataType = DataTypes.TIMESTAMP;
         break;
       case "STRING":
-        dataType = DataType.STRING;
+        dataType = DataTypes.STRING;
         break;
       case "INT":
-        dataType = DataType.INT;
+        dataType = DataTypes.INT;
         break;
       case "SMALLINT":
-        dataType = DataType.SHORT;
+        dataType = DataTypes.SHORT;
         break;
       case "LONG":
-        dataType = DataType.LONG;
+        dataType = DataTypes.LONG;
         break;
       case "DOUBLE":
-        dataType = DataType.DOUBLE;
+        dataType = DataTypes.DOUBLE;
         break;
       case "DECIMAL":
-        dataType = DataType.DECIMAL;
+        dataType = DataTypes.DECIMAL;
         break;
       case "ARRAY":
-        dataType = DataType.ARRAY;
+        dataType = DataTypes.ARRAY;
         break;
       case "STRUCT":
-        dataType = DataType.STRUCT;
+        dataType = DataTypes.STRUCT;
         break;
       case "MAP":
       default:
-        dataType = DataType.STRING;
+        dataType = DataTypes.STRING;
     }
     return dataType;
   }
@@ -307,61 +303,60 @@ public final class DataTypeUtil {
       return null;
     }
     try {
-      switch (actualDataType) {
-        case INT:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return Integer.parseInt(data);
-        case SHORT:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return Short.parseShort(data);
-        case FLOAT:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return Float.parseFloat(data);
-        case DOUBLE:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return Double.parseDouble(data);
-        case LONG:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return Long.parseLong(data);
-        case DATE:
-          if (data.isEmpty()) {
-            return null;
-          }
-          try {
-            Date dateToStr = dateformatter.get().parse(data);
-            return dateToStr.getTime() * 1000;
-          } catch (ParseException e) {
-            LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
-            return null;
-          }
-        case TIMESTAMP:
-          if (data.isEmpty()) {
-            return null;
-          }
-          try {
-            Date dateToStr = timeStampformatter.get().parse(data);
-            return dateToStr.getTime() * 1000;
-          } catch (ParseException e) {
-            LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
-            return null;
-          }
-        case DECIMAL:
-          if (data.isEmpty()) {
-            return null;
-          }
-          return converter.convertToDecimal(data);
-        default:
-          return converter.convertFromStringToUTF8String(data);
+      if (actualDataType == DataTypes.INT) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return Integer.parseInt(data);
+      } else if (actualDataType == DataTypes.SHORT) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return Short.parseShort(data);
+      } else if (actualDataType == DataTypes.FLOAT) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return Float.parseFloat(data);
+      } else if (actualDataType == DataTypes.DOUBLE) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return Double.parseDouble(data);
+      } else if (actualDataType == DataTypes.LONG) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return Long.parseLong(data);
+      } else if (actualDataType == DataTypes.DATE) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        try {
+          Date dateToStr = dateformatter.get().parse(data);
+          return dateToStr.getTime() * 1000;
+        } catch (ParseException e) {
+          LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
+          return null;
+        }
+      } else if (actualDataType == DataTypes.TIMESTAMP) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        try {
+          Date dateToStr = timeStampformatter.get().parse(data);
+          return dateToStr.getTime() * 1000;
+        } catch (ParseException e) {
+          LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
+          return null;
+        }
+      } else if (actualDataType == DataTypes.DECIMAL) {
+        if (data.isEmpty()) {
+          return null;
+        }
+        return converter.convertToDecimal(data);
+      } else {
+        return converter.convertFromStringToUTF8String(data);
       }
     } catch (NumberFormatException ex) {
       LOGGER.error("Problem while converting data type" + data);
@@ -371,33 +366,32 @@ public final class DataTypeUtil {
 
   public static byte[] getBytesBasedOnDataTypeForNoDictionaryColumn(String dimensionValue,
       DataType actualDataType, String dateFormat) {
-    switch (actualDataType) {
-      case STRING:
-        return ByteUtil.toBytes(dimensionValue);
-      case BOOLEAN:
-        return ByteUtil.toBytes(Boolean.parseBoolean(dimensionValue));
-      case SHORT:
-        return ByteUtil.toBytes(Short.parseShort(dimensionValue));
-      case INT:
-        return ByteUtil.toBytes(Integer.parseInt(dimensionValue));
-      case LONG:
-        return ByteUtil.toBytes(Long.parseLong(dimensionValue));
-      case TIMESTAMP:
-        Date dateToStr = null;
-        DateFormat dateFormatter = null;
-        try {
-          if (null != dateFormat) {
-            dateFormatter = new SimpleDateFormat(dateFormat);
-          } else {
-            dateFormatter = timeStampformatter.get();
-          }
-          dateToStr = dateFormatter.parse(dimensionValue);
-          return ByteUtil.toBytes(dateToStr.getTime());
-        } catch (ParseException e) {
-          throw new NumberFormatException(e.getMessage());
+    if (actualDataType == DataTypes.STRING) {
+      return ByteUtil.toBytes(dimensionValue);
+    } else if (actualDataType == DataTypes.BOOLEAN) {
+      return ByteUtil.toBytes(Boolean.parseBoolean(dimensionValue));
+    } else if (actualDataType == DataTypes.SHORT) {
+      return ByteUtil.toBytes(Short.parseShort(dimensionValue));
+    } else if (actualDataType == DataTypes.INT) {
+      return ByteUtil.toBytes(Integer.parseInt(dimensionValue));
+    } else if (actualDataType == DataTypes.LONG) {
+      return ByteUtil.toBytes(Long.parseLong(dimensionValue));
+    } else if (actualDataType == DataTypes.TIMESTAMP) {
+      Date dateToStr = null;
+      DateFormat dateFormatter = null;
+      try {
+        if (null != dateFormat) {
+          dateFormatter = new SimpleDateFormat(dateFormat);
+        } else {
+          dateFormatter = timeStampformatter.get();
         }
-      default:
-        return ByteUtil.toBytes(dimensionValue);
+        dateToStr = dateFormatter.parse(dimensionValue);
+        return ByteUtil.toBytes(dateToStr.getTime());
+      } catch (ParseException e) {
+        throw new NumberFormatException(e.getMessage());
+      }
+    } else {
+      return ByteUtil.toBytes(dimensionValue);
     }
   }
 
@@ -417,21 +411,20 @@ public final class DataTypeUtil {
       return null;
     }
     try {
-      switch (actualDataType) {
-        case STRING:
-          return getDataTypeConverter().convertFromByteToUTF8String(dataInBytes);
-        case BOOLEAN:
-          return ByteUtil.toBoolean(dataInBytes);
-        case SHORT:
-          return ByteUtil.toShort(dataInBytes, 0, dataInBytes.length);
-        case INT:
-          return ByteUtil.toInt(dataInBytes, 0, dataInBytes.length);
-        case LONG:
-          return ByteUtil.toLong(dataInBytes, 0, dataInBytes.length);
-        case TIMESTAMP:
-          return ByteUtil.toLong(dataInBytes, 0, dataInBytes.length) * 1000L;
-        default:
-          return ByteUtil.toString(dataInBytes, 0, dataInBytes.length);
+      if (actualDataType == DataTypes.STRING) {
+        return getDataTypeConverter().convertFromByteToUTF8String(dataInBytes);
+      } else if (actualDataType == DataTypes.BOOLEAN) {
+        return ByteUtil.toBoolean(dataInBytes);
+      } else if (actualDataType == DataTypes.SHORT) {
+        return ByteUtil.toShort(dataInBytes, 0, dataInBytes.length);
+      } else if (actualDataType == DataTypes.INT) {
+        return ByteUtil.toInt(dataInBytes, 0, dataInBytes.length);
+      } else if (actualDataType == DataTypes.LONG) {
+        return ByteUtil.toLong(dataInBytes, 0, dataInBytes.length);
+      } else if (actualDataType == DataTypes.TIMESTAMP) {
+        return ByteUtil.toLong(dataInBytes, 0, dataInBytes.length) * 1000L;
+      } else {
+        return ByteUtil.toString(dataInBytes, 0, dataInBytes.length);
       }
     } catch (Throwable ex) {
       String data = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
@@ -457,68 +450,67 @@ public final class DataTypeUtil {
       return null;
     }
     try {
-      switch (dimension.getDataType()) {
-        case INT:
-          String data1 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data1.isEmpty()) {
-            return null;
-          }
-          return Integer.parseInt(data1);
-        case SHORT:
-          String data2 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data2.isEmpty()) {
-            return null;
-          }
-          return Short.parseShort(data2);
-        case DOUBLE:
-          String data3 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data3.isEmpty()) {
-            return null;
-          }
-          return Double.parseDouble(data3);
-        case LONG:
-          String data4 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data4.isEmpty()) {
-            return null;
-          }
-          return Long.parseLong(data4);
-        case DATE:
-          String data5 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data5.isEmpty()) {
-            return null;
-          }
-          try {
-            Date dateToStr = dateformatter.get().parse(data5);
-            return dateToStr.getTime() * 1000;
-          } catch (ParseException e) {
-            LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
-            return null;
-          }
-
-        case TIMESTAMP:
-          String data6 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data6.isEmpty()) {
-            return null;
-          }
-          try {
-            Date dateToStr = timeStampformatter.get().parse(data6);
-            return dateToStr.getTime() * 1000;
-          } catch (ParseException e) {
-            LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
-            return null;
-          }
-        case DECIMAL:
-          String data7 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
-          if (data7.isEmpty()) {
-            return null;
-          }
-          java.math.BigDecimal javaDecVal = new java.math.BigDecimal(data7);
-          if (dimension.getColumnSchema().getScale() > javaDecVal.scale()) {
-            javaDecVal = javaDecVal.setScale(dimension.getColumnSchema().getScale());
-          }
-          return getDataTypeConverter().convertToDecimal(javaDecVal);
-        default:
-          return getDataTypeConverter().convertFromByteToUTF8String(dataInBytes);
+      DataType dataType = dimension.getDataType();
+      if (dataType == DataTypes.INT) {
+        String data1 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data1.isEmpty()) {
+          return null;
+        }
+        return Integer.parseInt(data1);
+      } else if (dataType == DataTypes.SHORT) {
+        String data2 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data2.isEmpty()) {
+          return null;
+        }
+        return Short.parseShort(data2);
+      } else if (dataType == DataTypes.DOUBLE) {
+        String data3 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data3.isEmpty()) {
+          return null;
+        }
+        return Double.parseDouble(data3);
+      } else if (dataType == DataTypes.LONG) {
+        String data4 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data4.isEmpty()) {
+          return null;
+        }
+        return Long.parseLong(data4);
+      } else if (dataType == DataTypes.DATE) {
+        String data5 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data5.isEmpty()) {
+          return null;
+        }
+        try {
+          Date dateToStr = dateformatter.get().parse(data5);
+          return dateToStr.getTime() * 1000;
+        } catch (ParseException e) {
+          LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
+          return null;
+        }
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        String data6 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data6.isEmpty()) {
+          return null;
+        }
+        try {
+          Date dateToStr = timeStampformatter.get().parse(data6);
+          return dateToStr.getTime() * 1000;
+        } catch (ParseException e) {
+          LOGGER.error("Cannot convert value to Time/Long type value" + e.getMessage());
+          return null;
+        }
+      } else if (dataType == DataTypes.DECIMAL) {
+        String data7 = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
+        if (data7.isEmpty()) {
+          return null;
+        }
+        java.math.BigDecimal javaDecVal = new java.math.BigDecimal(data7);
+        if (dimension.getColumnSchema().getScale() > javaDecVal.scale()) {
+          javaDecVal = javaDecVal.setScale(dimension.getColumnSchema().getScale());
+        }
+        return getDataTypeConverter().convertToDecimal(javaDecVal);
+      } else {
+        return getDataTypeConverter().convertFromByteToUTF8String(dataInBytes);
       }
     } catch (NumberFormatException ex) {
       String data = new String(dataInBytes, CarbonCommonConstants.DEFAULT_CHARSET_CLASS);
@@ -542,18 +534,14 @@ public final class DataTypeUtil {
     }
     try {
       Object parsedValue = null;
-      switch (actualDataType) {
-        case SHORT:
-          parsedValue = Short.parseShort(data);
-          break;
-        case INT:
-          parsedValue = Integer.parseInt(data);
-          break;
-        case LONG:
-          parsedValue = Long.parseLong(data);
-          break;
-        default:
-          return data;
+      if (actualDataType == DataTypes.SHORT) {
+        parsedValue = Short.parseShort(data);
+      } else if (actualDataType == DataTypes.INT) {
+        parsedValue = Integer.parseInt(data);
+      } else if (actualDataType == DataTypes.LONG) {
+        parsedValue = Long.parseLong(data);
+      } else {
+        return data;
       }
       if (null != parsedValue) {
         return data;
@@ -577,19 +565,16 @@ public final class DataTypeUtil {
       Object parsedValue = null;
       // validation will not be done for timestamp datatype as for timestamp direct dictionary
       // is generated. No dictionary file is created for timestamp datatype column
-      switch (dimension.getDataType()) {
-        case DECIMAL:
-          return parseStringToBigDecimal(value, dimension);
-        case SHORT:
-        case INT:
-        case LONG:
-          parsedValue = normalizeIntAndLongValues(value, dimension.getDataType());
-          break;
-        case DOUBLE:
-          parsedValue = Double.parseDouble(value);
-          break;
-        default:
-          return value;
+      DataType dataType = dimension.getDataType();
+      if (dataType == DataTypes.DECIMAL) {
+        return parseStringToBigDecimal(value, dimension);
+      } else if (dataType == DataTypes.SHORT || dataType == DataTypes.INT ||
+          dataType == DataTypes.LONG) {
+        parsedValue = normalizeIntAndLongValues(value, dimension.getDataType());
+      } else if (dataType == DataTypes.DOUBLE) {
+        parsedValue = Double.parseDouble(value);
+      } else {
+        return value;
       }
       if (null != parsedValue) {
         return value;
@@ -613,23 +598,19 @@ public final class DataTypeUtil {
       return null;
     }
     try {
-      switch (dimension.getDataType()) {
-        case DECIMAL:
-          return parseStringToBigDecimal(value, dimension);
-        case INT:
-          Integer.parseInt(value);
-          break;
-        case DOUBLE:
-          Double.parseDouble(value);
-          break;
-        case LONG:
-          Long.parseLong(value);
-          break;
-        case FLOAT:
-          Float.parseFloat(value);
-          break;
-        default:
-          // do nothing
+      DataType dataType = dimension.getDataType();
+      if (dataType == DataTypes.DECIMAL) {
+        return parseStringToBigDecimal(value, dimension);
+      } else if (dataType == DataTypes.INT) {
+        Integer.parseInt(value);
+      } else if (dataType == DataTypes.DOUBLE) {
+        Double.parseDouble(value);
+      } else if (dataType == DataTypes.LONG) {
+        Long.parseLong(value);
+      } else if (dataType == DataTypes.FLOAT) {
+        Float.parseFloat(value);
+      } else {
+        // do nothing
       }
     } catch (NumberFormatException e) {
       return null;
@@ -682,55 +663,54 @@ public final class DataTypeUtil {
     }
     try {
       long parsedIntVal = 0;
-      switch (columnSchema.getDataType()) {
-        case INT:
-          parsedIntVal = (long) Integer.parseInt(data);
-          return String.valueOf(parsedIntVal)
-              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-        case SHORT:
-          parsedIntVal = (long) Short.parseShort(data);
-          return String.valueOf(parsedIntVal)
-              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-        case DOUBLE:
-          return String.valueOf(Double.parseDouble(data))
-              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-        case LONG:
-          return String.valueOf(Long.parseLong(data))
-              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-        case DATE:
-          DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory
+      DataType dataType = columnSchema.getDataType();
+      if (dataType == DataTypes.INT) {
+        parsedIntVal = (long) Integer.parseInt(data);
+        return String.valueOf(parsedIntVal)
+            .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+      } else if (dataType == DataTypes.SHORT) {
+        parsedIntVal = (long) Short.parseShort(data);
+        return String.valueOf(parsedIntVal)
+            .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+      } else if (dataType == DataTypes.DOUBLE) {
+        return String.valueOf(Double.parseDouble(data))
+            .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+      } else if (dataType == DataTypes.LONG) {
+        return String.valueOf(Long.parseLong(data))
+            .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+      } else if (dataType == DataTypes.DATE) {
+        DirectDictionaryGenerator directDictionaryGenerator = DirectDictionaryKeyGeneratorFactory
+            .getDirectDictionaryGenerator(columnSchema.getDataType());
+        int value = directDictionaryGenerator.generateDirectSurrogateKey(data);
+        return String.valueOf(value)
+            .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
+      } else if (dataType == DataTypes.TIMESTAMP) {
+        if (columnSchema.hasEncoding(Encoding.DIRECT_DICTIONARY)) {
+          DirectDictionaryGenerator directDictionaryGenerator1 = DirectDictionaryKeyGeneratorFactory
               .getDirectDictionaryGenerator(columnSchema.getDataType());
-          int value = directDictionaryGenerator.generateDirectSurrogateKey(data);
-          return String.valueOf(value)
+          int value1 = directDictionaryGenerator1.generateDirectSurrogateKey(data);
+          return String.valueOf(value1)
               .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-        case TIMESTAMP:
-          if (columnSchema.hasEncoding(Encoding.DIRECT_DICTIONARY)) {
-            DirectDictionaryGenerator directDictionaryGenerator1 =
-                DirectDictionaryKeyGeneratorFactory
-                    .getDirectDictionaryGenerator(columnSchema.getDataType());
-            int value1 = directDictionaryGenerator1.generateDirectSurrogateKey(data);
-            return String.valueOf(value1)
-                .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-          } else {
-            try {
-              Date dateToStr = timeStampformatter.get().parse(data);
-              return ByteUtil.toBytes(dateToStr.getTime());
-            } catch (ParseException e) {
-              LOGGER.error(
-                  "Cannot convert value to Time/Long type value. Value is considered as null" + e
-                      .getMessage());
-              return null;
-            }
-          }
-        case DECIMAL:
-          String parsedValue = parseStringToBigDecimal(data, columnSchema);
-          if (null == parsedValue) {
+        } else {
+          try {
+            Date dateToStr = timeStampformatter.get().parse(data);
+            return ByteUtil.toBytes(dateToStr.getTime());
+          } catch (ParseException e) {
+            LOGGER.error(
+                "Cannot convert value to Time/Long type value. Value is considered as null" + e
+                    .getMessage());
             return null;
           }
-          java.math.BigDecimal javaDecVal = new java.math.BigDecimal(parsedValue);
-          return bigDecimalToByte(javaDecVal);
-        default:
-          return getDataTypeConverter().convertFromStringToByte(data);
+        }
+      } else if (dataType == DataTypes.DECIMAL) {
+        String parsedValue = parseStringToBigDecimal(data, columnSchema);
+        if (null == parsedValue) {
+          return null;
+        }
+        java.math.BigDecimal javaDecVal = new java.math.BigDecimal(parsedValue);
+        return bigDecimalToByte(javaDecVal);
+      } else {
+        return getDataTypeConverter().convertFromStringToByte(data);
       }
     } catch (NumberFormatException ex) {
       LOGGER.error("Problem while converting data type" + data);
@@ -749,19 +729,16 @@ public final class DataTypeUtil {
   public static String normalizeColumnValueForItsDataType(String value, ColumnSchema columnSchema) {
     try {
       Object parsedValue = null;
-      switch (columnSchema.getDataType()) {
-        case DECIMAL:
-          return parseStringToBigDecimal(value, columnSchema);
-        case SHORT:
-        case INT:
-        case LONG:
-          parsedValue = normalizeIntAndLongValues(value, columnSchema.getDataType());
-          break;
-        case DOUBLE:
-          parsedValue = Double.parseDouble(value);
-          break;
-        default:
-          return value;
+      DataType dataType = columnSchema.getDataType();
+      if (dataType == DataTypes.DECIMAL) {
+        return parseStringToBigDecimal(value, columnSchema);
+      } else if (dataType == DataTypes.SHORT || dataType == DataTypes.INT ||
+          dataType == DataTypes.LONG) {
+        parsedValue = normalizeIntAndLongValues(value, columnSchema.getDataType());
+      } else if (dataType == DataTypes.DOUBLE) {
+        parsedValue = Double.parseDouble(value);
+      } else {
+        return value;
       }
       if (null != parsedValue) {
         return value;


Mime
View raw message