Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125153736 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java --- @@ -152,12 +261,31 @@ private BitSet setFilterdIndexToBitSet(DimensionColumnDataChunk dimensionColumnD public BitSet isScanRequired(byte[][] blkMaxVal, byte[][] blkMinVal) { BitSet bitSet = new BitSet(1); - byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys(); - int columnIndex = dimColumnEvaluatorInfo.getColumnIndex(); - int blockIndex = segmentProperties.getDimensionOrdinalToBlockMapping().get(columnIndex); + byte[][] filterValues = null; + int columnIndex = 0; + int blockIndex = 0; + boolean isScanRequired = false; + + if (isDimensionPresentInCurrentBlock == true) { + filterValues = dimColumnExecuterInfo.getFilterKeys(); + columnIndex = dimColumnEvaluatorInfo.getColumnIndex(); + blockIndex = segmentProperties.getDimensionOrdinalToBlockMapping().get(columnIndex); + isScanRequired = + isScanRequired(blkMaxVal[blockIndex], blkMinVal[blockIndex], filterValues); + + } else if (isMeasurePresentInCurrentBlock) { + filterValues = msrColumnExecutorInfo.getFilterKeys(); + columnIndex = msrColumnEvaluatorInfo.getColumnIndex(); + // blockIndex = + // segmentProperties.getDimensionOrdinalToBlockMapping().get(columnIndex) + segmentProperties + // .getLastDimensionColOrdinal(); --- End diff -- remove commented code --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125153772 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/IncludeFilterExecuterImpl.java --- @@ -186,12 +314,60 @@ private boolean isScanRequired(byte[] blkMaxVal, byte[] blkMinVal, byte[][] filt return isScanRequired; } + private boolean isScanRequired(byte[] maxValue, byte[] minValue, byte[][] filterValue, + DataType dataType) { + for (int i = 0; i < filterValue.length; i++) { + if (filterValue[i].length == 0 || maxValue.length == 0 || minValue.length == 0) { + return isScanRequired(maxValue, minValue, filterValue); + } else { + switch (dataType) { --- End diff -- Use existing methods of DataTypeUtil for conversions. And use comparator which is used in applyFilter method here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125153811 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/MeasureColumnExecuterFilterInfo.java --- @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.carbondata.core.scan.filter.executer; + +public class MeasureColumnExecuterFilterInfo { + + byte[][] filterKeys; --- End diff -- Use Object[] --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154090 --- 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); --- End diff -- This comparison in case of measure is wrong. Always compare actual values. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154170 --- 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) { + case DOUBLE: + double maxValueDouble = ByteBuffer.wrap(maxValue).getDouble(); + double filterValueDouble = ByteBuffer.wrap(filterValue[i]).getDouble(); + if (filterValueDouble < maxValueDouble) { + return true; + } + break; + case INT: + case SHORT: + case LONG: + long maxValueLong = ByteBuffer.wrap(maxValue).getLong(); + long filterValueLong = ByteBuffer.wrap(filterValue[i]).getLong(); + if (filterValueLong < maxValueLong) { + return true; + } + break; + case DECIMAL: + BigDecimal maxDecimal = DataTypeUtil.byteToBigDecimal(maxValue); + BigDecimal filterDecimal = DataTypeUtil.byteToBigDecimal(filterValue[i]); + if (filterDecimal.compareTo(maxDecimal) < 0) { + return true; + } + } + } + return false; + } + @Override public BitSetGroup applyFilter(BlocksChunkHolder blockChunkHolder) throws FilterUnsupportedException, IOException { // select all rows if dimension does not exists in the current block - if (!isDimensionPresentInCurrentBlock[0]) { + if (!isDimensionPresentInCurrentBlock[0] && !isMeasurePresentInCurrentBlock[0]) { int numberOfRows = blockChunkHolder.getDataBlock().nodeSize(); return FilterUtil .createBitSetGroupWithDefaultValue(blockChunkHolder.getDataBlock().numberOfPages(), numberOfRows, true); } - int blockIndex = - segmentProperties.getDimensionOrdinalToBlockMapping().get(dimensionBlocksIndex[0]); - if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) { - blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() - .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex); - } - DimensionRawColumnChunk rawColumnChunk = - blockChunkHolder.getDimensionRawDataChunk()[blockIndex]; - BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); - for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { - if (rawColumnChunk.getMaxValues() != null) { - if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues)) { - int compare = ByteUtil.UnsafeComparer.INSTANCE - .compareTo(filterRangeValues[0], rawColumnChunk.getMinValues()[i]); - if (compare < 0) { - BitSet bitSet = new BitSet(rawColumnChunk.getRowCount()[i]); - bitSet.flip(0, rawColumnChunk.getRowCount()[i]); - bitSetGroup.setBitSet(bitSet, i); - } else { - BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), - rawColumnChunk.getRowCount()[i]); - bitSetGroup.setBitSet(bitSet, i); + if (isDimensionPresentInCurrentBlock[0]) { + int blockIndex = + segmentProperties.getDimensionOrdinalToBlockMapping().get(dimensionBlocksIndex[0]); + if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) { + blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() + .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex); + } + DimensionRawColumnChunk rawColumnChunk = + blockChunkHolder.getDimensionRawDataChunk()[blockIndex]; + BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); + for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { + if (rawColumnChunk.getMaxValues() != null) { + if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues)) { + int compare = ByteUtil.UnsafeComparer.INSTANCE + .compareTo(filterRangeValues[0], rawColumnChunk.getMinValues()[i]); + if (compare < 0) { + BitSet bitSet = new BitSet(rawColumnChunk.getRowCount()[i]); + bitSet.flip(0, rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } else { + BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), + rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } } + } else { + BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), + rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } + } + return bitSetGroup; + } else if (isMeasurePresentInCurrentBlock[0]) { + int blockIndex = + segmentProperties.getMeasuresOrdinalToBlockMapping().get(measureBlocksIndex[0]); + if (null == blockChunkHolder.getMeasureRawDataChunk()[blockIndex]) { + blockChunkHolder.getMeasureRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() + .getMeasureChunk(blockChunkHolder.getFileReader(), blockIndex); + } + MeasureRawColumnChunk rawColumnChunk = blockChunkHolder.getMeasureRawDataChunk()[blockIndex]; + BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); + for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { + if (rawColumnChunk.getMaxValues() != null) { + if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues, + msrColEvalutorInfoList.get(0).getType())) { + int compare = ByteUtil.UnsafeComparer.INSTANCE --- End diff -- This binary comparison cannot be used for measures, compare actual values --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154219 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java --- @@ -91,67 +131,167 @@ private void ifDefaultValueMatchesFilter() { 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 less than equal to 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 methods of `DataTypeUtil` and comparator here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154226 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeGrtrThanEquaToFilterExecuterImpl.java --- @@ -91,67 +131,167 @@ private void ifDefaultValueMatchesFilter() { 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 less than equal to 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) { + case DOUBLE: + double maxValueDouble = ByteBuffer.wrap(maxValue).getDouble(); + double filterValueDouble = ByteBuffer.wrap(filterValue[i]).getDouble(); + if (filterValueDouble <= maxValueDouble) { + return true; + } + break; + case INT: + case SHORT: + case LONG: + long maxValueLong = ByteBuffer.wrap(maxValue).getLong(); + long filterValueLong = ByteBuffer.wrap(filterValue[i]).getLong(); + if (filterValueLong <= maxValueLong) { + return true; + } + break; + case DECIMAL: + BigDecimal maxDecimal = DataTypeUtil.byteToBigDecimal(maxValue); + BigDecimal filterDecimal = DataTypeUtil.byteToBigDecimal(filterValue[i]); + if (filterDecimal.compareTo(maxDecimal) <= 0) { + return true; + } + } + } + return false; + } + @Override public BitSetGroup applyFilter(BlocksChunkHolder blockChunkHolder) throws FilterUnsupportedException, IOException { // select all rows if dimension does not exists in the current block - if (!isDimensionPresentInCurrentBlock[0]) { + if (!isDimensionPresentInCurrentBlock[0] && !isMeasurePresentInCurrentBlock[0]) { int numberOfRows = blockChunkHolder.getDataBlock().nodeSize(); return FilterUtil .createBitSetGroupWithDefaultValue(blockChunkHolder.getDataBlock().numberOfPages(), numberOfRows, true); } - int blockIndex = - segmentProperties.getDimensionOrdinalToBlockMapping().get(dimensionBlocksIndex[0]); - if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) { - blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() - .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex); - } - DimensionRawColumnChunk rawColumnChunk = - blockChunkHolder.getDimensionRawDataChunk()[blockIndex]; - BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); - for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { - if (rawColumnChunk.getMaxValues() != null) { - if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues)) { - int compare = ByteUtil.UnsafeComparer.INSTANCE - .compareTo(filterRangeValues[0], rawColumnChunk.getMinValues()[i]); - if (compare <= 0) { - BitSet bitSet = new BitSet(rawColumnChunk.getRowCount()[i]); - bitSet.flip(0, rawColumnChunk.getRowCount()[i]); - bitSetGroup.setBitSet(bitSet, i); - } else { - BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), - rawColumnChunk.getRowCount()[i]); - bitSetGroup.setBitSet(bitSet, i); + + if (isDimensionPresentInCurrentBlock[0]) { + int blockIndex = + segmentProperties.getDimensionOrdinalToBlockMapping().get(dimensionBlocksIndex[0]); + if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) { + blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() + .getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex); + } + DimensionRawColumnChunk rawColumnChunk = + blockChunkHolder.getDimensionRawDataChunk()[blockIndex]; + BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); + for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { + if (rawColumnChunk.getMaxValues() != null) { + if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues)) { + int compare = ByteUtil.UnsafeComparer.INSTANCE + .compareTo(filterRangeValues[0], rawColumnChunk.getMinValues()[i]); + if (compare <= 0) { + BitSet bitSet = new BitSet(rawColumnChunk.getRowCount()[i]); + bitSet.flip(0, rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } else { + BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), + rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } } + } else { + BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), + rawColumnChunk.getRowCount()[i]); + bitSetGroup.setBitSet(bitSet, i); + } + } + return bitSetGroup; + } else if (isMeasurePresentInCurrentBlock[0]) { + int blockIndex = + segmentProperties.getMeasuresOrdinalToBlockMapping().get(measureBlocksIndex[0]); + if (null == blockChunkHolder.getMeasureRawDataChunk()[blockIndex]) { + blockChunkHolder.getMeasureRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock() + .getMeasureChunk(blockChunkHolder.getFileReader(), blockIndex); + } + MeasureRawColumnChunk rawColumnChunk = blockChunkHolder.getMeasureRawDataChunk()[blockIndex]; + BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount()); + for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) { + if (rawColumnChunk.getMaxValues() != null) { + if (isScanRequired(rawColumnChunk.getMaxValues()[i], this.filterRangeValues, + msrColEvalutorInfoList.get(0).getType())) { + int compare = ByteUtil.UnsafeComparer.INSTANCE --- End diff -- Binary comparison cannot be used here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154233 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanEqualFilterExecuterImpl.java --- @@ -91,57 +129,147 @@ private void ifDefaultValueMatchesFilter() { private boolean isScanRequired(byte[] blockMinValue, byte[][] filterValues) { boolean isScanRequired = false; - if (isDimensionPresentInCurrentBlock[0]) { - for (int k = 0; k < filterValues.length; k++) { - // and filter-min should be positive - int minCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMinValue); + for (int k = 0; k < filterValues.length; k++) { + // and filter-min should be positive + int minCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMinValue); - // if any filter applied is not in range of min and max of block - // then since its a less than equal to fiter validate whether the block - // min range is less than equal to applied filter member - if (minCompare >= 0) { - isScanRequired = true; - break; - } + // if any filter applied is not in range of min and max of block + // then since its a less than equal to fiter validate whether the block + // min range is less than equal to applied filter member + if (minCompare >= 0) { + isScanRequired = true; + break; } - } else { - isScanRequired = isDefaultValuePresentInFilter; } return isScanRequired; } + private boolean isScanRequired(byte[] minValue, byte[][] filterValue, + DataType dataType) { + for (int i = 0; i < filterValue.length; i++) { + if (filterValue[i].length == 0 || minValue.length == 0) { + return isScanRequired(minValue, filterValue); + } + switch (dataType) { --- End diff -- Use existing methods of `DataTypeUtil` and comparator here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154256 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java --- @@ -77,72 +89,188 @@ 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); --- End diff -- Cannot use binary comparison here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154262 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RowLevelRangeLessThanFiterExecuterImpl.java --- @@ -77,72 +89,188 @@ 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(blockMinValue[dimensionBlocksIndex[0]], filterRangeValues); + byte[] minValue = null; + boolean isScanRequired = false; + if (isMeasurePresentInCurrentBlock[0] || isDimensionPresentInCurrentBlock[0]) { + if (isMeasurePresentInCurrentBlock[0]) { + minValue = blockMinValue[measureBlocksIndex[0] + lastDimensionColOrdinal]; + isScanRequired = + isScanRequired(minValue, filterRangeValues, msrColEvalutorInfoList.get(0).getType()); + } else { + minValue = blockMinValue[dimensionBlocksIndex[0]]; + isScanRequired = isScanRequired(minValue, filterRangeValues); + } + } else { + isScanRequired = isDefaultValuePresentInFilter; + } if (isScanRequired) { bitSet.set(0); } return bitSet; } + private boolean isScanRequired(byte[] blockMinValue, byte[][] filterValues) { boolean isScanRequired = false; - if (isDimensionPresentInCurrentBlock[0]) { - for (int k = 0; k < filterValues.length; k++) { - // and filter-min should be positive - int minCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMinValue); + for (int k = 0; k < filterValues.length; k++) { + // and filter-min should be positive + int minCompare = ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterValues[k], blockMinValue); - // if any filter applied is not in range of min and max of block - // then since its a less than fiter validate whether the block - // min range is less than applied filter member - if (minCompare > 0) { - isScanRequired = true; - break; - } + // if any filter applied is not in range of min and max of block + // then since its a less than equal to fiter validate whether the block + // min range is less than equal to applied filter member + if (minCompare > 0) { + isScanRequired = true; + break; } - } else { - isScanRequired = isDefaultValuePresentInFilter; } return isScanRequired; } + private boolean isScanRequired(byte[] minValue, byte[][] filterValue, + DataType dataType) { + for (int i = 0; i < filterValue.length; i++) { + if (filterValue[i].length == 0 || minValue.length == 0) { + return isScanRequired(minValue, filterValue); + } + switch (dataType) { --- End diff -- Use existing methods of `DataTypeUtil` and comparator here --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154292 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java --- @@ -76,24 +99,25 @@ public static Comparator getComparatorByDataType(DataType dataType) { static class DoubleComparator implements Comparator<Object> { @Override public int compare(Object key1, Object key2) { - double result = (double) key1 - (double) key2; - if (result < 0) { + double key1Double1 = (double)key1; --- End diff -- Why need to change this logic? old logic seems fine right --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154321 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java --- @@ -107,6 +131,12 @@ public static Comparator getComparatorByDataType(DataType dataType) { } } + static class DecimalComparator implements Comparator<Object> { --- End diff -- what is the use of this comparator? Please remove if not used --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154337 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java --- @@ -44,16 +44,22 @@ protected boolean isExpressionResolve; protected boolean isIncludeFilter; private DimColumnResolvedFilterInfo dimColResolvedFilterInfo; + private MeasureColumnResolvedFilterInfo msrColResolvedFilterInfo; private AbsoluteTableIdentifier tableIdentifier; + private boolean isMeasure; --- End diff -- it is not used anywhere, please remove --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125154345 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/resolver/ConditionalFilterResolverImpl.java --- @@ -198,21 +237,31 @@ public AbsoluteTableIdentifier getTableIdentifier() { */ public void getStartKey(SegmentProperties segmentProperties, long[] startKey, SortedMap<Integer, byte[]> setOfStartKeyByteArray, List<long[]> startKeyList) { - FilterUtil.getStartKey(dimColResolvedFilterInfo.getDimensionResolvedFilterInstance(), - segmentProperties, startKey, startKeyList); - FilterUtil.getStartKeyForNoDictionaryDimension(dimColResolvedFilterInfo, - segmentProperties, setOfStartKeyByteArray); + if (null != dimColResolvedFilterInfo) { + FilterUtil.getStartKey(dimColResolvedFilterInfo.getDimensionResolvedFilterInstance(), + segmentProperties, startKey, startKeyList); + FilterUtil.getStartKeyForNoDictionaryDimension(dimColResolvedFilterInfo, segmentProperties, + setOfStartKeyByteArray); + } +// else { +// FilterUtil.getStartKey(dimColResolvedFilterInfo.getDimensionResolvedFilterInstance(), +// segmentProperties, startKey, startKeyList); +// FilterUtil.getStartKeyForNoDictionaryDimension(dimColResolvedFilterInfo, segmentProperties, +// setOfStartKeyByteArray); +// } --- End diff -- remove commented code --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125190753 --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/page/statistics/ColumnPageStatsVO.java --- @@ -56,9 +65,7 @@ public ColumnPageStatsVO(DataType dataType) { nonExistValue = Double.MIN_VALUE; break; case DECIMAL: - max = new BigDecimal(Double.MIN_VALUE); - min = new BigDecimal(Double.MAX_VALUE); - nonExistValue = new BigDecimal(Double.MIN_VALUE); + this.zeroDecimal = new BigDecimal(0); --- End diff -- Done --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125190787 --- Diff: core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java --- @@ -137,6 +137,8 @@ */ private int numberOfNoDictSortColumns; + private int lastDimensionColumnOrdinal; --- End diff -- Removed. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125190813 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/expression/ColumnExpression.java --- @@ -31,12 +32,16 @@ private boolean isDimension; + private boolean isMeasure; --- End diff -- Just kept it in order to be in sync with dimension implementation. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125190853 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java --- @@ -180,9 +185,27 @@ private static FilterExecuter createFilterExecuterTree( * @return */ private static FilterExecuter getIncludeFilterExecuter( - DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties) { - - if (dimColResolvedFilterInfo.getDimension().isColumnar()) { + DimColumnResolvedFilterInfo dimColResolvedFilterInfo, + MeasureColumnResolvedFilterInfo msrColResolvedFilterInfo, + SegmentProperties segmentProperties) { + if (null != msrColResolvedFilterInfo && msrColResolvedFilterInfo.getMeasure().isColumnar()) { --- End diff -- Done. Removed. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
In reply to this post by qiuchenjian-2
Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1079#discussion_r125190884 --- Diff: core/src/main/java/org/apache/carbondata/core/scan/filter/FilterUtil.java --- @@ -180,9 +185,27 @@ private static FilterExecuter createFilterExecuterTree( * @return */ private static FilterExecuter getIncludeFilterExecuter( - DimColumnResolvedFilterInfo dimColResolvedFilterInfo, SegmentProperties segmentProperties) { - - if (dimColResolvedFilterInfo.getDimension().isColumnar()) { + DimColumnResolvedFilterInfo dimColResolvedFilterInfo, + MeasureColumnResolvedFilterInfo msrColResolvedFilterInfo, + SegmentProperties segmentProperties) { + if (null != msrColResolvedFilterInfo && msrColResolvedFilterInfo.getMeasure().isColumnar()) { + CarbonMeasure measuresFromCurrentBlock = segmentProperties + .getMeasureFromCurrentBlock(msrColResolvedFilterInfo.getMeasure().getColumnId()); + if (null != measuresFromCurrentBlock) { + // update dimension and column index according to the dimension position in current block + MeasureColumnResolvedFilterInfo msrColResolvedFilterInfoCopyObject = + msrColResolvedFilterInfo.getCopyObject(); + msrColResolvedFilterInfoCopyObject.setMeasure(measuresFromCurrentBlock); + msrColResolvedFilterInfoCopyObject.setColumnIndex(measuresFromCurrentBlock.getOrdinal()); + msrColResolvedFilterInfoCopyObject.setType(measuresFromCurrentBlock.getDataType()); + return new IncludeFilterExecuterImpl(null, msrColResolvedFilterInfoCopyObject, + segmentProperties, true); + } else { + return new RestructureIncludeFilterExecutorImpl(dimColResolvedFilterInfo, + msrColResolvedFilterInfo, segmentProperties, true); + } + } --- End diff -- No, This whole block belongs to Measure. Line 220 points to Restructure in case of dimentions. --- 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 [hidden email] or file a JIRA ticket with INFRA. --- |
Free forum by Nabble | Edit this page |