Skip to content

Commit

Permalink
simplified logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cxzl25 committed Jul 10, 2024
1 parent 8ec24ec commit d49d315
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 43 deletions.
40 changes: 0 additions & 40 deletions java/core/src/java/org/apache/orc/impl/TreeReaderFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1551,8 +1551,6 @@ private void nextVector(DecimalColumnVector result,
HiveDecimalWritable[] vector = result.vector;
HiveDecimalWritable decWritable;
if (result.noNulls) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
for (int r = 0; r < batchSize; ++r) {
decWritable = vector[r];
if (!decWritable.serializationUtilsRead(
Expand All @@ -1563,12 +1561,7 @@ private void nextVector(DecimalColumnVector result,
}
setIsRepeatingIfNeeded(result, r);
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
} else if (!result.isRepeating || !result.isNull[0]) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
for (int r = 0; r < batchSize; ++r) {
if (!result.isNull[r]) {
decWritable = vector[r];
Expand All @@ -1581,9 +1574,6 @@ private void nextVector(DecimalColumnVector result,
}
setIsRepeatingIfNeeded(result, r);
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
}
}

Expand All @@ -1603,8 +1593,6 @@ private void nextVector(DecimalColumnVector result,
HiveDecimalWritable[] vector = result.vector;
HiveDecimalWritable decWritable;
if (result.noNulls) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
int previousIdx = 0;
for (int r = 0; r != filterContext.getSelectedSize(); ++r) {
int idx = filterContext.getSelected()[r];
Expand All @@ -1621,13 +1609,8 @@ private void nextVector(DecimalColumnVector result,
setIsRepeatingIfNeeded(result, idx);
previousIdx = idx + 1;
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
skipStreamRows(batchSize - previousIdx);
} else if (!result.isRepeating || !result.isNull[0]) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
int previousIdx = 0;
for (int r = 0; r != filterContext.getSelectedSize(); ++r) {
int idx = filterContext.getSelected()[r];
Expand All @@ -1646,9 +1629,6 @@ private void nextVector(DecimalColumnVector result,
setIsRepeatingIfNeeded(result, idx);
previousIdx = idx + 1;
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
skipStreamRows(countNonNullRowsInRange(result.isNull, previousIdx, batchSize));
}
}
Expand All @@ -1667,29 +1647,19 @@ private void nextVector(Decimal64ColumnVector result,
// read the scales
scaleReader.nextVector(result, scratchScaleVector, batchSize);
if (result.noNulls) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
for (int r = 0; r < batchSize; ++r) {
final long scaleFactor = powerOfTenTable[scale - scratchScaleVector[r]];
result.vector[r] = SerializationUtils.readVslong(valueStream) * scaleFactor;
setIsRepeatingIfNeeded(result, r);
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
} else if (!result.isRepeating || !result.isNull[0]) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
for (int r = 0; r < batchSize; ++r) {
if (!result.isNull[r]) {
final long scaleFactor = powerOfTenTable[scale - scratchScaleVector[r]];
result.vector[r] = SerializationUtils.readVslong(valueStream) * scaleFactor;
}
setIsRepeatingIfNeeded(result, r);
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
}
result.precision = (short) precision;
result.scale = (short) scale;
Expand All @@ -1710,8 +1680,6 @@ private void nextVector(Decimal64ColumnVector result,
// Read all the scales
scaleReader.nextVector(result, scratchScaleVector, batchSize);
if (result.noNulls) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
int previousIdx = 0;
for (int r = 0; r != filterContext.getSelectedSize(); r++) {
int idx = filterContext.getSelected()[r];
Expand All @@ -1725,13 +1693,8 @@ private void nextVector(Decimal64ColumnVector result,
setIsRepeatingIfNeeded(result, idx);
previousIdx = idx + 1;
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
skipStreamRows(batchSize - previousIdx);
} else if (!result.isRepeating || !result.isNull[0]) {
boolean preIsRepeating = result.isRepeating;
result.isRepeating = true;
int previousIdx = 0;
for (int r = 0; r != filterContext.getSelectedSize(); r++) {
int idx = filterContext.getSelected()[r];
Expand All @@ -1747,9 +1710,6 @@ private void nextVector(Decimal64ColumnVector result,
setIsRepeatingIfNeeded(result, idx);
previousIdx = idx + 1;
}
if (!preIsRepeating && result.isRepeating) {
result.isRepeating = preIsRepeating;
}
skipStreamRows(countNonNullRowsInRange(result.isNull, previousIdx, batchSize));
}
result.precision = (short) precision;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ private void readDecimalInNullStripe(String typeString, Class<?> expectedColumnT
assertTrue(batch.cols[0].isRepeating);
StringBuilder sb = new StringBuilder();
batch.cols[0].stringifyValue(sb, 1023);
assertEquals(sb.toString(), expectedResult[0]);
assertEquals(expectedResult[0], sb.toString());

rows.nextBatch(batch);
assertEquals(1024, batch.size);
Expand All @@ -717,7 +717,7 @@ private void readDecimalInNullStripe(String typeString, Class<?> expectedColumnT
assertFalse(batch.cols[0].isRepeating);
StringBuilder sb2 = new StringBuilder();
batch.cols[0].stringifyValue(sb2, 1023);
assertEquals(sb2.toString(), expectedResult[1]);
assertEquals(expectedResult[1], sb2.toString());

rows.nextBatch(batch);
assertEquals(1024, batch.size);
Expand All @@ -727,7 +727,7 @@ private void readDecimalInNullStripe(String typeString, Class<?> expectedColumnT
assertFalse(batch.cols[0].isRepeating);
StringBuilder sb3 = new StringBuilder();
batch.cols[0].stringifyValue(sb3, 1023);
assertEquals(sb3.toString(), expectedResult[2]);
assertEquals(expectedResult[2], sb3.toString());
}

private void testDecimalConvertToLongInNullStripe() throws Exception {
Expand Down

0 comments on commit d49d315

Please sign in to comment.