-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Store split indices #138396
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
Store split indices #138396
Changes from all commits
a43470b
2a92340
68fac4b
f5cdcef
5800b0b
3788e2c
808b6f1
6fc3a7e
e3ee2c7
4d9f91c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 9226000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| keystore_details_in_reload_secure_settings_response,9225000 | ||
| esql_es_relation_add_split_indices,9226000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| */ | ||
| package org.elasticsearch.xpack.esql.plan.logical; | ||
|
|
||
| import org.elasticsearch.TransportVersion; | ||
| import org.elasticsearch.TransportVersions; | ||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
|
|
@@ -25,6 +26,9 @@ | |
| import java.util.Set; | ||
|
|
||
| public class EsRelation extends LeafPlan { | ||
|
|
||
| private static final TransportVersion SPLIT_INDICES = TransportVersion.fromName("esql_es_relation_add_split_indices"); | ||
|
|
||
| public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry( | ||
| LogicalPlan.class, | ||
| "EsRelation", | ||
|
|
@@ -33,19 +37,25 @@ public class EsRelation extends LeafPlan { | |
|
|
||
| private final String indexPattern; | ||
| private final IndexMode indexMode; | ||
| private final Map<String, List<String>> originalIndices; // keyed by cluster alias | ||
| private final Map<String, List<String>> concreteIndices; // keyed by cluster alias | ||
| private final Map<String, IndexMode> indexNameWithModes; | ||
| private final List<Attribute> attrs; | ||
|
|
||
| public EsRelation( | ||
| Source source, | ||
| String indexPattern, | ||
| IndexMode indexMode, | ||
| Map<String, List<String>> originalIndices, | ||
| Map<String, List<String>> concreteIndices, | ||
| Map<String, IndexMode> indexNameWithModes, | ||
| List<Attribute> attributes | ||
| ) { | ||
| super(source); | ||
| this.indexPattern = indexPattern; | ||
| this.indexMode = indexMode; | ||
| this.originalIndices = originalIndices; | ||
| this.concreteIndices = concreteIndices; | ||
| this.indexNameWithModes = indexNameWithModes; | ||
| this.attrs = attributes; | ||
| } | ||
|
|
@@ -57,13 +67,22 @@ private static EsRelation readFrom(StreamInput in) throws IOException { | |
| // this used to be part of EsIndex deserialization | ||
| in.readImmutableMap(StreamInput::readString, EsField::readFrom); | ||
| } | ||
| Map<String, List<String>> originalIndices; | ||
| Map<String, List<String>> concreteIndices; | ||
| if (in.getTransportVersion().supports(SPLIT_INDICES)) { | ||
| originalIndices = in.readMapOfLists(StreamInput::readString); | ||
| concreteIndices = in.readMapOfLists(StreamInput::readString); | ||
| } else { | ||
| originalIndices = Map.of(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This scares me a bit, but I think it's fine. Will a remote need this information to execute the plan fragment? One day, when we start supporting nested sub-queries and maybe multi-step coordination (ie. when the remote cluster will become a "secondary" master, potentially sending a fragment to a third cluster), the primary master will still be unable to coordinate such queries if it's on an older version, so we'll always be sure that we have the two maps. My conclusion is that it's all good, but I wanted to write it down, in case it rings a bell.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct. Remotes/data nodes do not need this information, at least today. I will add a note that this information is only available in recent versions. |
||
| concreteIndices = Map.of(); | ||
| } | ||
| Map<String, IndexMode> indexNameWithModes = in.readMap(IndexMode::readFrom); | ||
| List<Attribute> attributes = in.readNamedWriteableCollectionAsList(Attribute.class); | ||
| IndexMode indexMode = IndexMode.fromString(in.readString()); | ||
| if (in.getTransportVersion().supports(TransportVersions.V_8_18_0) == false) { | ||
| in.readBoolean(); | ||
| } | ||
| return new EsRelation(source, indexPattern, indexMode, indexNameWithModes, attributes); | ||
| return new EsRelation(source, indexPattern, indexMode, originalIndices, concreteIndices, indexNameWithModes, attributes); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -74,6 +93,10 @@ public void writeTo(StreamOutput out) throws IOException { | |
| // this used to be part of EsIndex serialization | ||
| out.writeMap(Map.<String, EsField>of(), (o, x) -> x.writeTo(out)); | ||
| } | ||
| if (out.getTransportVersion().supports(SPLIT_INDICES)) { | ||
| out.writeMap(originalIndices, StreamOutput::writeStringCollection); | ||
| out.writeMap(concreteIndices, StreamOutput::writeStringCollection); | ||
| } | ||
| out.writeMap(indexNameWithModes, (o, v) -> IndexMode.writeTo(v, out)); | ||
| out.writeNamedWriteableCollection(attrs); | ||
| out.writeString(indexMode.getName()); | ||
|
|
@@ -89,7 +112,7 @@ public String getWriteableName() { | |
|
|
||
| @Override | ||
| protected NodeInfo<EsRelation> info() { | ||
| return NodeInfo.create(this, EsRelation::new, indexPattern, indexMode, indexNameWithModes, attrs); | ||
| return NodeInfo.create(this, EsRelation::new, indexPattern, indexMode, originalIndices, concreteIndices, indexNameWithModes, attrs); | ||
| } | ||
|
|
||
| public String indexPattern() { | ||
|
|
@@ -100,6 +123,14 @@ public IndexMode indexMode() { | |
| return indexMode; | ||
| } | ||
|
|
||
| public Map<String, List<String>> originalIndices() { | ||
| return originalIndices; | ||
| } | ||
|
|
||
| public Map<String, List<String>> concreteIndices() { | ||
| return concreteIndices; | ||
| } | ||
|
|
||
| public Map<String, IndexMode> indexNameWithModes() { | ||
| return indexNameWithModes; | ||
| } | ||
|
|
@@ -109,7 +140,7 @@ public List<Attribute> output() { | |
| return attrs; | ||
| } | ||
|
|
||
| public Set<String> concreteIndices() { | ||
| public Set<String> concreteQualifiedIndices() { | ||
| return indexNameWithModes.keySet(); | ||
| } | ||
|
|
||
|
|
@@ -122,7 +153,7 @@ public boolean expressionsResolved() { | |
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(indexPattern, indexMode, indexNameWithModes, attrs); | ||
| return Objects.hash(indexPattern, indexMode, originalIndices, concreteIndices, indexNameWithModes, attrs); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -138,6 +169,8 @@ public boolean equals(Object obj) { | |
| EsRelation other = (EsRelation) obj; | ||
| return Objects.equals(indexPattern, other.indexPattern) | ||
| && Objects.equals(indexMode, other.indexMode) | ||
| && Objects.equals(originalIndices, other.originalIndices) | ||
| && Objects.equals(concreteIndices, other.concreteIndices) | ||
| && Objects.equals(indexNameWithModes, other.indexNameWithModes) | ||
| && Objects.equals(attrs, other.attrs); | ||
| } | ||
|
|
@@ -153,10 +186,10 @@ public String nodeString() { | |
| } | ||
|
|
||
| public EsRelation withAttributes(List<Attribute> newAttributes) { | ||
| return new EsRelation(source(), indexPattern, indexMode, indexNameWithModes, newAttributes); | ||
| return new EsRelation(source(), indexPattern, indexMode, originalIndices, concreteIndices, indexNameWithModes, newAttributes); | ||
| } | ||
|
|
||
| public EsRelation withIndexMode(IndexMode indexMode) { | ||
| return new EsRelation(source(), indexPattern, indexMode, indexNameWithModes, attrs); | ||
| return new EsRelation(source(), indexPattern, indexMode, originalIndices, concreteIndices, indexNameWithModes, attrs); | ||
| } | ||
| } | ||
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.
👍
Will these all be qualified also in CPS? I mean, will local indices have an
_origin:prefix? I'm just asking to learn, but I thinkconcreteQualifiedIndicesis a good method name even if they won't.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 believe local indices will not have
_originprefix, only remote will have prefixes. I will confirm this once we are able to run CPS query.