public RelOptTableImpl getTable(final String[] names) { List<Pair<String, Object>> pairs = new ArrayList<Pair<String, Object>>(); Schema schema2 = schema; for (int i = 0; i < names.length; i++) { final String name = names[i]; Schema subSchema = schema2.getSubSchema(name); if (subSchema != null) { pairs.add(Pair.<String, Object>of(name, subSchema)); schema2 = subSchema; continue; } final Table table = schema2.getTable(name); if (table != null) { pairs.add(Pair.<String, Object>of(name, table)); if (i != names.length - 1) { // not enough objects to match all names return null; } return new RelOptTableImpl( this, typeFactory.createType(table.getElementType()), names, table); } return null; } return null; }
/** Creates a result based on a single relational expression. */ public Result result(SqlNode node, Collection<Clause> clauses, RelNode rel) { final String alias2 = SqlValidatorUtil.getAlias(node, -1); final String alias3 = alias2 != null ? alias2 : "t"; final String alias4 = SqlValidatorUtil.uniquify(alias3, aliasSet, SqlValidatorUtil.EXPR_SUGGESTER); final String alias5 = alias2 == null || !alias2.equals(alias4) ? alias4 : null; return new Result( node, clauses, alias5, Collections.singletonList(Pair.of(alias4, rel.getRowType()))); }
private List<Object> getList(List<Pair<String, Object>> values, String tag) { for (Pair<String, Object> value : values) { if (value.left.equals(tag)) { //noinspection unchecked return (List<Object>) value.right; } } final List<Object> list = new ArrayList<Object>(); values.add(Pair.of(tag, (Object) list)); return list; }
public Object freeze(ColumnLoader.ValueSet valueSet) { final int n = valueSet.map.keySet().size(); int extra = valueSet.containsNull ? 1 : 0; Comparable[] codeValues = valueSet.map.keySet().toArray(new Comparable[n + extra]); Arrays.sort(codeValues, 0, n); ColumnLoader.ValueSet codeValueSet = new ColumnLoader.ValueSet(int.class); for (Comparable value : valueSet.values) { int code; if (value == null) { code = n; } else { code = Arrays.binarySearch(codeValues, value); assert code >= 0 : code + ", " + value; } codeValueSet.add(code); } Object codes = representation.freeze(codeValueSet); return Pair.of(codes, codeValues); }
public RelWriter item(String term, Object value) { values.add(Pair.of(term, value)); return this; }
public Object freeze(ColumnLoader.ValueSet valueSet) { final int size = valueSet.values.size(); return Pair.of(size == 0 ? null : valueSet.values.get(0), size); }
public void addColumn(String name, RelDataType type) { columnList.add(Pair.of(name, type)); }
public void addColumn(int index, String name, RelDataType type) { columnList.add(index, Pair.of(name, type)); }