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 12e941200fa..a6b09d4ea1b 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 @@ -204,11 +204,6 @@ public class DocIdEncodingBenchmark { .toList(); } - public static DocIdEncoder fromClazz(Class clazz) { - String parsedEncoderName = parsedClazzName(clazz); - return getInternal(parsedEncoderName); - } - private static DocIdEncoder getInternal(String parsedEncoderName) { if (ENCODER_NAME_TO_INSTANCE_MAPPING.containsKey(parsedEncoderName)) { return ENCODER_NAME_TO_INSTANCE_MAPPING.get(parsedEncoderName); @@ -493,6 +488,10 @@ public class DocIdEncodingBenchmark { } } + /** + * Last fallback in org.apache.lucene.util.bkd.DocIdsWriter#writeDocIds() when no optimisation + * works + */ class Bit32Encoder implements DocIdEncoder { @Override @@ -510,6 +509,7 @@ public class DocIdEncodingBenchmark { } } + /** Variation of @{@link Bit32Encoder} using readLong and writeLong methods. */ class Bit32OnlyRWLongEncoder implements DocIdEncoder { @Override diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java index 18da2c9366e..5c11ed88ad7 100644 --- a/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java +++ b/lucene/core/src/java/org/apache/lucene/util/bkd/DocIdsWriter.java @@ -121,7 +121,7 @@ final class DocIdsWriter { out.writeByte(BPV_21); int i = 0; // See - // @org.apache.lucene.benchmark.jmh.DocIdEncodingBenchmark.DocIdEncoder.Bit21With3StepsEncoder + // @org.apache.lucene.benchmark.jmh.DocIdEncodingBenchmark$DocIdEncoder$Bit21With3StepsEncoder if (!IS_ARCH_64) { for (; i < count - 8; i += 9) { long l1 = @@ -148,8 +148,14 @@ final class DocIdsWriter { | (docIds[i + 2] & BPV_21_MASK); out.writeLong(packedLong); } - for (; i < count; i++) { - out.writeInt(docIds[i]); + if (IS_ARCH_64) { + for (; i < count; i++) { + out.writeInt(docIds[i]); + } + } else { + for (; i < count; i++) { + out.writeLong(docIds[i]); + } } } else if (max <= 0xFFFFFF) { out.writeByte(BPV_24); @@ -332,8 +338,14 @@ final class DocIdsWriter { docIDs[i + 1] = (int) ((packedLong >>> 21) & BPV_21_MASK); docIDs[i + 2] = (int) (packedLong & BPV_21_MASK); } - for (; i < count; i++) { - docIDs[i] = in.readInt(); + if (IS_ARCH_64) { + for (; i < count; i++) { + docIDs[i] = in.readInt(); + } + } else { + for (; i < count; i++) { + docIDs[i] = (int) in.readLong(); + } } }