use of org.apache.calcite.util.NameSet in project calcite by apache.
the class CachingCalciteSchema method addImplicitFunctionsToBuilder.
protected void addImplicitFunctionsToBuilder(ImmutableList.Builder<Function> builder, String name, boolean caseSensitive) {
// Add implicit functions, case-insensitive.
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String name2 : set.range(name, caseSensitive)) {
final Collection<Function> functions = schema.getFunctions(name2);
if (functions != null) {
builder.addAll(functions);
}
}
}
use of org.apache.calcite.util.NameSet in project calcite by apache.
the class CachingCalciteSchema method addImplicitFuncNamesToBuilder.
protected void addImplicitFuncNamesToBuilder(ImmutableSortedSet.Builder<String> builder) {
// Add implicit functions, case-sensitive.
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
builder.addAll(set.iterable());
}
use of org.apache.calcite.util.NameSet in project calcite by apache.
the class CachingCalciteSchema method getImplicitTable.
protected TableEntry getImplicitTable(String tableName, boolean caseSensitive) {
final long now = System.currentTimeMillis();
final NameSet implicitTableNames = implicitTableCache.get(now);
for (String tableName2 : implicitTableNames.range(tableName, caseSensitive)) {
final Table table = schema.getTable(tableName2);
if (table != null) {
return tableEntry(tableName2, table);
}
}
return null;
}
use of org.apache.calcite.util.NameSet in project calcite by apache.
the class CachingCalciteSchema method addImplicitTablesBasedOnNullaryFunctionsToBuilder.
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(ImmutableSortedMap.Builder<String, Table> builder) {
ImmutableSortedMap<String, Table> explicitTables = builder.build();
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.iterable()) {
// explicit table wins.
if (explicitTables.containsKey(s)) {
continue;
}
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro && function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
builder.put(s, table);
}
}
}
}
use of org.apache.calcite.util.NameSet in project calcite by apache.
the class CachingCalciteSchema method getImplicitTableBasedOnNullaryFunction.
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) {
final long now = System.currentTimeMillis();
final NameSet set = implicitFunctionCache.get(now);
for (String s : set.range(tableName, caseSensitive)) {
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro && function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
return tableEntry(tableName, table);
}
}
}
return null;
}
Aggregations