Login  Register

[GitHub] [carbondata] ajantha-bhat commented on a change in pull request #4073: [CARBONDATA-4104] Vector filling for complex decimal type needs to be handled

Posted by GitBox on Jan 29, 2021; 6:01am
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-akkio-97-opened-a-new-pull-request-4073-WIP-tp105327p105764.html


ajantha-bhat commented on a change in pull request #4073:
URL: https://github.com/apache/carbondata/pull/4073#discussion_r566597101



##########
File path: core/src/main/java/org/apache/carbondata/core/metadata/datatype/DecimalConverterFactory.java
##########
@@ -109,29 +113,35 @@ public BigDecimal getDecimal(Object valueToBeConverted) {
       return BigDecimal.valueOf((Long) valueToBeConverted, scale);
     }
 
+    private void initializeValues(int size, CarbonColumnVector vector,
+        ColumnVectorInfo vectorInfo) {
+      if (vectorInfo.measure == null) {
+        DecimalType decimalType = (DecimalType) vector.getType();
+        // complex primitive decimal flow comes as dimension
+        this.precision = decimalType.getPrecision();
+        this.newMeasureScale = decimalType.getScale();
+        this.updatedSize = ColumnVectorInfo.getUpdatedPageSizeForChildVector(vectorInfo, size);
+      } else {
+        CarbonMeasure carbonMeasure = vectorInfo.measure.getMeasure();
+        this.precision = carbonMeasure.getPrecision();
+        this.newMeasureScale = carbonMeasure.getScale();
+      }
+    }
+
     @Override
     public void fillVector(Object valuesToBeConverted, int size,
         ColumnVectorInfo vectorInfo, BitSet nullBitSet, DataType pageType) {
-      if (!(valuesToBeConverted instanceof byte[])) {
-        throw new UnsupportedOperationException("This object type " + valuesToBeConverted.getClass()
-            + " is not supported in this method");
-      }
       // TODO we need to find way to directly set to vector with out conversion. This way is very
       // inefficient.
       CarbonColumnVector vector = getCarbonColumnVector(vectorInfo, nullBitSet);
-      int precision;
-      int newMeasureScale;
-      if (vectorInfo.measure == null) {
-        // complex primitive decimal flow comes as dimension
-        precision = ((DecimalType) vector.getType()).getPrecision();
-        newMeasureScale = ((DecimalType) vector.getType()).getScale();
-        size = ColumnVectorInfo.getUpdatedPageSizeForChildVector(vectorInfo, size);
-      } else {
-        precision = vectorInfo.measure.getMeasure().getPrecision();
-        newMeasureScale = vectorInfo.measure.getMeasure().getScale();
+      initializeValues(size, vector, vectorInfo);

Review comment:
       If used only once, no need to extract common code.




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