MCPcopy Create free account
hub / github.com/crate/crate / ScopedSymbol

Class ScopedSymbol

server/src/main/java/io/crate/expression/symbol/ScopedSymbol.java:53–174  ·  view source on GitHub ↗

A symbol that associates another symbol with a relation. {@code DocTableRelation | outputs: [Reference(x)] | SELECT t1.x, t2.x FROM tbl AS t1, tbl AS t2 | ~~~~~~~~~

Source from the content-addressed store, hash-verified

51 * </pre>
52 */
53public final class ScopedSymbol implements Symbol, ScopedColumn {
54
55 private final RelationName relation;
56 private final ColumnIdent column;
57 private final DataType<?> dataType;
58
59 /**
60 * Used to disambiguate columns with the same name.
61 **/
62 private final int identity;
63
64 /**
65 * <p>
66 * Creates a ScopedSymbol describing output from a relation.
67 * E.g. in the case of UNION its a stand-in for two symbols from the two child
68 * relations.
69 * </p>
70 *
71 * Use the {@link #ScopedSymbol(RelationName, ColumnIdent, Symbol)} constructor
72 * if the symbol is pointing to a single specific symbol of a child relation
73 *
74 * @param relation owner of this symbol
75 * @param column name of the symbol
76 **/
77 public ScopedSymbol(RelationName relation, ColumnIdent column, DataType<?> dataType) {
78 this.relation = relation;
79 this.column = column;
80 this.dataType = dataType;
81 this.identity = 0;
82 }
83
84 /**
85 * Creates a ScopedSymbol describing the output from a relation, pointing to a single specific symbol of a child
86 * relation.
87 * <p>
88 * It uses the hashCode of the symbol to disambiguate columns with the same name but different source relations.
89 * Using the identity of the symbol is not possible because dynamic or void references are not cached and are
90 * created on the fly on every look up. This would lead to different identities for the same symbol.
91 * </p>
92 *
93 * @param relation owner of this symbol
94 * @param column name of the symbol
95 * @param symbol the symbol this ScopedSymbol is pointing towards
96 **/
97 public ScopedSymbol(RelationName relation, ColumnIdent column, Symbol symbol) {
98 this.relation = relation;
99 this.column = column;
100 this.dataType = symbol.valueType();
101 this.identity = symbol.hashCode();
102 }
103
104 public RelationName relation() {
105 return relation;
106 }
107
108 public ColumnIdent column() {
109 return column;
110 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected