Skip to content

Commit

Permalink
Fix checkstyle violation and limit the prefix inc/dec check in for lo…
Browse files Browse the repository at this point in the history
…ok (#7451)
  • Loading branch information
Jackie-Jiang authored Sep 18, 2021
1 parent 31ca84e commit 0069fc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
8 changes: 5 additions & 3 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@
<module name="StringLiteralEquality"/>
<!-- Use 'L' with long literals -->
<module name="UpperEll"/>
<!-- ban prefix increment, decrement -->
<module name="IllegalToken">
<property name="tokens" value="INC,DEC"/>
<!-- Do not use prefix increment, decrement in for loop iterator -->
<module name="DescendantToken">
<property name="tokens" value="FOR_ITERATOR"/>
<property name="limitedTokens" value="INC,DEC"/>
<property name="maximumNumber" value="0"/>
</module>

<!-- IMPORTS -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import org.testng.annotations.Test;

import static org.apache.pinot.segment.spi.V1Constants.Indexes.BITMAP_RANGE_INDEX_FILE_EXTENSION;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;


public class RangeIndexCreatorTest {
Expand Down Expand Up @@ -243,7 +245,7 @@ private void addDataToIndexer(DataType dataType, int numDocs, int numValuesPerEn
}

private void verifyRangesForDataType(DataType dataType, Object values, Object ranges, int numValuesPerMVEntry,
RangeIndexReader<ImmutableRoaringBitmap> rangeIndexReader) {
RangeIndexReader<ImmutableRoaringBitmap> rangeIndexReader) {
switch (dataType) {
case INT: {
// single bucket ranges
Expand All @@ -256,14 +258,14 @@ private void verifyRangesForDataType(DataType dataType, Object values, Object ra
for (int docId : partialMatches.toArray()) {
checkValueForDocId(dataType, values, ranges, rangeId, docId, numValuesPerMVEntry);
}
++rangeId;
rangeId++;
}
// multi bucket ranges
int[] lowerPartialRange = ((int[][]) ranges)[0];
int[] coveredRange = ((int[][]) ranges)[1];
int[] upperPartialRange = ((int[][]) ranges)[2];
ImmutableRoaringBitmap matches = rangeIndexReader.getMatchingDocIds(lowerPartialRange[0], upperPartialRange[1]);
assertNotNull(matches, "matches for covered range must not be null");
assertNotNull(matches, "matches for covered range must not be null");
for (int docId : matches.toArray()) {
checkValueForDocId(dataType, values, ranges, 1, docId, numValuesPerMVEntry);
}
Expand Down Expand Up @@ -298,14 +300,14 @@ private void verifyRangesForDataType(DataType dataType, Object values, Object ra
for (int docId : partialMatches.toArray()) {
checkValueForDocId(dataType, values, ranges, rangeId, docId, numValuesPerMVEntry);
}
++rangeId;
rangeId++;
}
// multi bucket ranges
long[] lowerPartialRange = ((long[][]) ranges)[0];
long[] coveredRange = ((long[][]) ranges)[1];
long[] upperPartialRange = ((long[][]) ranges)[2];
ImmutableRoaringBitmap matches = rangeIndexReader.getMatchingDocIds(lowerPartialRange[0], upperPartialRange[1]);
assertNotNull(matches, "matches for covered range must not be null");
assertNotNull(matches, "matches for covered range must not be null");
for (int docId : matches.toArray()) {
checkValueForDocId(dataType, values, ranges, 1, docId, numValuesPerMVEntry);
}
Expand Down Expand Up @@ -340,14 +342,14 @@ private void verifyRangesForDataType(DataType dataType, Object values, Object ra
for (int docId : partialMatches.toArray()) {
checkValueForDocId(dataType, values, ranges, rangeId, docId, numValuesPerMVEntry);
}
++rangeId;
rangeId++;
}
// multi bucket ranges
float[] lowerPartialRange = ((float[][]) ranges)[0];
float[] coveredRange = ((float[][]) ranges)[1];
float[] upperPartialRange = ((float[][]) ranges)[2];
ImmutableRoaringBitmap matches = rangeIndexReader.getMatchingDocIds(lowerPartialRange[0], upperPartialRange[1]);
assertNotNull(matches, "matches for covered range must not be null");
assertNotNull(matches, "matches for covered range must not be null");
for (int docId : matches.toArray()) {
checkValueForDocId(dataType, values, ranges, 1, docId, numValuesPerMVEntry);
}
Expand Down Expand Up @@ -382,14 +384,14 @@ private void verifyRangesForDataType(DataType dataType, Object values, Object ra
for (int docId : partialMatches.toArray()) {
checkValueForDocId(dataType, values, ranges, rangeId, docId, numValuesPerMVEntry);
}
++rangeId;
rangeId++;
}
// multi bucket ranges
double[] lowerPartialRange = ((double[][]) ranges)[0];
double[] coveredRange = ((double[][]) ranges)[1];
double[] upperPartialRange = ((double[][]) ranges)[2];
ImmutableRoaringBitmap matches = rangeIndexReader.getMatchingDocIds(lowerPartialRange[0], upperPartialRange[1]);
assertNotNull(matches, "matches for covered range must not be null");
assertNotNull(matches, "matches for covered range must not be null");
for (int docId : matches.toArray()) {
checkValueForDocId(dataType, values, ranges, 1, docId, numValuesPerMVEntry);
}
Expand Down Expand Up @@ -516,7 +518,6 @@ private void checkDoubleMV(double[][] ranges, int rangeId, double[] values, int
Assert.fail();
}


private static Object valuesArray(DataType dataType, int numValues) {
switch (dataType) {
case INT:
Expand All @@ -539,7 +540,7 @@ private static Object splitIntoRanges(DataType dataType, Object values, int numV
int[] sorted = Arrays.copyOf(ints, ints.length);
Arrays.sort(sorted);
int[][] split = new int[ints.length / numValuesPerRange + 1][2];
for (int i = 0; i < split.length - 1; ++i) {
for (int i = 0; i < split.length - 1; i++) {
split[i][0] = sorted[i * numValuesPerRange];
split[i][1] = sorted[(i + 1) * numValuesPerRange - 1];
}
Expand All @@ -552,7 +553,7 @@ private static Object splitIntoRanges(DataType dataType, Object values, int numV
long[] sorted = Arrays.copyOf(longs, longs.length);
Arrays.sort(sorted);
long[][] split = new long[longs.length / numValuesPerRange + 1][2];
for (int i = 0; i < split.length - 1; ++i) {
for (int i = 0; i < split.length - 1; i++) {
split[i][0] = sorted[i * numValuesPerRange];
split[i][1] = sorted[(i + 1) * numValuesPerRange - 1];
}
Expand All @@ -565,7 +566,7 @@ private static Object splitIntoRanges(DataType dataType, Object values, int numV
float[] sorted = Arrays.copyOf(floats, floats.length);
Arrays.sort(sorted);
float[][] split = new float[floats.length / numValuesPerRange + 1][2];
for (int i = 0; i < split.length - 1; ++i) {
for (int i = 0; i < split.length - 1; i++) {
split[i][0] = sorted[i * numValuesPerRange];
split[i][1] = sorted[(i + 1) * numValuesPerRange - 1];
}
Expand All @@ -578,7 +579,7 @@ private static Object splitIntoRanges(DataType dataType, Object values, int numV
double[] sorted = Arrays.copyOf(doubles, doubles.length);
Arrays.sort(sorted);
double[][] split = new double[doubles.length / numValuesPerRange + 1][2];
for (int i = 0; i < split.length - 1; ++i) {
for (int i = 0; i < split.length - 1; i++) {
split[i][0] = sorted[i * numValuesPerRange];
split[i][1] = sorted[(i + 1) * numValuesPerRange - 1];
}
Expand Down

0 comments on commit 0069fc3

Please sign in to comment.