carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [21/50] [abbrv] incubator-carbondata git commit: [Issue-643] Column Property addition, extract interface for dictionary (#641)
Date Thu, 30 Jun 2016 17:42:08 GMT
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/38d84e0e/processing/src/main/java/org/carbondata/processing/surrogatekeysgenerator/csvbased/FileStoreSurrogateKeyGenForCSV.java
----------------------------------------------------------------------
diff --git a/processing/src/main/java/org/carbondata/processing/surrogatekeysgenerator/csvbased/FileStoreSurrogateKeyGenForCSV.java
b/processing/src/main/java/org/carbondata/processing/surrogatekeysgenerator/csvbased/FileStoreSurrogateKeyGenForCSV.java
index e2ca310..196d677 100644
--- a/processing/src/main/java/org/carbondata/processing/surrogatekeysgenerator/csvbased/FileStoreSurrogateKeyGenForCSV.java
+++ b/processing/src/main/java/org/carbondata/processing/surrogatekeysgenerator/csvbased/FileStoreSurrogateKeyGenForCSV.java
@@ -35,6 +35,7 @@ import org.carbondata.core.cache.CacheType;
 import org.carbondata.core.cache.dictionary.Dictionary;
 import org.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier;
 import org.carbondata.core.carbon.CarbonTableIdentifier;
+import org.carbondata.core.carbon.ColumnIdentifier;
 import org.carbondata.core.carbon.metadata.CarbonMetadata;
 import org.carbondata.core.carbon.metadata.schema.table.CarbonTable;
 import org.carbondata.core.constants.CarbonCommonConstants;
@@ -241,17 +242,21 @@ public class FileStoreSurrogateKeyGenForCSV extends CarbonCSVBasedDimSurrogateKe
         List<GenericDataType> primitiveChild = new ArrayList<GenericDataType>();
         complexType.getAllPrimitiveChildren(primitiveChild);
         for (GenericDataType eachPrimitive : primitiveChild) {
+          ColumnIdentifier columnIdentifier = new ColumnIdentifier(eachPrimitive.getColumnId(),
+              columnsInfo.getColumnProperties(eachPrimitive.getName()), details.getColumnType());
           String dimColumnName =
               tableName + CarbonCommonConstants.UNDERSCORE + eachPrimitive.getName();
           DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier =
-              new DictionaryColumnUniqueIdentifier(carbonTableIdentifier,
-                  eachPrimitive.getColumnId());
+              new DictionaryColumnUniqueIdentifier(carbonTableIdentifier, columnIdentifier);
           dictionaryColumnUniqueIdentifiers.add(dictionaryColumnUniqueIdentifier);
           dictionaryKeys.add(dimColumnName);
         }
       } else {
+        ColumnIdentifier columnIdentifier =
+            new ColumnIdentifier(dimColumnIds[i], columnsInfo.getColumnProperties(dimColName),
+                details.getColumnType());
         DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier =
-            new DictionaryColumnUniqueIdentifier(carbonTableIdentifier, dimColumnIds[i]);
+            new DictionaryColumnUniqueIdentifier(carbonTableIdentifier, columnIdentifier);
         dictionaryColumnUniqueIdentifiers.add(dictionaryColumnUniqueIdentifier);
         dictionaryKeys.add(dimColumnNames[i]);
       }
@@ -386,4 +391,3 @@ public class FileStoreSurrogateKeyGenForCSV extends CarbonCSVBasedDimSurrogateKe
   }
 
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/38d84e0e/processing/src/main/java/org/carbondata/processing/util/CarbonSchemaParser.java
----------------------------------------------------------------------
diff --git a/processing/src/main/java/org/carbondata/processing/util/CarbonSchemaParser.java
b/processing/src/main/java/org/carbondata/processing/util/CarbonSchemaParser.java
index a6a9328..3a789f1 100644
--- a/processing/src/main/java/org/carbondata/processing/util/CarbonSchemaParser.java
+++ b/processing/src/main/java/org/carbondata/processing/util/CarbonSchemaParser.java
@@ -20,6 +20,7 @@
 package org.carbondata.processing.util;
 
 import java.util.*;
+import java.util.Map.Entry;
 
 import org.carbondata.core.carbon.CarbonDataLoadSchema;
 import org.carbondata.core.carbon.CarbonDataLoadSchema.DimensionRelation;
@@ -1229,4 +1230,47 @@ public final class CarbonSchemaParser {
     }
     return counter;
   }
+
+  public static String getColumnPropertiesString(List<CarbonDimension> dimensions)
{
+    StringBuilder colPropertiesString = new StringBuilder();
+    for (int dim = 0; dim < dimensions.size(); dim++) {
+      CarbonDimension dimension = dimensions.get(dim);
+      if (dimension.isComplex()) {
+        List<CarbonDimension> childs = dimension.getListOfChildDimensions();
+        for (CarbonDimension child : childs) {
+          buildDimensionColumnPropertyString(child, colPropertiesString, dim);
+        }
+      } else {
+        buildDimensionColumnPropertyString(dimension, colPropertiesString, dim);
+      }
+
+    }
+
+    return colPropertiesString.toString();
+  }
+
+  protected static void buildDimensionColumnPropertyString(CarbonDimension dimension,
+      StringBuilder colPropertiesString, int dim) {
+    Map<String, String> columnProperties = dimension.getColumnProperties();
+    if (null != columnProperties && columnProperties.size() > 0) {
+      if (colPropertiesString.length() > 0) {
+        colPropertiesString.append(CarbonCommonConstants.HASH_SPC_CHARACTER);
+      }
+      colPropertiesString.append(dimension.getColName())
+          .append(CarbonCommonConstants.COLON_SPC_CHARACTER);
+      int size = columnProperties.entrySet().size();
+      int index = 0;
+      Iterator<Entry<String, String>> itr = columnProperties.entrySet().iterator();
+      while (itr.hasNext()) {
+        Entry<String, String> entry = itr.next();
+        colPropertiesString.append(entry.getKey())
+            .append(CarbonCommonConstants.HYPHEN_SPC_CHARACTER);
+        colPropertiesString.append(entry.getValue());
+        index++;
+        if (index < size) {
+          colPropertiesString.append(CarbonCommonConstants.COMA_SPC_CHARACTER);
+        }
+      }
+    }
+  }
 }


Mime
View raw message