Update hitkey

This commit is contained in:
Andrea Cavalli 2022-06-04 16:33:45 +02:00
parent 62c2dabd8c
commit 0e9b45ebf9
1 changed files with 10 additions and 0 deletions

View File

@ -1,8 +1,10 @@
package it.cavallium.dbengine.client;
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
import java.util.Comparator;
import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Mono;
public record HitKey<T>(T key, float score) implements Comparable<HitKey<T>> {
@ -11,6 +13,14 @@ public record HitKey<T>(T key, float score) implements Comparable<HitKey<T>> {
return valueGetter.apply(key).map(value -> new HitEntry<>(key, value, score));
}
public <U> HitEntry<T, U> withNullValue() {
return new HitEntry<>(key, null, score);
}
public HitEntry<T, Nothing> withNothingValue() {
return new HitEntry<>(key, Nothing.INSTANCE, score);
}
@Override
public int compareTo(@NotNull HitKey<T> o) {
return Float.compare(o.score, this.score);