From 775fb387b6457d946711cf2d9d563321e6c03e31 Mon Sep 17 00:00:00 2001 From: expani Date: Sat, 26 Oct 2024 21:54:44 +0530 Subject: [PATCH] Added a variation of BPV32 using only r/w long --- .../benchmark/jmh/DocIdEncodingBenchmark.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/DocIdEncodingBenchmark.java b/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/DocIdEncodingBenchmark.java index fa26b75fd9c..2dfc6868563 100644 --- a/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/DocIdEncodingBenchmark.java +++ b/lucene/benchmark-jmh/src/java/org/apache/lucene/benchmark/jmh/DocIdEncodingBenchmark.java @@ -509,6 +509,34 @@ public class DocIdEncodingBenchmark { } } } + + class Bit32OnlyRWLongEncoder implements DocIdEncoder { + + @Override + public void encode(IndexOutput out, int start, int count, int[] docIds) throws IOException { + int i; + for (i = 0; i < count - 1; i += 2) { + long packedLong = ((long) docIds[i] << 32) & docIds[i + 1]; + out.writeLong(packedLong); + } + for (; i < count; i++) { + out.writeLong(docIds[i]); + } + } + + @Override + public void decode(IndexInput in, int start, int count, int[] docIds) throws IOException { + int i; + for (i = 0; i < count - 1; i += 2) { + long packedLong = in.readLong(); + docIds[i] = (int) (packedLong >>> 32); + docIds[i + 1] = (int) (packedLong & 0xFFFFFFFFL); + } + for (; i < count; i++) { + docIds[i] = (int) in.readLong(); + } + } + } } interface DocIdProvider { @@ -528,6 +556,8 @@ public class DocIdEncodingBenchmark { DocIdEncodingBenchmark.DocIdEncoder.Bit24Encoder.class, 24, DocIdEncodingBenchmark.DocIdEncoder.Bit32Encoder.class, + 32, + DocIdEncoder.Bit32OnlyRWLongEncoder.class, 32); /**