RussellSpitzer commented on code in PR #10943:
URL: https://github.com/apache/iceberg/pull/10943#discussion_r1720011247
##########
parquet/src/main/java/org/apache/iceberg/parquet/VectorizedParquetReader.java:
##########
@@ -141,8 +148,15 @@ public T next() {
advance();
}
+ long remainingValues = nextRowGroupStart - valuesRead;
+ int remainingLimit = (int) (pushedLimit - valuesRead);
// batchSize is an integer, so casting to integer is safe
- int numValuesToRead = (int) Math.min(nextRowGroupStart - valuesRead,
batchSize);
+ int numValuesToRead =
+ (int)
+ Math.min(
+ remainingValues,
+ (remainingLimit > 0 ? Math.min(batchSize, remainingLimit) :
batchSize));
Review Comment:
may be clearer to keep this in a temporary variable like the above examples.
This is where my main confusion really comes in, because we use values less
than 0 to indicate "unset" we can never just do
Math.min(remaining, Math.min(limit, batchsize)
We always have to first check if "limit" is in our "set" range first. I'm
wondering if it's clearer if we just do
```
If (remainingLimit > 0)
{
Math.min(remainingValues, Math.min(batchsize, reaminingLimit)
} else {
Math.min(remainingValues, batchSize)
}
```
Using the ternary operator is less lines, but a bit more confusing at least
for me. I think maybe this is the pattern we should be using everywhere. Like
in hasNext()
we could jmust have
```java
if (limit > 0) {
return valuesRead < Math.min(batchSize, pushedLimit)
} else {
return valuesRead < batchSize
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]