Class InMemoryCatalog

  • All Implemented Interfaces:
    Catalog

    public class InMemoryCatalog
    extends java.lang.Object
    implements Catalog
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected @Nullable java.lang.String currentDatabase  
      protected java.util.Map<java.lang.String,​TableProvider> tableProviders  
      • Fields inherited from interface org.apache.beam.sdk.extensions.sql.meta.catalog.Catalog

        DEFAULT
    • Constructor Summary

      Constructors 
      Constructor Description
      InMemoryCatalog​(java.lang.String name, java.util.Map<java.lang.String,​java.lang.String> properties)  
      InMemoryCatalog​(java.lang.String name, MetaStore defaultMetastore, java.util.Map<java.lang.String,​java.lang.String> properties)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean createDatabase​(java.lang.String database)
      Creates a database with this name.
      @Nullable java.lang.String currentDatabase()
      Produces the currently active database.
      boolean databaseExists​(java.lang.String db)
      Returns true if the database exists.
      java.util.Collection<java.lang.String> databases()
      Returns a collection of existing database names.
      boolean dropDatabase​(java.lang.String database, boolean cascade)
      Drops the database with this name.
      MetaStore metaStore​(java.lang.String db)
      Returns the underlying MetaStore for this database.
      java.lang.String name()
      The name of this catalog, specified by the user.
      java.util.Map<java.lang.String,​java.lang.String> properties()
      User-specified configuration properties.
      void registerTableProvider​(TableProvider provider)
      Registers this TableProvider and propagates it to underlying MetaStores.
      java.util.Map<java.lang.String,​TableProvider> tableProviders()
      Returns all the TableProviders available to this Catalog, organized by type.
      java.lang.String toString()  
      java.lang.String type()
      A type that defines this catalog.
      void useDatabase​(java.lang.String database)
      Switches to use the specified database.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • tableProviders

        protected final java.util.Map<java.lang.String,​TableProvider> tableProviders
      • currentDatabase

        protected @Nullable java.lang.String currentDatabase
    • Constructor Detail

      • InMemoryCatalog

        public InMemoryCatalog​(java.lang.String name,
                               java.util.Map<java.lang.String,​java.lang.String> properties)
      • InMemoryCatalog

        public InMemoryCatalog​(java.lang.String name,
                               MetaStore defaultMetastore,
                               java.util.Map<java.lang.String,​java.lang.String> properties)
    • Method Detail

      • type

        public java.lang.String type()
        Description copied from interface: Catalog
        A type that defines this catalog.
        Specified by:
        type in interface Catalog
      • name

        public java.lang.String name()
        Description copied from interface: Catalog
        The name of this catalog, specified by the user.
        Specified by:
        name in interface Catalog
      • metaStore

        public MetaStore metaStore​(java.lang.String db)
        Description copied from interface: Catalog
        Returns the underlying MetaStore for this database. Creates a new MetaStore if one does not exist yet.
        Specified by:
        metaStore in interface Catalog
      • properties

        public java.util.Map<java.lang.String,​java.lang.String> properties()
        Description copied from interface: Catalog
        User-specified configuration properties.
        Specified by:
        properties in interface Catalog
      • createDatabase

        public boolean createDatabase​(java.lang.String database)
        Description copied from interface: Catalog
        Creates a database with this name.
        Specified by:
        createDatabase in interface Catalog
        Returns:
        true if the database was created, false otherwise.
      • databaseExists

        public boolean databaseExists​(java.lang.String db)
        Description copied from interface: Catalog
        Returns true if the database exists.
        Specified by:
        databaseExists in interface Catalog
      • useDatabase

        public void useDatabase​(java.lang.String database)
        Description copied from interface: Catalog
        Switches to use the specified database.
        Specified by:
        useDatabase in interface Catalog
      • currentDatabase

        public @Nullable java.lang.String currentDatabase()
        Description copied from interface: Catalog
        Produces the currently active database. Can be null if no database is active.
        Specified by:
        currentDatabase in interface Catalog
        Returns:
        the current active database
      • databases

        public java.util.Collection<java.lang.String> databases()
        Description copied from interface: Catalog
        Returns a collection of existing database names.
        Specified by:
        databases in interface Catalog
      • dropDatabase

        public boolean dropDatabase​(java.lang.String database,
                                    boolean cascade)
        Description copied from interface: Catalog
        Drops the database with this name. If cascade is true, the catalog should first drop all tables contained in this database.
        Specified by:
        dropDatabase in interface Catalog
        Returns:
        true if the database was dropped, false otherwise.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object