mirror of https://github.com/apache/lucene.git
Added new hybrid encoder based on readlong vs readint tests
This commit is contained in:
parent
da2325cdbd
commit
06dd48fcfd
|
@ -27,7 +27,6 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
@ -72,6 +71,7 @@ public class DocIdEncodingBenchmark {
|
||||||
"Bit21With3StepsEncoder",
|
"Bit21With3StepsEncoder",
|
||||||
"Bit21With2StepsEncoder",
|
"Bit21With2StepsEncoder",
|
||||||
"Bit24Encoder",
|
"Bit24Encoder",
|
||||||
|
"Bit21HybridEncoder",
|
||||||
"Bit21With2StepsOnlyRWLongEncoder",
|
"Bit21With2StepsOnlyRWLongEncoder",
|
||||||
"Bit21With3StepsEncoderOnlyRWLongEncoder"
|
"Bit21With3StepsEncoderOnlyRWLongEncoder"
|
||||||
})
|
})
|
||||||
|
@ -165,10 +165,6 @@ public class DocIdEncodingBenchmark {
|
||||||
private static final Map<String, DocIdEncoder> ENCODER_NAME_TO_INSTANCE_MAPPING =
|
private static final Map<String, DocIdEncoder> ENCODER_NAME_TO_INSTANCE_MAPPING =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
|
|
||||||
/** Add all the encoders that have custom constructors. */
|
|
||||||
private static final Set<Class<? extends DocIdEncoder>> EXCLUDED_ENCODERS =
|
|
||||||
Set.of(Bit21HybridEncoder.class);
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
initialiseEncoders();
|
initialiseEncoders();
|
||||||
}
|
}
|
||||||
|
@ -182,7 +178,7 @@ public class DocIdEncodingBenchmark {
|
||||||
for (Class<?> clazz : allImplementations) {
|
for (Class<?> clazz : allImplementations) {
|
||||||
boolean isADocIdEncoder =
|
boolean isADocIdEncoder =
|
||||||
Arrays.asList(clazz.getInterfaces()).contains(DocIdEncoder.class);
|
Arrays.asList(clazz.getInterfaces()).contains(DocIdEncoder.class);
|
||||||
if (isADocIdEncoder && !EXCLUDED_ENCODERS.contains(clazz)) {
|
if (isADocIdEncoder) {
|
||||||
try {
|
try {
|
||||||
ENCODER_NAME_TO_INSTANCE_MAPPING.put(
|
ENCODER_NAME_TO_INSTANCE_MAPPING.put(
|
||||||
parsedClazzName(clazz), (DocIdEncoder) clazz.getConstructor().newInstance());
|
parsedClazzName(clazz), (DocIdEncoder) clazz.getConstructor().newInstance());
|
||||||
|
@ -194,24 +190,6 @@ public class DocIdEncodingBenchmark {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding the encoders with custom constructors
|
|
||||||
// @Bit21HybridEncoder
|
|
||||||
if (Constants.OS_ARCH.equals("aarch64")) {
|
|
||||||
ENCODER_NAME_TO_INSTANCE_MAPPING.put(
|
|
||||||
parsedClazzName(Bit21HybridEncoder.class),
|
|
||||||
new Bit21HybridEncoder(
|
|
||||||
SingletonFactory.fromClazz(Bit21With2StepsEncoder.class),
|
|
||||||
SingletonFactory.fromClazz(Bit21With3StepsEncoder.class)));
|
|
||||||
} else if (Constants.OS_ARCH.equals("amd64")) {
|
|
||||||
ENCODER_NAME_TO_INSTANCE_MAPPING.put(
|
|
||||||
parsedClazzName(Bit21HybridEncoder.class),
|
|
||||||
new Bit21HybridEncoder(
|
|
||||||
SingletonFactory.fromClazz(Bit21With3StepsEncoder.class),
|
|
||||||
SingletonFactory.fromClazz(Bit21With3StepsEncoder.class)));
|
|
||||||
} else {
|
|
||||||
throw new UnsupportedOperationException("Unsupported architecture: " + Constants.OS_ARCH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DocIdEncoder fromName(String encoderName) {
|
public static DocIdEncoder fromName(String encoderName) {
|
||||||
|
@ -496,18 +474,12 @@ public class DocIdEncodingBenchmark {
|
||||||
private final DocIdEncoder encoder;
|
private final DocIdEncoder encoder;
|
||||||
private final DocIdEncoder decoder;
|
private final DocIdEncoder decoder;
|
||||||
|
|
||||||
private final Set<Class<? extends DocIdEncoder>> VALID_BPV_21_ENCODER_CLASSES =
|
public Bit21HybridEncoder() {
|
||||||
Set.of(Bit21With2StepsEncoder.class, Bit21With3StepsEncoder.class);
|
if (Constants.OS_ARCH.equals("aarch64")) {
|
||||||
|
this.encoder = this.decoder = new Bit21With2StepsEncoder();
|
||||||
public Bit21HybridEncoder(DocIdEncoder encoder, DocIdEncoder decoder) {
|
} else {
|
||||||
if (!VALID_BPV_21_ENCODER_CLASSES.contains(encoder.getClass())) {
|
this.encoder = this.decoder = new Bit21With3StepsEncoderOnlyRWLongEncoder();
|
||||||
throw new IllegalArgumentException("Illegal encoder " + encoder.getClass());
|
|
||||||
}
|
}
|
||||||
if (!VALID_BPV_21_ENCODER_CLASSES.contains(decoder.getClass())) {
|
|
||||||
throw new IllegalArgumentException("Illegal decoder " + decoder.getClass());
|
|
||||||
}
|
|
||||||
this.encoder = encoder;
|
|
||||||
this.decoder = decoder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue