Class CatalogStore

Object
gudusoft.gsqlparser.sqlenv.calcite.CatalogStore

public class CatalogStore extends Object
Unified storage abstraction for catalog objects using canonical keys.

This class replaces GSP's legacy triple-index architecture (schemaObjectList + objectIndex + tablesByName) with a clean, type-aware storage system backed by LinkedHashMaps for O(1) lookups.

Key improvements over legacy storage:

  • Canonical keys eliminate string suffix hacks ($function, $procedure, etc.)
  • Per-type indexes for efficient type-specific lookups
  • Vendor-aware case sensitivity via NameService
  • Insertion order preservation for compatibility
  • Full and partial name resolution support

Thread safety: This class is NOT thread-safe. External synchronization is required if accessed from multiple threads.

Since:
3.2.0.3 (Phase 1)
  • Constructor Details

    • CatalogStore

      Creates a new CatalogStore for the specified database vendor.
      Parameters:
      vendor - the database vendor
    • CatalogStore

      public CatalogStore(EDbVendor vendor, IdentifierService identifierService)
      Creates a new CatalogStore for the specified database vendor with IdentifierService.

      This is the preferred constructor that uses IdentifierService for proper per-object-type identifier normalization.

      Parameters:
      vendor - the database vendor
      identifierService - the identifier service for normalization
      Since:
      3.2.0.3 (Phase 3.5)
  • Method Details

    • getVendor

      public EDbVendor getVendor()
      Returns the database vendor associated with this store.
      Returns:
      the database vendor
    • getNameService

      Returns the name service used by this store.
      Returns:
      the name service
    • put

      Adds or updates an object in the store.

      The object is indexed by its fully-qualified canonical name and also added to type-specific and name-only indexes for efficient lookups.

      Parameters:
      object - the schema object to add
      Returns:
      the previous object with the same key, or null if none existed
    • get

      public TSQLSchemaObject get(String catalog, String schema, String objectName, ESQLDataObjectType type)
      Finds an object by its fully-qualified name and type.

      This is an O(1) lookup using the canonical key index.

      Parameters:
      catalog - the catalog name (may be null)
      schema - the schema name (may be null)
      objectName - the object name (required)
      type - the object type
      Returns:
      the matching object, or null if not found
    • getByName

      Finds objects by name only, regardless of catalog/schema.

      This is used for partial name resolution when the full path is not specified.

      Parameters:
      objectName - the object name
      type - the object type (optional - null returns all types)
      Returns:
      list of matching objects (may be empty, never null)
    • getByType

      Finds all objects of a specific type.
      Parameters:
      type - the object type
      Returns:
      collection of all objects of that type (may be empty, never null)
    • remove

      public boolean remove(TSQLSchemaObject object)
      Removes an object from the store.
      Parameters:
      object - the object to remove
      Returns:
      true if the object was removed, false if it was not present
    • size

      public int size()
      Returns the total number of objects in the store.
      Returns:
      the total count
    • clear

      public void clear()
      Removes all objects from the store.
    • getAll

      Returns all objects in insertion order.
      Returns:
      collection of all objects (may be empty, never null)