VenuReddy2103 commented on a change in pull request #3436: 
[CARBONDATA-3548]Geospatial Support: Modified to create and load the table with 
a nonschema dimension sort column. And added InPolygon UDF
URL: https://github.com/apache/carbondata/pull/3436#discussion_r349878033
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/carbondata/processing/loading/converter/impl/RowConverterImpl.java
 ##########
 @@ -161,11 +166,59 @@ public DictionaryClient call() throws Exception {
     return null;
   }
 
+  private int getDataFieldIndexByName(String column) {
+    for (int i = 0; i < fields.length; i++) {
+      if (fields[i].getColumn().getColName().equalsIgnoreCase(column)) {
+        return i;
+      }
+    }
+    return -1;
+  }
+
+  private String generateNonSchemaColumnValue(DataField field, CarbonRow row) {
+    Map<String, String> properties = 
configuration.getTableSpec().getCarbonTable()
+            .getTableInfo().getFactTable().getTableProperties();
+    String handler = properties.get(CarbonCommonConstants.INDEX_HANDLER
+            + "." + field.getColumn().getColName() + ".instance");
+    if (handler != null) {
+      try {
+        // TODO Need to check to how to store the instance. This serialization 
may be incorrect.
+        ByteArrayInputStream bis = new 
ByteArrayInputStream(Base64.getDecoder().decode(handler));
+        ObjectInputStream in = new ObjectInputStream(bis);
+        CustomIndex instance = (CustomIndex) in.readObject();
+        String sourceColumns = 
properties.get(CarbonCommonConstants.INDEX_HANDLER
+                + "." + field.getColumn().getColName() + ".sourcecolumns");
+        assert (sourceColumns != null);
+        String[] sources = sourceColumns.split(",");
+        int srcFieldIndex;
+        List<Object> sourceValues = new ArrayList<Object>();
+        for (String source : sources) {
+          srcFieldIndex = getDataFieldIndexByName(source);
+          assert (srcFieldIndex != -1);
+          sourceValues.add(row.getData()[srcFieldIndex]);
+        }
+        return instance.generate(sourceValues);
 
 Review comment:
   Modified accordingly.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to