mirror of https://github.com/apache/lucene.git
Added arch specific write int/long
This commit is contained in:
parent
702580a96d
commit
11821194ee
|
@ -204,11 +204,6 @@ public class DocIdEncodingBenchmark {
|
|||
.toList();
|
||||
}
|
||||
|
||||
public static DocIdEncoder fromClazz(Class<? extends DocIdEncoder> 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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue