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

67 lines
1.9 KiB
Java
Raw Normal View History

2021-02-03 20:13:17 +01:00
package it.cavallium.dbengine.client;
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-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;
import it.cavallium.dbengine.database.collections.Joiner.ValueGetter;
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
@SuppressWarnings("unused")
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) {
if (delta.isModified()) {
return updateOrDeleteDocument(key, delta.current());
} else {
return Mono.empty();
}
}
2021-04-03 19:09:06 +02:00
Mono<Void> deleteAll();
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<SearchResultKeys<T>> moreLikeThis(ClientQueryParams<SearchResultKey<T>> queryParams, T key, U mltDocumentValue);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<SearchResult<T, U>> moreLikeThisWithValues(ClientQueryParams<SearchResultItem<T, U>> queryParams,
2021-02-06 15:53:10 +01:00
T key,
2021-02-03 20:13:17 +01:00
U mltDocumentValue,
2021-04-03 19:09:06 +02:00
ValueGetter<T, U> valueGetter);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<SearchResultKeys<T>> search(ClientQueryParams<SearchResultKey<T>> queryParams);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<SearchResult<T, U>> searchWithValues(ClientQueryParams<SearchResultItem<T, U>> queryParams,
ValueGetter<T, U> valueGetter);
2021-02-03 20:13:17 +01:00
2021-04-03 19:09:06 +02:00
Mono<Long> 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-04-03 19:09:06 +02:00
Mono<Void> refresh();
2021-02-03 20:13:17 +01:00
}