Search in sources :

Example 1 with NameSet

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);
        }
    }
}
Also used : Function(org.apache.calcite.schema.Function) NameSet(org.apache.calcite.util.NameSet)

Example 2 with NameSet

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());
}
Also used : NameSet(org.apache.calcite.util.NameSet)

Example 3 with NameSet

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;
}
Also used : Table(org.apache.calcite.schema.Table) NameSet(org.apache.calcite.util.NameSet)

Example 4 with NameSet

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);
            }
        }
    }
}
Also used : Function(org.apache.calcite.schema.Function) TableMacro(org.apache.calcite.schema.TableMacro) Table(org.apache.calcite.schema.Table) NameSet(org.apache.calcite.util.NameSet)

Example 5 with NameSet

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;
}
Also used : Function(org.apache.calcite.schema.Function) TableMacro(org.apache.calcite.schema.TableMacro) Table(org.apache.calcite.schema.Table) NameSet(org.apache.calcite.util.NameSet)

Aggregations

NameSet (org.apache.calcite.util.NameSet)6 Function (org.apache.calcite.schema.Function)3 Table (org.apache.calcite.schema.Table)3 TableMacro (org.apache.calcite.schema.TableMacro)2