2021-01-29 17:19:01 +01:00
|
|
|
package it.cavallium.dbengine.database;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.function.BiFunction;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import reactor.core.publisher.Flux;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
public class LLSearchResult {
|
|
|
|
|
2021-03-03 15:03:25 +01:00
|
|
|
private final Flux<Flux<LLSignal>> results;
|
2021-01-29 17:19:01 +01:00
|
|
|
|
2021-03-03 15:03:25 +01:00
|
|
|
public LLSearchResult(Flux<Flux<LLSignal>> results) {
|
2021-01-29 17:19:01 +01:00
|
|
|
this.results = results;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static LLSearchResult empty() {
|
2021-03-03 15:03:25 +01:00
|
|
|
return new LLSearchResult(Flux.just(Flux.just(new LLTotalHitsCount(0L))));
|
2021-01-29 17:19:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
public static BiFunction<LLSearchResult, LLSearchResult, LLSearchResult> accumulator() {
|
2021-03-03 15:03:25 +01:00
|
|
|
return (a, b) -> new LLSearchResult(Flux.merge(a.results, b.results));
|
2021-01-29 17:19:01 +01:00
|
|
|
}
|
|
|
|
|
2021-03-03 15:03:25 +01:00
|
|
|
public Flux<Flux<LLSignal>> results() {
|
2021-01-29 17:19:01 +01:00
|
|
|
return this.results;
|
|
|
|
}
|
|
|
|
|
2021-02-04 22:42:57 +01:00
|
|
|
public Mono<Void> completion() {
|
|
|
|
return results.flatMap(r -> r).then();
|
|
|
|
}
|
|
|
|
|
2021-01-29 17:19:01 +01:00
|
|
|
public boolean equals(final Object o) {
|
|
|
|
if (o == this) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(o instanceof LLSearchResult)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final LLSearchResult other = (LLSearchResult) o;
|
|
|
|
final Object this$results = this.results();
|
|
|
|
final Object other$results = other.results();
|
|
|
|
return Objects.equals(this$results, other$results);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
final int PRIME = 59;
|
|
|
|
int result = 1;
|
|
|
|
final Object $results = this.results();
|
|
|
|
result = result * PRIME + ($results == null ? 43 : $results.hashCode());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
2021-03-03 15:03:25 +01:00
|
|
|
return "LLSearchResult(results=" + this.results() + ")";
|
2021-01-29 17:19:01 +01:00
|
|
|
}
|
|
|
|
}
|