CavalliumDBEngine/src/main/java/it/cavallium/dbengine/client/LuceneIndex.java

75 lines
2.3 KiB
Java
Raw Normal View History

2021-02-03 20:13:17 +01:00
package it.cavallium.dbengine.client;
2021-09-19 19:59:37 +02:00
import io.net5.buffer.api.Send;
2021-03-02 01:53:36 +01:00
import it.cavallium.dbengine.client.query.ClientQueryParams;
import it.cavallium.dbengine.client.query.current.data.Query;
2021-08-04 01:12:39 +02:00
import it.cavallium.dbengine.client.query.current.data.TotalHitsCount;
2021-06-07 16:21:12 +02:00
import it.cavallium.dbengine.database.Delta;
2021-02-03 20:13:17 +01:00
import it.cavallium.dbengine.database.LLSnapshottable;
2021-07-17 11:52:08 +02:00
import it.cavallium.dbengine.database.collections.ValueGetter;
import it.cavallium.dbengine.database.collections.ValueTransformer;
2021-11-19 19:03:31 +01:00
import it.cavallium.dbengine.lucene.collector.Buckets;
2021-11-18 17:13:53 +01:00
import it.cavallium.dbengine.lucene.searcher.BucketParams;
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
2021-11-19 19:03:31 +01:00
import java.util.List;
2021-02-03 20:13:17 +01:00
import java.util.Map.Entry;
2021-06-07 16:21:12 +02:00
import org.jetbrains.annotations.NotNull;
2021-02-03 20:13:17 +01:00
import org.jetbrains.annotations.Nullable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
2021-04-03 19:09:06 +02:00
public interface LuceneIndex<T, U> extends LLSnapshottable {
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> addDocument(T key, U value);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> addDocuments(Flux<Entry<T, U>> entries);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> deleteDocument(T key);
2021-02-03 20:13:17 +01:00
2021-06-07 16:21:12 +02:00
Mono<Void> updateDocument(T key, @NotNull U value);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> updateDocuments(Flux<Entry<T, U>> entries);
2021-02-03 20:13:17 +01:00
2021-06-07 16:21:12 +02:00
default Mono<Void> updateOrDeleteDocument(T key, @Nullable U value) {
if (value == null) {
return deleteDocument(key);
} else {
return updateDocument(key, value);
}
}
default Mono<Void> updateOrDeleteDocumentIfModified(T key, @NotNull Delta<U> delta) {
2021-07-17 11:52:08 +02:00
return updateOrDeleteDocumentIfModified(key, delta.current(), delta.isModified());
}
default Mono<Void> updateOrDeleteDocumentIfModified(T key, @Nullable U currentValue, boolean modified) {
if (modified) {
return updateOrDeleteDocument(key, currentValue);
2021-06-07 16:21:12 +02:00
} else {
return Mono.empty();
}
}
2021-04-03 19:09:06 +02:00
Mono<Void> deleteAll();
2021-02-03 20:13:17 +01:00
2021-11-08 11:17:52 +01:00
Mono<Hits<HitKey<T>>> moreLikeThis(ClientQueryParams queryParams, T key,
2021-10-28 23:48:25 +02:00
U mltDocumentValue);
2021-07-17 11:52:08 +02:00
2021-11-08 11:17:52 +01:00
Mono<Hits<HitKey<T>>> search(ClientQueryParams queryParams);
2021-02-03 20:13:17 +01:00
2021-11-19 19:03:31 +01:00
Mono<Buckets> computeBuckets(@Nullable CompositeSnapshot snapshot,
@NotNull List<Query> queries,
@Nullable Query normalizaitonQuery,
BucketParams bucketParams);
2021-11-18 17:13:53 +01:00
2021-08-04 01:12:39 +02:00
Mono<TotalHitsCount> count(@Nullable CompositeSnapshot snapshot, Query query);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
boolean isLowMemoryMode();
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> close();
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Void> flush();
2021-02-03 20:13:17 +01:00
2021-07-18 19:37:24 +02:00
Mono<Void> refresh(boolean force);
2021-02-03 20:13:17 +01:00
}