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

Class InputColumn

server/src/main/java/io/crate/expression/symbol/InputColumn.java:42–145  ·  view source on GitHub ↗

A symbol which represents a column of a result array

Source from the content-addressed store, hash-verified

40 * A symbol which represents a column of a result array
41 */
42public class InputColumn implements Symbol, Comparable<InputColumn> {
43
44 private final DataType<?> dataType;
45 private final int index;
46
47 /**
48 * Map each data type to an {@link InputColumn} with an index corresponding to the data type's position in the list.
49 */
50 public static List<Symbol> mapToInputColumns(List<DataType<?>> dataTypes) {
51 List<Symbol> inputColumns = new ArrayList<>(dataTypes.size());
52 for (int i = 0; i < dataTypes.size(); i++) {
53 inputColumns.add(new InputColumn(i, dataTypes.get(i)));
54 }
55 return inputColumns;
56 }
57
58 /**
59 * Map each symbol to an {@link InputColumn} with an index corresponding to the symbol's position in the collection.
60 */
61 public static List<Symbol> mapToInputColumns(Collection<? extends Symbol> symbols) {
62 List<Symbol> inputColumns = new ArrayList<>(symbols.size());
63 int idx = 0;
64 for (Symbol symbol : symbols) {
65 inputColumns.add(new InputColumn(idx, symbol.valueType()));
66 idx++;
67 }
68 return inputColumns;
69 }
70
71 public InputColumn(int index, @Nullable DataType<?> dataType) {
72 assert index >= 0 : "index must be >= 0";
73 this.index = index;
74 this.dataType = Objects.requireNonNullElse(dataType, DataTypes.UNDEFINED);
75 }
76
77 public InputColumn(StreamInput in) throws IOException {
78 index = in.readVInt();
79 dataType = DataTypes.fromStream(in);
80 }
81
82 public InputColumn(int index) {
83 this(index, null);
84 }
85
86 public int index() {
87 return index;
88 }
89
90 @Override
91 public SymbolType symbolType() {
92 return SymbolType.INPUT_COLUMN;
93 }
94
95 @Override
96 public DataType<?> valueType() {
97 return dataType;
98 }
99

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected