-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We want it in a few places.
- Loading branch information
Showing
11 changed files
with
191 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
62 changes: 62 additions & 0 deletions
62
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/DefaultLayout.java
This file contains 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,62 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.planner; | ||
|
||
import org.elasticsearch.xpack.ql.expression.NameId; | ||
|
||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
class DefaultLayout implements Layout { | ||
private final Map<NameId, ChannelAndType> layout; | ||
private final int numberOfChannels; | ||
|
||
DefaultLayout(Map<NameId, ChannelAndType> layout, int numberOfChannels) { | ||
this.layout = layout; | ||
this.numberOfChannels = numberOfChannels; | ||
} | ||
|
||
@Override | ||
public ChannelAndType get(NameId id) { | ||
return layout.get(id); | ||
} | ||
|
||
/** | ||
* @return the total number of channels in the layout. | ||
*/ | ||
@Override | ||
public int numberOfChannels() { | ||
return numberOfChannels; | ||
} | ||
|
||
@Override | ||
public Map<Integer, Set<NameId>> inverse() { | ||
Map<Integer, Set<NameId>> inverse = new HashMap<>(); | ||
for (Map.Entry<NameId, ChannelAndType> entry : layout.entrySet()) { | ||
NameId key = entry.getKey(); | ||
Integer value = entry.getValue().channel(); | ||
inverse.computeIfAbsent(value, k -> new HashSet<>()).add(key); | ||
} | ||
return inverse; | ||
} | ||
|
||
/** | ||
* @return creates a builder to append to this layout. | ||
*/ | ||
@Override | ||
public Layout.Builder builder() { | ||
return new Builder(numberOfChannels, layout); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Layout{" + "layout=" + layout + ", numberOfChannels=" + numberOfChannels + '}'; | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.