All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.kuseman.payloadbuilder.api.catalog.Catalog Maven / Gradle / Ivy

The newest version!
package se.kuseman.payloadbuilder.api.catalog;

import static java.util.Collections.emptyMap;
import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import se.kuseman.payloadbuilder.api.QualifiedName;
import se.kuseman.payloadbuilder.api.catalog.Column.Type;
import se.kuseman.payloadbuilder.api.execution.IExecutionContext;
import se.kuseman.payloadbuilder.api.execution.IQuerySession;
import se.kuseman.payloadbuilder.api.execution.ISeekPredicate;
import se.kuseman.payloadbuilder.api.execution.ObjectTupleVector;
import se.kuseman.payloadbuilder.api.execution.TupleVector;

/**
 * Catalog. Defines the hooking points for retrieving data, functions etc.
 */
// CSOFF
public abstract class Catalog
// CSON
{
    public static final String SYSTEM_CATALOG_ALIAS = "sys";

    protected static final String SYS_TABLES = "tables";
    protected static final String SYS_TABLES_NAME = "name";

    protected static final String SYS_COLUMNS = "columns";
    protected static final String SYS_COLUMNS_NAME = "name";
    protected static final String SYS_COLUMNS_TABLE = "table";

    protected static final String SYS_FUNCTIONS = "functions";
    protected static final String SYS_FUNCTIONS_NAME = "name";
    protected static final String SYS_FUNCTIONS_DESCRIPTION = "description";
    protected static final String SYS_FUNCTIONS_TYPE = "type";

    protected static final String SYS_INDICES = "indices";
    protected static final String SYS_INDICES_TABLE = "table";
    protected static final String SYS_INDICES_COLUMNS = "columns";

    protected static final Schema SYS_FUNCTIONS_SCHEMA = Schema.of(Column.of(SYS_FUNCTIONS_NAME, Type.String), Column.of(SYS_FUNCTIONS_TYPE, Type.String),
            Column.of(SYS_FUNCTIONS_DESCRIPTION, Type.String));

    /** Name of the catalog */
    private final String name;
    /** Scalar functions. This also includes aggregate functions */
    private final Map scalarFunctionByName = new HashMap<>();
    /** Table functions */
    private final Map tableFunctionByName = new HashMap<>();
    /** Operator functions */
    private final Map operatorFunctionByName = new HashMap<>();

    public Catalog(String name)
    {
        this.name = requireNonNull(name, "name");
    }

    public String getName()
    {
        return name;
    }

    /**
     * Return the table schema information for provided table.
     *
     * @deprecated Use {@link #getTableSchema(IExecutionContext, String, QualifiedName, List)} instead
     */
    @Deprecated
    public TableSchema getTableSchema(IQuerySession session, String catalogAlias, QualifiedName table)
    {
        return TableSchema.EMPTY;
    }

    /**
     * Return the table schema information for provided table.
     */
    public TableSchema getTableSchema(IQuerySession session, String catalogAlias, QualifiedName table, List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy