Github user ravipesala commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1079#discussion_r125154119
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeGrtThanFiterExecuterImpl.java
 ---
    @@ -74,80 +87,205 @@ private void ifDefaultValueMatchesFilter() {
               }
             }
           }
    +    } else if (!msrColEvalutorInfoList.isEmpty() && 
!isMeasurePresentInCurrentBlock[0]) {
    +      CarbonMeasure measure = 
this.msrColEvalutorInfoList.get(0).getMeasure();
    +      byte[] defaultValue = measure.getDefaultValue();
    +      if (null != defaultValue) {
    +        for (int k = 0; k < filterRangeValues.length; k++) {
    +          int maxCompare =
    +              
ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterRangeValues[k], defaultValue);
    +          if (maxCompare < 0) {
    +            isDefaultValuePresentInFilter = true;
    +            break;
    +          }
    +        }
    +      }
         }
       }
     
       @Override public BitSet isScanRequired(byte[][] blockMaxValue, byte[][] 
blockMinValue) {
         BitSet bitSet = new BitSet(1);
    -    boolean isScanRequired =
    -        isScanRequired(blockMaxValue[dimensionBlocksIndex[0]], 
filterRangeValues);
    +    boolean isScanRequired = false;
    +    byte[] maxValue = null;
    +    if (isMeasurePresentInCurrentBlock[0] || 
isDimensionPresentInCurrentBlock[0]) {
    +      if (isMeasurePresentInCurrentBlock[0]) {
    +        maxValue = blockMaxValue[measureBlocksIndex[0] + 
lastDimensionColOrdinal];
    +        isScanRequired =
    +            isScanRequired(maxValue, filterRangeValues, 
msrColEvalutorInfoList.get(0).getType());
    +      } else {
    +        maxValue = blockMaxValue[dimensionBlocksIndex[0]];
    +        isScanRequired = isScanRequired(maxValue, filterRangeValues);
    +      }
    +    } else {
    +      isScanRequired = isDefaultValuePresentInFilter;
    +    }
    +
         if (isScanRequired) {
           bitSet.set(0);
         }
         return bitSet;
       }
     
    +
       private boolean isScanRequired(byte[] blockMaxValue, byte[][] 
filterValues) {
         boolean isScanRequired = false;
    -    if (isDimensionPresentInCurrentBlock[0]) {
    -      for (int k = 0; k < filterValues.length; k++) {
    -        // filter value should be in range of max and min value i.e
    -        // max>filtervalue>min
    -        // so filter-max should be negative
    -        int maxCompare = 
ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMaxValue);
    -        // if any filter value is in range than this block needs to be
    -        // scanned means always less than block max range.
    -        if (maxCompare < 0) {
    -          isScanRequired = true;
    -          break;
    -        }
    +    for (int k = 0; k < filterValues.length; k++) {
    +      // filter value should be in range of max and min value i.e
    +      // max>filtervalue>min
    +      // so filter-max should be negative
    +      int maxCompare = 
ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMaxValue);
    +      // if any filter value is in range than this block needs to be
    +      // scanned less than equal to max range.
    +      if (maxCompare < 0) {
    +        isScanRequired = true;
    +        break;
           }
    -    } else {
    -      isScanRequired = isDefaultValuePresentInFilter;
         }
         return isScanRequired;
       }
     
    +  private boolean isScanRequired(byte[] maxValue, byte[][] filterValue,
    +      DataType dataType) {
    +    for (int i = 0; i < filterValue.length; i++) {
    +      if (filterValue[i].length == 0 || maxValue.length == 0) {
    +        return isScanRequired(maxValue, filterValue);
    +      }
    +      switch (dataType) {
    --- End diff --
    
    Use existing DataTypeUtil  methods and comparator here to compare


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to