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

com.hazelcast.org.apache.calcite.schema.impl.AbstractSchema Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in com.hazelcast.com.liance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.com.hazelcast.org.licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hazelcast.org.apache.calcite.schema.impl;

import com.hazelcast.org.apache.calcite.linq4j.tree.Expression;
import com.hazelcast.org.apache.calcite.rel.type.RelProtoDataType;
import com.hazelcast.org.apache.calcite.schema.Function;
import com.hazelcast.org.apache.calcite.schema.Schema;
import com.hazelcast.org.apache.calcite.schema.SchemaFactory;
import com.hazelcast.org.apache.calcite.schema.SchemaPlus;
import com.hazelcast.org.apache.calcite.schema.SchemaVersion;
import com.hazelcast.org.apache.calcite.schema.Schemas;
import com.hazelcast.org.apache.calcite.schema.Table;

import com.hazelcast.com.google.com.hazelcast.com.on.collect.ImmutableMap;
import com.hazelcast.com.google.com.hazelcast.com.on.collect.ImmutableMultimap;
import com.hazelcast.com.google.com.hazelcast.com.on.collect.Multimap;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Abstract implementation of {@link Schema}.
 *
 * 

Behavior is as follows:

*
    *
  • The schema has no tables unless you override * {@link #getTableMap()}.
  • *
  • The schema has no functions unless you override * {@link #getFunctionMultimap()}.
  • *
  • The schema has no sub-schemas unless you override * {@link #getSubSchemaMap()}.
  • *
  • The schema is mutable unless you override * {@link #isMutable()}.
  • *
  • The name and parent schema are as specified in the constructor * arguments.
  • *
*/ public class AbstractSchema implements Schema { public AbstractSchema() { } public boolean isMutable() { return true; } public Schema snapshot(SchemaVersion version) { return this; } public Expression getExpression(SchemaPlus parentSchema, String name) { return Schemas.subSchemaExpression(parentSchema, name, getClass()); } /** * Returns a map of tables in this schema by name. * *

The implementations of {@link #getTableNames()} * and {@link #getTable(String)} depend on this map. * The default implementation of this method returns the empty map. * Override this method to change their behavior.

* * @return Map of tables in this schema by name */ protected Map getTableMap() { return ImmutableMap.of(); } public final Set getTableNames() { return getTableMap().keySet(); } public final Table getTable(String name) { return getTableMap().get(name); } /** * Returns a map of types in this schema by name. * *

The implementations of {@link #getTypeNames()} * and {@link #getType(String)} depend on this map. * The default implementation of this method returns the empty map. * Override this method to change their behavior.

* * @return Map of types in this schema by name */ protected Map getTypeMap() { return ImmutableMap.of(); } public RelProtoDataType getType(String name) { return getTypeMap().get(name); } public Set getTypeNames() { return getTypeMap().keySet(); } /** * Returns a multi-map of functions in this schema by name. * It is a multi-map because functions are overloaded; there may be more than * one function in a schema with a given name (as long as they have different * parameter lists). * *

The implementations of {@link #getFunctionNames()} * and {@link Schema#getFunctions(String)} depend on this map. * The default implementation of this method returns the empty multi-map. * Override this method to change their behavior.

* * @return Multi-map of functions in this schema by name */ protected Multimap getFunctionMultimap() { return ImmutableMultimap.of(); } public final Collection getFunctions(String name) { return getFunctionMultimap().get(name); // never null } public final Set getFunctionNames() { return getFunctionMultimap().keySet(); } /** * Returns a map of sub-schemas in this schema by name. * *

The implementations of {@link #getSubSchemaNames()} * and {@link #getSubSchema(String)} depend on this map. * The default implementation of this method returns the empty map. * Override this method to change their behavior.

* * @return Map of sub-schemas in this schema by name */ protected Map getSubSchemaMap() { return ImmutableMap.of(); } public final Set getSubSchemaNames() { return getSubSchemaMap().keySet(); } public final Schema getSubSchema(String name) { return getSubSchemaMap().get(name); } /** Schema factory that creates an * {@link com.hazelcast.org.apache.calcite.schema.impl.AbstractSchema}. */ public static class Factory implements SchemaFactory { public static final Factory INSTANCE = new Factory(); private Factory() {} public Schema create(SchemaPlus parentSchema, String name, Map operand) { return new AbstractSchema(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy