-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ECS Namespacing Processor #124735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
ECS Namespacing Processor #124735
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d00c6e9
Adding APIs for dotted fields to IngestDocument
eyalkoren 7550fa9
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren 4a9de22
Merging and completing IngestDocument APIs
eyalkoren fb7318b
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren e6200db
Removing EcsNamespacingProcessor for now
eyalkoren 1a5186b
Small javadoc clarification
eyalkoren 08830ee
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren 011139e
Adding initial ECS namespacing processor
eyalkoren c36a109
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren 5d5d26e
Merge completion
eyalkoren 6b5bb05
Restoring minimum Gradle version
eyalkoren f6b3e4e
Restoring minimumGradleVersion
eyalkoren e4f26c3
Test
eyalkoren a689661
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren 4eaa17c
Initial microbenchmark test
eyalkoren 43b69c7
Merge remote-tracking branch 'upstream/main' into ECS-namespacing-pro…
eyalkoren d2bcd85
Merge remote-tracking branch 'eyalkoren/ECS-namespacing-processor' in…
eyalkoren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
benchmarks/src/main/java/org/elasticsearch/benchmark/ingest/FieldAccessBenchmark.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.benchmark.ingest; | ||
|
|
||
| import org.elasticsearch.index.VersionType; | ||
| import org.elasticsearch.ingest.IngestDocument; | ||
| import org.openjdk.jmh.annotations.Benchmark; | ||
| import org.openjdk.jmh.annotations.BenchmarkMode; | ||
| import org.openjdk.jmh.annotations.Fork; | ||
| import org.openjdk.jmh.annotations.Measurement; | ||
| import org.openjdk.jmh.annotations.Mode; | ||
| import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
| import org.openjdk.jmh.annotations.Scope; | ||
| import org.openjdk.jmh.annotations.State; | ||
| import org.openjdk.jmh.annotations.Warmup; | ||
| import org.openjdk.jmh.infra.Blackhole; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| @Fork(1) | ||
| @Warmup(iterations = 3) | ||
| @Measurement(iterations = 5) | ||
| @BenchmarkMode(Mode.AverageTime) | ||
| @OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
| @State(Scope.Benchmark) | ||
| public class FieldAccessBenchmark { | ||
|
|
||
| IngestDocument ingestDocument = createIngestDocument(4); | ||
|
|
||
| @Benchmark | ||
| public void dotNotationAccess(Blackhole blackhole) { | ||
| blackhole.consume(ingestDocument.getFieldValue("level1.level2.level3.level4", String.class)); | ||
| } | ||
|
|
||
| @Benchmark | ||
| public void dottedFieldAccess(Blackhole blackhole) { | ||
| // printPaths(ingestDocument.getSource(), new ArrayList<>()); | ||
| blackhole.consume(ingestDocument.getAllFieldValues("level1.level2.level3.level4", String.class)); | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| private static void printPaths(Map<String, Object> source, ArrayList<String> path) { | ||
| for (Map.Entry<String, Object> entry : source.entrySet()) { | ||
| path.add(entry.getKey()); | ||
| if (entry.getValue() instanceof Map) { | ||
| printPaths((Map<String, Object>) entry.getValue(), path); | ||
| } else { | ||
| System.out.println(String.join("|", path)); | ||
| } | ||
| path.removeLast(); | ||
| } | ||
| } | ||
|
|
||
| public static IngestDocument createIngestDocument(int maxDepth) { | ||
| if (maxDepth < 1) { | ||
| throw new IllegalArgumentException("Depth must be at least 1"); | ||
| } | ||
|
|
||
| // create a path with the given depth | ||
| StringBuilder path = new StringBuilder("level1"); | ||
| for (int i = 2; i <= maxDepth; i++) { | ||
| path.append(".level").append(i); | ||
| } | ||
| Map<String, Object> source = new HashMap<>(); | ||
| generatePermutations(source, path.toString(), 0); | ||
| return new IngestDocument("index", "id", 1L, "routing", VersionType.INTERNAL, source); | ||
| } | ||
|
|
||
| private static void generatePermutations(Map<String, Object> parentNode, String path, int startIndex) { | ||
| int nextDot = path.indexOf('.', startIndex); | ||
| if (nextDot > 0) { | ||
| // Consider the next dot as a path separator and generate paths recursively for the rest of the path | ||
| String key = path.substring(0, nextDot); | ||
| Map<String, Object> child = new HashMap<>(); | ||
| parentNode.put(key, child); | ||
| generatePermutations(child, path.substring(nextDot + 1), 0); | ||
|
|
||
| // Consider the next dot as part of the path element's name | ||
| generatePermutations(parentNode, path, nextDot + 1); | ||
| } else { | ||
| parentNode.put(path, "value" + nextDot * path.length()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 8.12.1 | ||
| 8.12.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
| apply plugin: 'elasticsearch.internal-yaml-rest-test' | ||
| apply plugin: 'elasticsearch.yaml-rest-compat-test' | ||
|
|
||
| esplugin { | ||
| description = 'Ingest processor that applies ECS namespacing' | ||
| classname ='org.elasticsearch.ingest.ecs.EcsNamespacingPlugin' | ||
| } | ||
|
|
||
| restResources { | ||
| restApi { | ||
| include '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest' | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| module org.elasticsearch.ingest.ecs { | ||
| requires org.elasticsearch.base; | ||
| requires org.elasticsearch.server; | ||
| requires org.elasticsearch.xcontent; | ||
| } |
24 changes: 24 additions & 0 deletions
24
modules/ingest-ecs/src/main/java/org/elasticsearch/ingest/ecs/EcsNamespacingPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.ingest.ecs; | ||
|
|
||
| import org.elasticsearch.ingest.Processor; | ||
| import org.elasticsearch.plugins.IngestPlugin; | ||
| import org.elasticsearch.plugins.Plugin; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class EcsNamespacingPlugin extends Plugin implements IngestPlugin { | ||
|
|
||
| @Override | ||
| public Map<String, Processor.Factory> getProcessors(Processor.Parameters parameters) { | ||
| return Map.of(EcsNamespacingProcessor.TYPE, new EcsNamespacingProcessor.Factory()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it seems relevant to this PR to have changes to this file. Can you tidy this up, please?