Skip to content

Commit

Permalink
#4682 PlanB State Store
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Jan 10, 2025
1 parent 517dd8c commit 719343a
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import stroom.docref.DocRef;
import stroom.entity.shared.ExpressionCriteria;
import stroom.index.shared.IndexFieldImpl;
import stroom.planb.impl.data.ReaderCache;
import stroom.planb.impl.io.AbstractLmdbReader;
import stroom.planb.impl.io.StateFieldUtil;
import stroom.planb.shared.PlanBDoc;
import stroom.query.api.v2.ExpressionUtil;
Expand All @@ -32,6 +34,7 @@
import stroom.query.common.v2.CoprocessorsFactory;
import stroom.query.common.v2.CoprocessorsImpl;
import stroom.query.common.v2.DataStoreSettings;
import stroom.query.common.v2.ExpressionPredicateFactory;
import stroom.query.common.v2.FieldInfoResultPageBuilder;
import stroom.query.common.v2.IndexFieldProvider;
import stroom.query.common.v2.ResultStore;
Expand Down Expand Up @@ -72,6 +75,8 @@ public class StateSearchProvider implements SearchProvider, IndexFieldProvider {
private final ResultStoreFactory resultStoreFactory;
private final TaskManager taskManager;
private final TaskContextFactory taskContextFactory;
private final ReaderCache readerCache;
private final ExpressionPredicateFactory expressionPredicateFactory;

@Inject
public StateSearchProvider(final Executor executor,
Expand All @@ -80,14 +85,18 @@ public StateSearchProvider(final Executor executor,
final CoprocessorsFactory coprocessorsFactory,
final ResultStoreFactory resultStoreFactory,
final TaskManager taskManager,
final TaskContextFactory taskContextFactory) {
final TaskContextFactory taskContextFactory,
final ReaderCache readerCache,
final ExpressionPredicateFactory expressionPredicateFactory) {
this.executor = executor;
this.stateDocStore = stateDocStore;
this.stateDocCache = stateDocCache;
this.coprocessorsFactory = coprocessorsFactory;
this.resultStoreFactory = resultStoreFactory;
this.taskManager = taskManager;
this.taskContextFactory = taskContextFactory;
this.readerCache = readerCache;
this.expressionPredicateFactory = expressionPredicateFactory;
}

private PlanBDoc getPlanBDoc(final DocRef docRef) {
Expand Down Expand Up @@ -224,11 +233,15 @@ public void onTerminate() {

final Instant queryStart = Instant.now();
try {
// DaoFactory.create(sessionProvider, doc.getStateType(), doc.getName()).search(
// criteria,
// coprocessors.getFieldIndex(),
// searchRequest.getDateTimeSettings(),
// coprocessors);
final Optional<AbstractLmdbReader<?, ?>> optional = readerCache.get(doc.getName());
optional.ifPresent(reader -> {
reader.search(
criteria,
coprocessors.getFieldIndex(),
searchRequest.getDateTimeSettings(),
expressionPredicateFactory,
coprocessors);
});
} catch (final RuntimeException e) {
LOGGER.debug(e::getMessage, e);
resultStore.addError(e);
Expand Down

0 comments on commit 719343a

Please sign in to comment.