[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3182: [CARBONDATA-3343] Compaction for Range Sort

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [carbondata] manishnalla1994 commented on a change in pull request #3182: [CARBONDATA-3343] Compaction for Range Sort

GitBox
manishnalla1994 commented on a change in pull request #3182: [CARBONDATA-3343] Compaction for Range Sort
URL: https://github.com/apache/carbondata/pull/3182#discussion_r277979543
 
 

 ##########
 File path: processing/src/main/java/org/apache/carbondata/processing/merger/CarbonCompactionUtil.java
 ##########
 @@ -460,6 +473,71 @@ public static boolean isRestructured(List<DataFileFooter> listMetadata,
     return false;
   }
 
+  public static RangeValues[] getRangesFromVals(Object[] tempRanges, Object[] startAndEnd) {
+    RangeValues[] ranges = new RangeValues[tempRanges.length + 1];
+    Object lastStart = startAndEnd[0];
+    for (int i = 0; i < tempRanges.length; i++) {
+      ranges[i] = new RangeValues(lastStart, tempRanges[i]);
+      lastStart = tempRanges[i];
+    }
+    ranges[tempRanges.length] = new RangeValues(lastStart, startAndEnd[1]);
+    return ranges;
+  }
+
+  public static Expression getAndExpressionForRange(String colName, int taskId, byte[] minVal,
+      byte[] maxVal, DataType dataType) {
+    Expression finalExpr;
+    Expression exp1, exp2;
+    Object currMinVal = null, currMaxVal = null;
+    if (dataType == DataTypes.STRING) {
+      if (null != minVal) {
+        currMinVal = ByteUtil.toString(minVal, 0, minVal.length);
+      }
+      currMaxVal = ByteUtil.toString(maxVal, 0, maxVal.length);
+    } else if (dataType == DataTypes.SHORT) {
+      if (null != minVal) {
+        currMinVal = Short.valueOf(ByteUtil.toShort(minVal, 0, minVal.length));
+      }
+      currMaxVal = Short.valueOf(ByteUtil.toShort(maxVal, 0, maxVal.length));
+    } else if (dataType == DataTypes.INT || dataType == DataTypes.DATE) {
+      if (null != minVal) {
+        currMinVal = Integer.valueOf(ByteUtil.toInt(minVal, 0, minVal.length));
+      }
+      currMaxVal = Integer.valueOf(ByteUtil.toInt(maxVal, 0, maxVal.length));
+    } else if (dataType == DataTypes.LONG || dataType == DataTypes.TIMESTAMP) {
+      if (null != minVal) {
+        currMinVal = Long.valueOf(ByteUtil.toLong(minVal, 0, minVal.length));
+      }
+      currMaxVal = Long.valueOf(ByteUtil.toLong(maxVal, 0, maxVal.length));
+    } else if (dataType == DataTypes.DOUBLE) {
+      if (null != minVal) {
+        currMinVal = Double.valueOf(ByteUtil.toDouble(minVal, 0, minVal.length));
+      }
+      currMaxVal = Double.valueOf(ByteUtil.toDouble(maxVal, 0, maxVal.length));
+    }
+    // In case of null values create an OrFilter expression and
+    // for other cases create and AndFilter Expression
+    if (null == currMinVal) {
+      exp1 = new EqualToExpression(new ColumnExpression(colName, dataType),
+          new LiteralExpression(null, dataType), true);
+      exp2 = new LessThanEqualToExpression(new ColumnExpression(colName, dataType),
+          new LiteralExpression(currMaxVal, dataType));
+      finalExpr = new OrExpression(exp1, exp2);
+    } else {
+      if (0 == taskId) {
 
 Review comment:
   Yes the partitioner gives the upper bounds of ranges in sorted order only

----------------------------------------------------------------
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]


With regards,
Apache Git Services