Skip to content

Commit 74aa7e5

Browse files
authored
Merge pull request #4847 from gchq/gh-4844_vis_parent_filter_issue
#4844 Fix issue where vis parent table filters are not applied to the…
2 parents a382a75 + 2405113 commit 74aa7e5

File tree

3 files changed

+63
-18
lines changed

3 files changed

+63
-18
lines changed

stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/FlatResultCreator.java

+39-17
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import stroom.query.language.functions.ExpressionContext;
3636
import stroom.query.language.functions.FieldIndex;
3737
import stroom.query.language.functions.Val;
38+
import stroom.query.language.functions.ValNull;
3839
import stroom.query.language.functions.ref.ErrorConsumer;
3940
import stroom.util.NullSafe;
4041
import stroom.util.concurrent.UncheckedInterruptedException;
@@ -49,6 +50,7 @@
4950
import java.util.Map;
5051
import java.util.Objects;
5152
import java.util.Optional;
53+
import java.util.function.Consumer;
5254
import java.util.function.Function;
5355
import java.util.function.Predicate;
5456

@@ -430,7 +432,42 @@ public DataStore map(final DataStore dataStore,
430432
parent.getAggregateFilter(),
431433
dataStore.getDateTimeSettings(),
432434
expressionPredicateFactory);
433-
final Predicate<Val[]> predicate = filter.orElse(vals -> true);
435+
final Consumer<Item> consumer = filter.map(predicate -> (Consumer<Item>) item -> {
436+
final List<Column> parentColumns = parent.getColumns();
437+
final Val[] parentValues = new Val[parentColumns.size()];
438+
for (int i = 0; i < parentValues.length; i++) {
439+
// TODO : @66 Currently evaluating more values than will be needed as we don't know what is
440+
// needed by the filter.
441+
parentValues[i] = item.getValue(i);
442+
}
443+
444+
if (predicate.test(parentValues)) {
445+
final Val[] values = new Val[parentFieldIndices.length];
446+
for (int i = 0; i < parentFieldIndices.length; i++) {
447+
final int index = parentFieldIndices[i];
448+
if (index != -1) {
449+
// TODO : @66 Currently evaluating more values than will be needed.
450+
values[i] = parentValues[index];
451+
} else {
452+
values[i] = ValNull.INSTANCE;
453+
}
454+
}
455+
childDataStore.accept(Val.of(values));
456+
}
457+
}).orElseGet(() -> item -> {
458+
final Val[] values = new Val[parentFieldIndices.length];
459+
for (int i = 0; i < parentFieldIndices.length; i++) {
460+
final int index = parentFieldIndices[i];
461+
if (index != -1) {
462+
// TODO : @66 Currently evaluating more values than will be needed.
463+
final Val val = item.getValue(index);
464+
values[i] = val;
465+
} else {
466+
values[i] = ValNull.INSTANCE;
467+
}
468+
}
469+
childDataStore.accept(Val.of(values));
470+
});
434471

435472
// Get top level items.
436473
// TODO : Add an option to get detail level items rather than root level items.
@@ -440,22 +477,7 @@ public DataStore map(final DataStore dataStore,
440477
OpenGroups.NONE,
441478
timeFilter,
442479
IdentityItemMapper.INSTANCE,
443-
item -> {
444-
final Val[] values = new Val[parentFieldIndices.length];
445-
for (int i = 0; i < parentFieldIndices.length; i++) {
446-
final int index = parentFieldIndices[i];
447-
if (index != -1) {
448-
// TODO : @66 Currently evaluating more values than will be needed.
449-
final Val val = item.getValue(index);
450-
values[i] = val;
451-
}
452-
}
453-
454-
// Filter values.
455-
if (predicate.test(values)) {
456-
childDataStore.accept(Val.of(values));
457-
}
458-
},
480+
consumer,
459481
null);
460482

461483
return childDataStore;

stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/ResultStore.java

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package stroom.query.common.v2;
1818

19-
import stroom.dictionary.api.WordListProvider;
2019
import stroom.query.api.v2.SearchRequest;
2120
import stroom.query.api.v2.SearchRequestSource;
2221
import stroom.query.api.v2.SearchResponse;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#4844** : Fix issue where vis parent table filters are not applied to the right data values.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: selection filter tables with viz are failing to set viz data on update
7+
# Issue link: https://github.com/gchq/stroom/issues/4844
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)