문서 탐색 열기
R2D1 / 문서

JDBC IndexStore

JdbcIndexStore는 blocking JDBC database를 R2D1의 asynchronous IndexStore SPI에 연결합니다. document identifier와 indexed field projection만 저장하고 authoritative serialized document는 선택한 DocumentStore에 남깁니다.

지원 database

built-in dialect는 정확한 JDBC product name으로 선택됩니다. 다른 product는 schema mutation 전에 실패합니다. JDBC driver 세 개는 module에 포함되지 않으며 애플리케이션의 DataSource가 선택한 driver를 제공합니다.

Database지원 topology
H2persistent embedded file, TCP server
HSQLDBpersistent embedded file, HSQL server
SQLitelocal persistent embedded file only

생성

애플리케이션 소유 DataSource와 blocking JDBC 작업을 위한 bounded execution resource를 전달합니다.

implementation("dev.nexcraft:r2d1-jdbc:<version>")

DataSource와 execution 소유권

JdbcIndexStore는 DataSource와 JdbcExecution을 소유하거나 닫지 않습니다. JdbcExecution.create(...)가 만든 executor는 creator가 닫고, JdbcExecution.using(...)은 caller-owned executor를 닫지 않습니다.

DataSource dataSource = applicationDataSource;

try (JdbcExecution execution = JdbcExecution.create(4, 64)) {
  JdbcIndexStore indexes = new JdbcIndexStore(dataSource, execution);
  // Pass indexes and indexes::initialize to PersistenceCollectionFactory.
}

Execution mode

기본은 platform thread입니다. Java 25 이상에서 virtual thread를 명시적으로 선택할 수 있으며 조용히 fallback하지 않습니다. maxConcurrency와 maxPending은 실행/admission 한도이지 physical connection 수나 pool을 바꾸지 않습니다.

JdbcExecutionConfig config =
    new JdbcExecutionConfig(JdbcExecutionMode.VIRTUAL_THREAD, 100, 500);
JdbcExecution execution = JdbcExecution.create(config);

Schema와 SQLite 경계

각 collection은 document_id primary key와 @Index 필드별 required column을 가진 table로 매핑됩니다. 지원 logical value는 String, long/Long, double/Double, boolean/Boolean이며 indexed value는 write 시 non-null이어야 합니다.

SQLite는 local persistent file database만 지원합니다. remote SQLite service가 아닙니다. 한 JdbcIndexStore instance 안에서 write를 조정하지만 별도 instance나 외부 process는 SQLite locking에 따릅니다.