Benchmarks at https://github.com/apache/lucene/pull/14979 suggested that tracking the sum in a variable performs faster than adding the previous value to each array element.
@@ -346,8 +346,10 @@ public final class TSDBDocValuesEncoder {
}
private void deltaDecode(long[] arr) {
- for (int i = 1; i < numericBlockSize; ++i) {
- arr[i] += arr[i - 1];
+ long sum = 0;
+ for (int i = 0; i < numericBlockSize; ++i) {
+ sum += arr[i];
+ arr[i] = sum;