xubo245 commented on a change in pull request #3188: [CARBONDATA-3358] Support 
configurable decode for loading binary data, support base64 and Hex decode.
URL: https://github.com/apache/carbondata/pull/3188#discussion_r285924265
 
 

 ##########
 File path: 
processing/src/main/java/org/apache/carbondata/processing/loading/converter/impl/BinaryFieldConverterImpl.java
 ##########
 @@ -43,33 +47,57 @@
   private String nullformat;
   private boolean isEmptyBadRecord;
   private DataField dataField;
+  private String  binaryEncoder;
   public BinaryFieldConverterImpl(DataField dataField, String nullformat, int 
index,
-      boolean isEmptyBadRecord) {
+      boolean isEmptyBadRecord,String binaryEncoder) {
     this.dataType = dataField.getColumn().getDataType();
     this.dimension = (CarbonDimension) dataField.getColumn();
     this.nullformat = nullformat;
     this.index = index;
     this.isEmptyBadRecord = isEmptyBadRecord;
     this.dataField = dataField;
+    this.binaryEncoder = binaryEncoder;
   }
 
   @Override
   public void convert(CarbonRow row, BadRecordLogHolder logHolder)
       throws CarbonDataLoadingException {
-    if (row.getObject(index) instanceof String) {
-      row.update((((String) row.getObject(index)))
-          .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)), 
index);
-    } else if (row.getObject(index) instanceof byte[]) {
-      row.update(row.getObject(index), index);
-    } else {
-      throw new CarbonDataLoadingException("Binary only support String and 
byte[] data type");
-    }
+    row.update(convert(row.getObject(index), logHolder), index);
   }
 
   @Override
   public Object convert(Object value, BadRecordLogHolder logHolder)
       throws RuntimeException {
-    return null;
+    if (value instanceof String) {
+      if (binaryEncoder.equalsIgnoreCase(
 
 Review comment:
   Why  checking for type will be expansive operation?  there are many check in 
org.apache.carbondata.processing.loading.converter.impl.MeasureFieldConverterImpl#convert(java.lang.Object,
 org.apache.carbondata.processing.loading.converter.BadRecordLogHolder) too

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to