Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b814faa
Empty initial commit on gh-4365-stroomql-case-sens-fields [no ci]
at055612 Jul 24, 2024
9c395b4
gh-4365 Make stroomQL fully case-insensitive
at055612 Jul 26, 2024
f04d674
gh-4365 Fix CS
at055612 Jul 29, 2024
53273cf
gh-4365 Add javadoc
at055612 Jul 29, 2024
d7b5a78
Merge branch '7.5' into gh-4365-stroomql-case-sens-fields
at055612 Jul 29, 2024
fff333d
gh-4365 Fix compile issues
at055612 Jul 29, 2024
dd453ec
gh-4365 Refactor more code to use CIKey
at055612 Jul 31, 2024
9efa655
gh-4365 Fix CS
at055612 Jul 31, 2024
8067e19
Merge branch '7.5' into gh-4365-stroomql-case-sens-fields
at055612 Jul 31, 2024
9b64a57
gh-4365 Change more code to use CIKey, add more constants
at055612 Aug 2, 2024
e3f5470
gh-4365 Tidy up field name constants
at055612 Aug 2, 2024
d5ae493
gh-4365 Fix failing tests
at055612 Aug 2, 2024
f3dd9e7
gh-4365 Fix failing test
at055612 Aug 6, 2024
f45c94b
gh-4365 Refactor AttributeMap to use CIKey, add IndexFieldMap WIP
at055612 Aug 8, 2024
8ee9553
gh-4365 Get IndexFieldMap working
at055612 Aug 28, 2024
90b0adf
gh-4365 Fix failing tests, refactor AttributeMap
at055612 Aug 29, 2024
c0bfee7
Merge branch '7.5' into gh-4365-stroomql-case-sens-fields
at055612 Aug 29, 2024
fe3a77b
gh-4365 Add change entries
at055612 Aug 29, 2024
bb02a19
gh-4365 Add sort to getFields()
at055612 Aug 29, 2024
5970cc0
gh-4365 Fix getNullSafeCaseInsensitiveComparator and add tests
at055612 Aug 29, 2024
d4e7d0b
Merge branch '7.5' into gh-4365-stroomql-case-sens-fields
at055612 Sep 9, 2024
b3fb95a
gh-4365 Fix compile error
at055612 Sep 10, 2024
b5c7837
Merge branch '7.5' into gh-4365-stroomql-case-sens-fields
at055612 Sep 10, 2024
9f9056d
Merge branch '7.6' into gh-4365-stroomql-case-sens-fields-7.6
at055612 Sep 10, 2024
56be778
gh-4365 Tidy up QueryField constants
at055612 Sep 11, 2024
14c9a55
gh-4365 Improve test
at055612 Sep 11, 2024
041ce82
gh-4365 Improve test
at055612 Sep 11, 2024
729806c
gh-4365 Code comments
at055612 Sep 11, 2024
13474a7
gh-4365 Add Rows searchable
at055612 Sep 12, 2024
ccc3615
Merge branch '7.6' into gh-4365-stroomql-case-sens-fields-7.6
at055612 Oct 17, 2024
82281a7
Merge branch '7.6' into gh-4365-stroomql-case-sens-fields-7.6
at055612 Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ ext.libs = [
commons_lang : "org.apache.commons:commons-lang3", // version controlled by dropwizard-dependencies
commons_pool2 : "org.apache.commons:commons-pool2:2.12.0",
commons_text : "org.apache.commons:commons-text", // version controlled by dropwizard-dependencies
commons_collections4 : "org.apache.commons:commons-collections4:4.4", // Not in dropwizard-dependencies
classgraph : "io.github.classgraph:classgraph:4.8.146",
curator_client : "org.apache.curator:curator-client:$versions.curator",
curator_framework : "org.apache.curator:curator-framework:$versions.curator",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package stroom.analytics.impl;

import stroom.analytics.rule.impl.AnalyticRuleStore;
Expand Down Expand Up @@ -47,6 +63,7 @@
import stroom.util.logging.LambdaLogger;
import stroom.util.logging.LambdaLoggerFactory;
import stroom.util.shared.ResultPage;
import stroom.util.shared.string.CIKey;
import stroom.view.shared.ViewDoc;

import jakarta.inject.Inject;
Expand Down Expand Up @@ -248,7 +265,7 @@ private LmdbDataStore createStore(final SearchRequest searchRequest) {
final FieldIndex fieldIndex = new FieldIndex();

// Create a parameter map.
final Map<String, String> paramMap = ParamUtil.createParamMap(searchRequest.getQuery().getParams());
final Map<CIKey, String> paramMap = ParamUtil.createParamMap(searchRequest.getQuery().getParams());

// Create error consumer.
final ErrorConsumer errorConsumer = new ErrorConsumerImpl();
Expand All @@ -274,7 +291,7 @@ private LmdbDataStore createAnalyticLmdbDataStore(final QueryKey queryKey,
final TableSettings tableSettings,
final ExpressionContext expressionContext,
final FieldIndex fieldIndex,
final Map<String, String> paramMap,
final Map<CIKey, String> paramMap,
final DataStoreSettings dataStoreSettings,
final ErrorConsumer errorConsumer) {
final AnalyticResultStoreConfig storeConfig = analyticStoreConfigProvider.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import stroom.datasource.api.v2.QueryField;
import stroom.docref.DocRef;
import stroom.util.shared.string.CIKey;
import stroom.util.shared.string.CIKeys;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -34,35 +36,28 @@ public class AnalyticFields {
.name(ANALYTICS_STORE_TYPE)
.build();

public static final String NAME = "Name";
public static final String UUID = "UUID";
public static final String TIME = "Time";
public static final String VALUE = "Value";
private static final List<QueryField> FIELDS = new ArrayList<>();
private static final Map<String, QueryField> FIELD_MAP;

// Times
public static final QueryField TIME_FIELD = QueryField.createDate(TIME);

public static final QueryField NAME_FIELD = QueryField.createText(NAME);
public static final QueryField UUID_FIELD = QueryField.createText(UUID);
public static final QueryField VALUE_FIELD = QueryField.createText(VALUE);

static {
FIELDS.add(TIME_FIELD);
FIELDS.add(NAME_FIELD);
FIELDS.add(UUID_FIELD);
FIELDS.add(VALUE_FIELD);

FIELD_MAP = FIELDS.stream()
.collect(Collectors.toMap(QueryField::getFldName, Function.identity()));
}
public static final QueryField TIME_FIELD = QueryField.createDate(CIKeys.TIME, true);
public static final QueryField NAME_FIELD = QueryField.createText(CIKeys.NAME, true);
public static final QueryField UUID_FIELD = QueryField.createText(CIKeys.UUID, true);
public static final QueryField VALUE_FIELD = QueryField.createText(CIKeys.VALUE, true);

private static final List<QueryField> FIELDS = List.of(
TIME_FIELD,
NAME_FIELD,
UUID_FIELD,
VALUE_FIELD);

private static final Map<CIKey, QueryField> FIELD_NAME_TO_FIELD_MAP = FIELDS.stream()
.collect(Collectors.toMap(
QueryField::getFldNameAsCIKey,
Function.identity()));

public static List<QueryField> getFields() {
return new ArrayList<>(FIELDS);
}

public static Map<String, QueryField> getFieldMap() {
return FIELD_MAP;
public static Map<CIKey, QueryField> getFieldMap() {
return FIELD_NAME_TO_FIELD_MAP;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Crown Copyright
* Copyright 2024 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package stroom.analytics.impl;
Expand Down Expand Up @@ -62,6 +61,7 @@
import stroom.util.concurrent.UncheckedInterruptedException;
import stroom.util.logging.LambdaLogger;
import stroom.util.logging.LambdaLoggerFactory;
import stroom.util.shared.string.CIKey;

import jakarta.inject.Inject;

Expand Down Expand Up @@ -148,10 +148,10 @@ private void doSearch(final TaskContext parentContext,
final List<CompletableFuture<Void>> futures = new ArrayList<>();
try {
final FieldIndex fieldIndex = coprocessors.getFieldIndex();
final Map<String, QueryField> fieldMap = AnalyticFields.getFieldMap();
final Map<CIKey, QueryField> fieldMap = AnalyticFields.getFieldMap();
final QueryField[] fieldArray = new QueryField[fieldIndex.size()];
for (int i = 0; i < fieldArray.length; i++) {
final String fieldName = fieldIndex.getField(i);
final CIKey fieldName = fieldIndex.getFieldAsCIKey(i);
final QueryField field = fieldMap.get(fieldName);
if (field == null) {
throw new RuntimeException("Field '" + fieldName + "' is not valid for this datasource");
Expand Down Expand Up @@ -331,7 +331,7 @@ public TableResultConsumer errors(final List<String> errors) {
public TableResultConsumer columns(final List<Column> columns) {
this.columns = columns;
fieldIndex = new FieldIndex();
columns.forEach(column -> fieldIndex.create(column.getName()));
columns.forEach(column -> fieldIndex.create(column.getNameAsCIKey()));
return this;
}

Expand All @@ -357,11 +357,11 @@ public TableResultConsumer addRow(final Row row) {
}
final String value = sb.toString();

final Map<String, Object> attributeMap = new HashMap<>();
attributeMap.put(AnalyticFields.NAME_FIELD.getFldName(), analyticRuleDoc.getName());
attributeMap.put(AnalyticFields.UUID_FIELD.getFldName(), analyticRuleDoc.getUuid());
attributeMap.put(AnalyticFields.TIME_FIELD.getFldName(), time);
attributeMap.put(AnalyticFields.VALUE_FIELD.getFldName(), value);
final Map<CIKey, Object> attributeMap = new HashMap<>();
attributeMap.put(AnalyticFields.NAME_FIELD.getFldNameAsCIKey(), analyticRuleDoc.getName());
attributeMap.put(AnalyticFields.UUID_FIELD.getFldNameAsCIKey(), analyticRuleDoc.getUuid());
attributeMap.put(AnalyticFields.TIME_FIELD.getFldNameAsCIKey(), time);
attributeMap.put(AnalyticFields.VALUE_FIELD.getFldNameAsCIKey(), value);

if (expressionMatcher.match(attributeMap, expression)) {
hitCount.increment();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package stroom.analytics.impl;

import stroom.analytics.shared.AnalyticRuleDoc;
Expand All @@ -9,7 +25,6 @@
import stroom.query.common.v2.CompiledColumns;
import stroom.query.common.v2.format.ColumnFormatter;
import stroom.query.common.v2.format.FormatterFactory;
import stroom.query.language.functions.FieldIndex;
import stroom.query.language.functions.Generator;
import stroom.query.language.functions.Val;
import stroom.query.language.functions.ValuesConsumer;
Expand All @@ -18,6 +33,7 @@
import stroom.util.NullSafe;
import stroom.util.date.DateUtil;
import stroom.util.shared.Severity;
import stroom.util.shared.query.FieldNames;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
Expand Down Expand Up @@ -198,9 +214,9 @@ private void writeRecord(final ColumnValue[] columnValues) {
NullSafe.consume(columnValue, ColumnValue::val, val -> {
final Column column = columnValue.column();
final String columnName = column.getName();
if (FieldIndex.isStreamIdFieldName(columnName)) {
if (FieldNames.isStreamIdFieldName(columnName)) {
streamId.set(getSafeLong(val));
} else if (FieldIndex.isEventIdFieldName(columnName)) {
} else if (FieldNames.isEventIdFieldName(columnName)) {
eventId.set(getSafeLong(val));
} else {
final String fieldValStr = fieldFormatter.format(column, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import stroom.util.shared.ResultPage;
import stroom.util.shared.Severity;
import stroom.util.shared.scheduler.Schedule;
import stroom.util.shared.string.CIKey;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
Expand Down Expand Up @@ -208,7 +209,7 @@ private void execAnalytic(final AnalyticRuleDoc analytic,
.builder()
.ownerDocRef(analytic.asDocRef())
.enabled(true)
.nodeName(StringMatch.equals(nodeInfo.getThisNodeName(), true))
.nodeName(StringMatch.equalsIgnoreCase(nodeInfo.getThisNodeName()))
.build();

final ResultPage<ExecutionSchedule> executionSchedules = executionScheduleDao.fetchExecutionSchedule(request);
Expand Down Expand Up @@ -366,7 +367,7 @@ private boolean process(final AnalyticRuleDoc analytic,
// Now consume all results as detections.
final TableSettings tableSettings = resultRequest.getMappings().getFirst();
final List<Column> columns = tableSettings.getColumns();
final Map<String, String> paramMap = ParamUtil
final Map<CIKey, String> paramMap = ParamUtil
.createParamMap(mappedRequest.getQuery().getParams());
final CompiledColumns compiledColumns = CompiledColumns.create(
expressionContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Crown Copyright
* Copyright 2024 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,6 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package stroom.analytics.impl;
Expand Down Expand Up @@ -41,6 +40,7 @@
import stroom.util.concurrent.UncheckedInterruptedException;
import stroom.util.logging.LambdaLogger;
import stroom.util.logging.LambdaLoggerFactory;
import stroom.util.shared.string.CIKey;

import jakarta.inject.Inject;
import jakarta.inject.Provider;
Expand Down Expand Up @@ -116,7 +116,7 @@ private Optional<AnalyticFieldListConsumer> createEventConsumer(final StreamingA
final ExpressionContext expressionContext = expressionContextFactory
.createContext(searchRequest);
final TableSettings tableSettings = searchRequest.getResultRequests().getFirst().getMappings().getFirst();
final Map<String, String> paramMap = ParamUtil.createParamMap(searchRequest.getQuery().getParams());
final Map<CIKey, String> paramMap = ParamUtil.createParamMap(searchRequest.getQuery().getParams());
final CompiledColumns compiledColumns = CompiledColumns.create(expressionContext,
tableSettings.getColumns(),
paramMap);
Expand All @@ -135,6 +135,7 @@ private Optional<AnalyticFieldListConsumer> createEventConsumer(final StreamingA
try {
final Provider<DetectionConsumer> detectionConsumerProvider =
detectionConsumerFactory.create(analytic.analyticRuleDoc());

detectionConsumerProxy.setAnalyticRuleDoc(analytic.analyticRuleDoc());
detectionConsumerProxy.setCompiledColumns(compiledColumns);
detectionConsumerProxy.setDetectionsConsumerProvider(detectionConsumerProvider);
Expand Down Expand Up @@ -162,6 +163,10 @@ private Optional<AnalyticFieldListConsumer> createEventConsumer(final StreamingA
}
}


// --------------------------------------------------------------------------------


private static class NullFieldListConsumer implements AnalyticFieldListConsumer {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package stroom.analytics.impl;

import stroom.analytics.impl.AnalyticDataStores.AnalyticDataStore;
Expand Down Expand Up @@ -61,6 +77,7 @@
import stroom.util.logging.LogExecutionTime;
import stroom.util.logging.LogUtil;
import stroom.util.shared.UserRef;
import stroom.util.shared.string.CIKey;
import stroom.util.shared.time.SimpleDuration;
import stroom.util.shared.time.TimeUnit;
import stroom.util.time.SimpleDurationUtil;
Expand Down Expand Up @@ -362,7 +379,7 @@ private void processStream(final DocRef pipelineDocRef,
final List<TableBuilderAnalytic> analytics,
final Meta meta,
final TaskContext parentTaskContext) {
final Map<String, Object> metaAttributeMap = MetaAttributeMapUtil
final Map<CIKey, Object> metaAttributeMap = MetaAttributeMapUtil
.createAttributeMap(meta);

final List<AnalyticFieldListConsumer> fieldListConsumers = new ArrayList<>();
Expand Down Expand Up @@ -477,7 +494,7 @@ private AnalyticFieldListConsumer createLmdbConsumer(final TableBuilderAnalytic

private boolean ignoreStream(final TableBuilderAnalytic analytic,
final Meta meta,
final Map<String, Object> metaAttributeMap) {
final Map<CIKey, Object> metaAttributeMap) {
final TableBuilderAnalyticTrackerData trackerData = analytic.trackerData;
final long minStreamId = trackerData.getMinStreamId();
final long minCreateTime =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ public List<DocRef> list() {
}

@Override
public List<DocRef> findByNames(final List<String> name, final boolean allowWildCards) {
return store.findByNames(name, allowWildCards);
public List<DocRef> findByNames(final List<String> names,
final boolean allowWildCards,
final boolean isCaseSensitive) {
return store.findByNames(names, allowWildCards, isCaseSensitive);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions stroom-annotation/stroom-annotation-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependencies {
implementation project(':stroom-core-shared')
implementation project(':stroom-docref')
implementation project(':stroom-query:stroom-query-api')
implementation project(':stroom-util-shared')

implementation libs.jackson_annotations
}
Loading
Loading