Class SqliteDialect

java.lang.Object
io.agentscope.extensions.jdbc.dialect.AbstractJdbcDialect
io.agentscope.extensions.jdbc.dialect.vendor.SqliteDialect
All Implemented Interfaces:
SandboxLockStrategy, SessionStateDialect, SnapshotDialect, StoreDialect

public class SqliteDialect extends AbstractJdbcDialect
SQLite dialect.

Uses SQLite-native TEXT/INTEGER types. UPSERT uses ON CONFLICT DO UPDATE (requires SQLite 3.24+). Table-existence check uses sqlite_master.

Author:
shanhongyu
  • Constructor Details

    • SqliteDialect

      public SqliteDialect()
  • Method Details

    • storeCreateTableDdls

      public List<String> storeCreateTableDdls()
      Description copied from interface: StoreDialect
      DDL statements (one or more) to create the KV store table. Must be idempotent.
    • storeUpsert

      public BoundSql storeUpsert(String namespacePath, String key, String json, long timestamp)
      Description copied from interface: StoreDialect
      UPSERT: insert new row with version=1 or update existing row with version+1.
    • sessionStateCreateTableDdls

      public List<String> sessionStateCreateTableDdls()
      Description copied from interface: SessionStateDialect
      DDL statements (one or more) to create the sessions table. Must be idempotent.
    • sessionStateUpsert

      public BoundSql sessionStateUpsert(String sessionId, String stateKey, int itemIndex, String stateData)
      Description copied from interface: SessionStateDialect
      UPSERT a single state value. On conflict, updates state_data.
    • sessionStateCheckTableExists

      public BoundSql sessionStateCheckTableExists(String tableName)
      Description copied from interface: SessionStateDialect
      Table-existence probe SQL. One bind param: the table name.
    • snapshotCreateTableDdls

      public List<String> snapshotCreateTableDdls()
      Description copied from interface: SnapshotDialect
      DDL statements (one or more) to create the snapshots table. Must be idempotent.
    • snapshotUpsert

      public BoundSql snapshotUpsert(String snapshotId, InputStream data)
      Description copied from interface: SnapshotDialect
      Idempotent UPSERT for uploading a snapshot.

      The data param is bound as a binary stream via PreparedStatement.setBinaryStream(int, InputStream) by the client, so snapshots of arbitrary size are streamed straight to the database without loading the whole archive into heap memory.

    • supports

      public boolean supports(DatabaseMetaData metaData) throws SQLException
      Description copied from class: AbstractJdbcDialect
      Whether this dialect supports the target database.
      Specified by:
      supports in class AbstractJdbcDialect
      Parameters:
      metaData - JDBC metadata (connection stays open)
      Returns:
      true if this dialect handles the database
      Throws:
      SQLException - if metadata reading fails