Interface StoreDialect

All Known Implementing Classes:
AbstractJdbcDialect, H2Dialect, MysqlDialect, PostgresDialect, SqliteDialect

public interface StoreDialect
Table-domain dialect interface for the KV store table.

Defines the create-schema DDL (abstract, varies per database) and ANSI-standard business SQL (default methods returning BoundSql). The aggregate class AbstractJdbcDialect implements this interface along with the other table-domain interfaces; vendor classes extend the aggregate and override only what differs.

Method names are prefixed with store to avoid collision when the aggregate class implements multiple table-domain interfaces.

Secondary index: the namespace_path LIKE 'prefix%' query in storeSearch(java.lang.String, int, int) requires an index on namespace_path to avoid a full table scan on large stores. Where the database supports it (MySQL), vendors inline INDEX idx_namespace (namespace_path) in the CREATE TABLE statement; the others append an idempotent CREATE INDEX IF NOT EXISTS as a second element of the storeCreateTableDdls() list.

Author:
shanhongyu
  • Method Details

    • storeTableName

      default String storeTableName()
      Base table name (without prefix).
    • storeCreateTableDdls

      List<String> storeCreateTableDdls()
      DDL statements (one or more) to create the KV store table. Must be idempotent.
    • storeUpsert

      BoundSql storeUpsert(String namespacePath, String key, String json, long timestamp)
      UPSERT: insert new row with version=1 or update existing row with version+1.
    • storeInsert

      default BoundSql storeInsert(String namespacePath, String key, String json, long timestamp)
      INSERT for create-only writes (version starts at 1). PK violation = row exists.
    • storeCasUpdate

      default BoundSql storeCasUpdate(String json, long timestamp, String namespacePath, String key, long expectedVersion)
      Conditional UPDATE for CAS path. Returns affected-row count (1=success).
    • storeSelect

      default BoundSql storeSelect(String namespacePath, String key)
      Single-item SELECT. Projection: (value_json, version).
    • storeDelete

      default BoundSql storeDelete(String namespacePath, String key)
      Single-item DELETE.
    • storeSearch

      default BoundSql storeSearch(String likePattern, int limit, int offset)
      Namespace-prefix search with pagination. Projection: (item_key, value_json, version).
    • storeLikeEscapeChar

      default char storeLikeEscapeChar()
      Escape character for LIKE patterns in storeSearch(java.lang.String, int, int).