gsmiller commented on a change in pull request #69:
URL: https://github.com/apache/lucene/pull/69#discussion_r609945080



##########
File path: lucene/core/src/java/org/apache/lucene/codecs/lucene90/PForUtil.java
##########
@@ -121,4 +167,146 @@ void skip(DataInput in) throws IOException {
       in.skipBytes(forUtil.numBytes(bitsPerValue) + (numExceptions << 1));
     }
   }
+
+  /**
+   * Fill {@code longs} with the final values for the case of all deltas being 
1. Note this assumes
+   * there are no exceptions to apply.
+   */
+  private static void prefixSumOfOnes(long[] longs, long base) {
+    System.arraycopy(IDENTITY_PLUS_ONE, 0, longs, 0, ForUtil.BLOCK_SIZE);
+    // This loop gets auto-vectorized
+    for (int i = 0; i < ForUtil.BLOCK_SIZE; ++i) {
+      longs[i] += base;
+    }
+  }
+
+  /**
+   * Fill {@code longs} with the final values for the case of all deltas being 
{@code val}. Note
+   * this assumes there are no exceptions to apply.
+   */
+  private static void prefixSumOf(long[] longs, long base, long val) {
+    for (int i = 0; i < ForUtil.BLOCK_SIZE; i++) {
+      longs[i] = (i + 1) * val + base;

Review comment:
       @rmuir interesting. Yeah, I'd like to explore this further, but I wonder 
if it makes sense to do so in a follow-up Jira? For starters, intuitively, this 
case seems pretty uncommon. It will only kick in when all deltas are the same 
value, but aren't `1`. "Dense" blocks seem like the common case for using 0 
bpv, where all deltas would be `1`, and that case is definitely optimized 
already (`prefixSumOfOnes`). In fact, `ForDeltaUtil` doesn't even use 0 bpv for 
any case other than `1` (it doesn't actually store the "same value", but rather 
infers that it's `1` if bpv == 0). So this is already more efficient than what 
`ForDeltaUtil` is doing for these cases, in the sense that `ForDeltaUtil` would 
actually fully encode the deltas and go through the whole dane of decoding 
them, etc.
   
   @rmuir / @jpountz Any concern with me creating a follow-on issue to further 
investigate and move forward with this PR in its current state?




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to