Github user omalley commented on a diff in the pull request:
https://github.com/apache/orc/pull/299#discussion_r208393137
--- Diff: java/core/src/java/org/apache/orc/impl/ColumnStatisticsImpl.java
---
@@ -543,35 +551,73 @@ public void reset() {
super.reset();
minimum = null;
maximum = null;
+ isLowerBoundSet = false;
+ isUpperBoundSet = false;
sum = 0;
}
@Override
public void updateString(Text value) {
if (minimum == null) {
- maximum = minimum = new Text(value);
+ if(value.getLength() > MAX_BYTES_RECORDED) {
+ minimum = truncateLowerBound(value);
+ maximum = truncateUpperBound(value);
+ isLowerBoundSet = true;
+ isUpperBoundSet = true;
+ } else {
+ maximum = minimum = new Text(value);
+ }
} else if (minimum.compareTo(value) > 0) {
- minimum = new Text(value);
+ if(value.getLength() > MAX_BYTES_RECORDED) {
+ minimum = truncateLowerBound(value);
+ isLowerBoundSet = true;
+ }else {
+ minimum = new Text(value);
+ }
} else if (maximum.compareTo(value) < 0) {
- maximum = new Text(value);
+ if(value.getLength() > MAX_BYTES_RECORDED) {
+ maximum = truncateUpperBound(value);
+ isUpperBoundSet = true;
+ } else {
+ maximum = new Text(value);
+ }
}
sum += value.getLength();
}
+
@Override
public void updateString(byte[] bytes, int offset, int length,
int repetitions) {
+ byte[] input = Arrays.copyOfRange(bytes, offset, offset+(length));
--- End diff --
Please don't copy the array unless it is needed.
---