diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fcb66bc5..44e43815 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -9,6 +9,6 @@ See [CONTRIBUTING.md](https://github.com/dfa1/rocksdb-ffm/blob/main/CONTRIBUTING - [ ] Tests use JUnit 5 + AssertJ with `@TempDir`, and every test follows `// Given` / `// When` / `// Then` - [ ] `./mvnw test` passes - [ ] `./mvnw package -pl core -am -DskipTests` passes (Javadoc fails the build on any error or warning) -- [ ] New native bindings: `private static final` `MH_` fields, each with its ``/// `` `` comment from `c.h` +- [ ] New native bindings: `private static final` `MH_` fields, each with its ``/// `` `` comment from `c.h`, initialized inline with `NativeLibrary.downcall(` - [ ] `CHANGELOG.md` has a line under `## [Unreleased]` linking this PR (and the issue, if any), ending with `— thanks [@your-handle](https://github.com/your-handle)` if you're an external contributor - [ ] Docs updated in the matching [Diátaxis](https://diataxis.fr/) page (tutorial / how-to / reference / explanation), snippets compile against `core` diff --git a/AGENTS.md b/AGENTS.md index 77d5c966..c1d1c4b9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,7 +42,7 @@ Every class wrapping a native pointer **must** implement `AutoCloseable`. throw `IllegalStateException`. - **Immortal defaults:** a default object that a native call only reads or copies (e.g. the `Options` behind `ColumnFamilyDescriptor.of(name)`, `TransactionOptions` for `beginTransaction(WriteOptions)`) is a single - package-private `static final X DEFAULTS = newX().makeImmortal();` declared after the class's `MH_` static block, not + package-private `static final X DEFAULTS = newX().makeImmortal();` declared after the class's `MH_` fields, not created and closed per call. `makeImmortal()` makes its `close()` a no-op while `ptr()` keeps working, so an accidental `close()` can't break every later caller. Never use it for an object a native call retains, mutates, or takes ownership of — verify against `db/c.cc` that the call copies (e.g. `ColumnFamilyOptions(opt->rep)`). @@ -250,7 +250,15 @@ type (`ReadWriteDB`, `TtlDB`, …) or its capability interface, not on `RocksDB` - always keep the MethodHandles private static final - never pass a `MethodHandle` as a method parameter, even internally: `invokeExact` on a `static final` field lets the JIT treat the target as a compile-time constant; routed through a parameter, that constant-folding is lost. Each call site must invoke its own `MH_` field directly, even if that means near-duplicate call sites instead of one shared helper - **Documented exception:** any class with the same cold-path, no-arg-getter/single-primitive-setter shape — every `*Options` class, plus [StatisticsHistogramData], [SstFileManager], [Env], [Cache], [Replayer], [ColumnFamilyHandle], [Snapshot], [WriteBufferManager], and the read-only event-listener payload views ([CompactionJobInfo], [FlushJobInfo], [MemTableInfo], [ExternalFileIngestionInfo]) that have at least one plain-shape field — routes through the static helpers on `NativeFields` instead of inlining its own `try { mh.invokeExact(...) } catch (Throwable t) { ... }` at every call site: `NativeFields.getInt(mh, ptr())`, `NativeFields.setInt(mh, ptr(), value)`, and the same pattern for `getLong`/`setLong`, `getDouble`/`setDouble`, `getBoolean`/`setBoolean`, `getMemorySize`/`setMemorySize`. The payload views hold a raw `MemorySegment ptr` field rather than extending `NativeObject`, which is fine: `NativeFields`'s helpers take `ptr` as a plain parameter, so nothing about them requires a `NativeObject` receiver. No per-instance delegate object either — `NativeFields` is stateless shared FFM plumbing, the same shape as `NativeCalls.errHolder`/`checkError`/`wrapInvokeFailure` are already static on `NativeCalls`. These are cold-path calls — made once (or once per read/write call in `ReadOptions`/`WriteOptions`, still nowhere near `Get`/`Put`/iterator internals) — so the JIT constant-folding the base rule protects is immaterial here, and consolidating the near-identical `catch (Throwable t)` blocks meaningfully shrinks the permanently-unreachable defensive code cataloged in ADR 0004. Scope stays tight: only a plain no-arg getter or a setter taking `ptr()` plus exactly one primitive qualifies. A pure, always-succeeding value transform in the argument expression is still in scope — e.g. `NativeCalls.toByte(value)`, a null-to-sentinel ternary (`x == null ? -1L : x.toBytes()`), or a bitmask encode/decode (`TraceFilter.toMask(filters)`) — since none of those can throw, so there is no risk of a validation failure being misattributed to `NativeCalls.wrapInvokeFailure`'s "native setter failed" message. What stays a raw, per-call-site `MethodHandle` invocation is a pointer-argument call, a multi-arg call, or a value expression that can itself throw (e.g. `TransactionDBOptions`'s `toMillisOrNoTimeout`, which rejects a negative `Duration`) or that maps onto more than a direct value substitution (e.g. a boolean mapped onto a non-0/1 native enum). Do not route a hot-path class (`WriteBatch`, `Transaction(DB)`, `RocksIterator`, `SstFileWriter`, `PinnableSlice`/`PinnableHandle`, `WalIterator`, ...) through `NativeFields` without the same justification -- every `MH_` field must have a `/// \`\`` comment on the line immediately above it, copied verbatim from `rocksdb/include/rocksdb/c.h` (strip the `extern ROCKSDB_LIBRARY_API` prefix); no duplicate comment in the `static` block +- every `MH_` field must have a `/// \`\`` comment on the line immediately above it, copied verbatim from `rocksdb/include/rocksdb/c.h` (strip the `extern ROCKSDB_LIBRARY_API` prefix) +- every `MH_` field is initialized inline, never assigned in a `static {}` block, in exactly this shape (`java scripts/CheckPrototypes.java` enforces it): + ```java + /// `rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(double bits_per_key);` + private static final MethodHandle MH_CREATE_BLOOM = NativeLibrary.downcall( + "rocksdb_filterpolicy_create_bloom", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); + ``` + Symbol name and descriptor on one indented line, `);` on its own line. A descriptor with per-argument comments may wrap its arguments, but keeps the same `downcall(` / `);` frame. Why: the prototype comment, the symbol and the descriptor sit together, and there is no second place to look for a handle's definition - a shared capability interface (`RocksDBReadOperations`, `RocksDBWriteOperations`, `RocksDBMonitoringOperations`, `RocksDBTracingOperations`, ...) never holds its own `MH_` fields directly — an interface field is implicitly `public static final`, so `private static final MethodHandle` (the rule above) cannot live on the interface itself. Instead its default methods delegate to a package-private sibling class named `Bindings` (e.g. `RocksDBTracingOperationsBindings`) that holds the `MH_` fields plus the invoke/error-handling logic. This is the shape [#131](https://github.com/dfa1/rocksdb-ffm/issues/131) used to split `RocksDB.java`'s read/write/compaction/monitoring helpers out — one `Bindings` class per capability interface, not one shared catch-all - don't map multiple times the same symbol from C library of rocksdb - try to create always a java wrapper for that (i.e. PinnableSlice) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8160596f..a4af89e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,7 +66,8 @@ Cloned without `--recurse-submodules`? Run `git submodule update --init --recurs - New features come in three tiers: `MemorySegment`, `ByteBuffer`, `byte[]`. - Open factories take the path first, then `Options`, then other options, descriptors, flags or a TTL (`openReadWrite(path, options, descriptors)`). - `MethodHandle`s are `private static final`, each with a `/// \`\`` comment copied from - `c.h`. Errors go through `NativeCalls.errHolder`/`checkError`/`wrapInvokeFailure`. + `c.h`, initialized inline as `= NativeLibrary.downcall(` / symbol and descriptor / `);` (checked by + `java scripts/CheckPrototypes.java`). Errors go through `NativeCalls.errHolder`/`checkError`/`wrapInvokeFailure`. - No C `malloc`: `core` never binds libc (benchmarks may, as an FFM-overhead stand-in). Native memory comes from an `Arena`, the heap (via a `critical(true)` accessor downcall), or RocksDB itself (freed with `rocksdb_free`) — see `AGENTS.md` for the callback-buffer pattern. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngine.java b/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngine.java index 96be9e61..73dee1de 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngine.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngine.java @@ -39,120 +39,111 @@ public final class BackupEngine extends NativeObject { /// `rocksdb_backup_engine_t* rocksdb_backup_engine_open(const rocksdb_options_t* options, const char* path, char** errptr);` - private static final MethodHandle MH_OPEN; + private static final MethodHandle MH_OPEN = NativeLibrary.downcall( + "rocksdb_backup_engine_open", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // path + ValueLayout.ADDRESS) // errptr + ); /// `rocksdb_backup_engine_t* rocksdb_backup_engine_open_opts(const rocksdb_backup_engine_options_t* options, rocksdb_env_t* env, char** errptr);` - private static final MethodHandle MH_OPEN_OPTS; + private static final MethodHandle MH_OPEN_OPTS = NativeLibrary.downcall( + "rocksdb_backup_engine_open_opts", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_backup_engine_create_new_backup_flush(rocksdb_backup_engine_t* be, rocksdb_t* db, unsigned char flush_before_backup, char** errptr);` - private static final MethodHandle MH_CREATE_NEW_BACKUP_FLUSH; + private static final MethodHandle MH_CREATE_NEW_BACKUP_FLUSH = NativeLibrary.downcall( + "rocksdb_backup_engine_create_new_backup_flush", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // be + ValueLayout.ADDRESS, // db + ValueLayout.JAVA_BYTE, // flush_before_backup + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_backup_engine_purge_old_backups(rocksdb_backup_engine_t* be, uint32_t num_backups_to_keep, char** errptr);` - private static final MethodHandle MH_PURGE_OLD_BACKUPS; + private static final MethodHandle MH_PURGE_OLD_BACKUPS = NativeLibrary.downcall( + "rocksdb_backup_engine_purge_old_backups", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // be + ValueLayout.JAVA_INT, // num_backups_to_keep (uint32_t) + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_backup_engine_verify_backup(rocksdb_backup_engine_t* be, uint32_t backup_id, char** errptr);` - private static final MethodHandle MH_VERIFY_BACKUP; + private static final MethodHandle MH_VERIFY_BACKUP = NativeLibrary.downcall( + "rocksdb_backup_engine_verify_backup", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // be + ValueLayout.JAVA_INT, // backup_id (uint32_t) + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_backup_engine_restore_db_from_latest_backup(rocksdb_backup_engine_t* be, const char* db_dir, const char* wal_dir, const rocksdb_restore_options_t* restore_options, char** errptr);` - private static final MethodHandle MH_RESTORE_FROM_LATEST; + private static final MethodHandle MH_RESTORE_FROM_LATEST = NativeLibrary.downcall( + "rocksdb_backup_engine_restore_db_from_latest_backup", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // be + ValueLayout.ADDRESS, // db_dir + ValueLayout.ADDRESS, // wal_dir + ValueLayout.ADDRESS, // restore_options + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_backup_engine_restore_db_from_backup(rocksdb_backup_engine_t* be, const char* db_dir, const char* wal_dir, const rocksdb_restore_options_t* restore_options, const uint32_t backup_id, char** errptr);` - private static final MethodHandle MH_RESTORE_FROM_BACKUP; + private static final MethodHandle MH_RESTORE_FROM_BACKUP = NativeLibrary.downcall( + "rocksdb_backup_engine_restore_db_from_backup", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // be + ValueLayout.ADDRESS, // db_dir + ValueLayout.ADDRESS, // wal_dir + ValueLayout.ADDRESS, // restore_options + ValueLayout.JAVA_INT, // backup_id (uint32_t) + ValueLayout.ADDRESS) // errptr + ); /// `const rocksdb_backup_engine_info_t* rocksdb_backup_engine_get_backup_info(rocksdb_backup_engine_t* be);` - private static final MethodHandle MH_GET_BACKUP_INFO; + private static final MethodHandle MH_GET_BACKUP_INFO = NativeLibrary.downcall( + "rocksdb_backup_engine_get_backup_info", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `int rocksdb_backup_engine_info_count(const rocksdb_backup_engine_info_t* info);` - private static final MethodHandle MH_INFO_COUNT; + private static final MethodHandle MH_INFO_COUNT = NativeLibrary.downcall( + "rocksdb_backup_engine_info_count", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `int64_t rocksdb_backup_engine_info_timestamp(const rocksdb_backup_engine_info_t* info, int index);` - private static final MethodHandle MH_INFO_TIMESTAMP; + private static final MethodHandle MH_INFO_TIMESTAMP = NativeLibrary.downcall( + "rocksdb_backup_engine_info_timestamp", + FunctionDescriptor.of(ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, // info + ValueLayout.JAVA_INT) // index + ); /// `uint32_t rocksdb_backup_engine_info_backup_id(const rocksdb_backup_engine_info_t* info, int index);` - private static final MethodHandle MH_INFO_BACKUP_ID; + private static final MethodHandle MH_INFO_BACKUP_ID = NativeLibrary.downcall( + "rocksdb_backup_engine_info_backup_id", + FunctionDescriptor.of(ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, // info + ValueLayout.JAVA_INT) // index + ); /// `uint64_t rocksdb_backup_engine_info_size(const rocksdb_backup_engine_info_t* info, int index);` - private static final MethodHandle MH_INFO_SIZE; + private static final MethodHandle MH_INFO_SIZE = NativeLibrary.downcall( + "rocksdb_backup_engine_info_size", + FunctionDescriptor.of(ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, // info + ValueLayout.JAVA_INT) // index + ); /// `uint32_t rocksdb_backup_engine_info_number_files(const rocksdb_backup_engine_info_t* info, int index);` - private static final MethodHandle MH_INFO_NUMBER_FILES; + private static final MethodHandle MH_INFO_NUMBER_FILES = NativeLibrary.downcall( + "rocksdb_backup_engine_info_number_files", + FunctionDescriptor.of(ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, // info + ValueLayout.JAVA_INT) // index + ); /// `void rocksdb_backup_engine_info_destroy(const rocksdb_backup_engine_info_t* info);` - private static final MethodHandle MH_INFO_DESTROY; + private static final MethodHandle MH_INFO_DESTROY = NativeLibrary.downcall( + "rocksdb_backup_engine_info_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_close(rocksdb_backup_engine_t* be);` - private static final MethodHandle MH_CLOSE; - - static { - MH_OPEN = NativeLibrary.downcall("rocksdb_backup_engine_open", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // path - ValueLayout.ADDRESS)); // errptr - - MH_OPEN_OPTS = NativeLibrary.downcall("rocksdb_backup_engine_open_opts", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS)); // errptr - - MH_CREATE_NEW_BACKUP_FLUSH = NativeLibrary.downcall( - "rocksdb_backup_engine_create_new_backup_flush", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // be - ValueLayout.ADDRESS, // db - ValueLayout.JAVA_BYTE, // flush_before_backup - ValueLayout.ADDRESS)); // errptr - - MH_PURGE_OLD_BACKUPS = NativeLibrary.downcall("rocksdb_backup_engine_purge_old_backups", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // be - ValueLayout.JAVA_INT, // num_backups_to_keep (uint32_t) - ValueLayout.ADDRESS)); // errptr - - MH_VERIFY_BACKUP = NativeLibrary.downcall("rocksdb_backup_engine_verify_backup", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // be - ValueLayout.JAVA_INT, // backup_id (uint32_t) - ValueLayout.ADDRESS)); // errptr - - MH_RESTORE_FROM_LATEST = NativeLibrary.downcall( - "rocksdb_backup_engine_restore_db_from_latest_backup", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // be - ValueLayout.ADDRESS, // db_dir - ValueLayout.ADDRESS, // wal_dir - ValueLayout.ADDRESS, // restore_options - ValueLayout.ADDRESS)); // errptr - - MH_RESTORE_FROM_BACKUP = NativeLibrary.downcall( - "rocksdb_backup_engine_restore_db_from_backup", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // be - ValueLayout.ADDRESS, // db_dir - ValueLayout.ADDRESS, // wal_dir - ValueLayout.ADDRESS, // restore_options - ValueLayout.JAVA_INT, // backup_id (uint32_t) - ValueLayout.ADDRESS)); // errptr - - MH_GET_BACKUP_INFO = NativeLibrary.downcall("rocksdb_backup_engine_get_backup_info", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_INFO_COUNT = NativeLibrary.downcall("rocksdb_backup_engine_info_count", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_INFO_TIMESTAMP = NativeLibrary.downcall("rocksdb_backup_engine_info_timestamp", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, - ValueLayout.ADDRESS, // info - ValueLayout.JAVA_INT)); // index - - MH_INFO_BACKUP_ID = NativeLibrary.downcall("rocksdb_backup_engine_info_backup_id", - FunctionDescriptor.of(ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, // info - ValueLayout.JAVA_INT)); // index - - MH_INFO_SIZE = NativeLibrary.downcall("rocksdb_backup_engine_info_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, - ValueLayout.ADDRESS, // info - ValueLayout.JAVA_INT)); // index - - MH_INFO_NUMBER_FILES = NativeLibrary.downcall("rocksdb_backup_engine_info_number_files", - FunctionDescriptor.of(ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, // info - ValueLayout.JAVA_INT)); // index - - MH_INFO_DESTROY = NativeLibrary.downcall("rocksdb_backup_engine_info_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_CLOSE = NativeLibrary.downcall("rocksdb_backup_engine_close", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CLOSE = NativeLibrary.downcall( + "rocksdb_backup_engine_close", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private BackupEngine(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngineOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngineOptions.java index 0fe395f3..105e6b12 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngineOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/BackupEngineOptions.java @@ -29,145 +29,101 @@ public final class BackupEngineOptions extends NativeObject { /// `rocksdb_backup_engine_options_t* rocksdb_backup_engine_options_create(const char* backup_dir);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_backup_engine_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_destroy(rocksdb_backup_engine_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_backup_engine_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_backup_dir(rocksdb_backup_engine_options_t* options, const char* backup_dir);` - private static final MethodHandle MH_SET_BACKUP_DIR; + private static final MethodHandle MH_SET_BACKUP_DIR = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_backup_dir", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_env(rocksdb_backup_engine_options_t* options, rocksdb_env_t* env);` - private static final MethodHandle MH_SET_ENV; + private static final MethodHandle MH_SET_ENV = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_env", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_share_table_files(rocksdb_backup_engine_options_t* options, unsigned char val);` - private static final MethodHandle MH_SET_SHARE_TABLE_FILES; + private static final MethodHandle MH_SET_SHARE_TABLE_FILES = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_share_table_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_backup_engine_options_get_share_table_files(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_SHARE_TABLE_FILES; + private static final MethodHandle MH_GET_SHARE_TABLE_FILES = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_share_table_files", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_sync(rocksdb_backup_engine_options_t* options, unsigned char val);` - private static final MethodHandle MH_SET_SYNC; + private static final MethodHandle MH_SET_SYNC = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_sync", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_backup_engine_options_get_sync(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_SYNC; + private static final MethodHandle MH_GET_SYNC = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_sync", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_destroy_old_data(rocksdb_backup_engine_options_t* options, unsigned char val);` - private static final MethodHandle MH_SET_DESTROY_OLD_DATA; + private static final MethodHandle MH_SET_DESTROY_OLD_DATA = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_destroy_old_data", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_backup_engine_options_get_destroy_old_data(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_DESTROY_OLD_DATA; + private static final MethodHandle MH_GET_DESTROY_OLD_DATA = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_destroy_old_data", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_backup_log_files(rocksdb_backup_engine_options_t* options, unsigned char val);` - private static final MethodHandle MH_SET_BACKUP_LOG_FILES; + private static final MethodHandle MH_SET_BACKUP_LOG_FILES = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_backup_log_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_backup_engine_options_get_backup_log_files(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_BACKUP_LOG_FILES; + private static final MethodHandle MH_GET_BACKUP_LOG_FILES = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_backup_log_files", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_backup_rate_limit(rocksdb_backup_engine_options_t* options, uint64_t limit);` - private static final MethodHandle MH_SET_BACKUP_RATE_LIMIT; + private static final MethodHandle MH_SET_BACKUP_RATE_LIMIT = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_backup_rate_limit", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_backup_engine_options_get_backup_rate_limit(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_BACKUP_RATE_LIMIT; + private static final MethodHandle MH_GET_BACKUP_RATE_LIMIT = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_backup_rate_limit", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_restore_rate_limit(rocksdb_backup_engine_options_t* options, uint64_t limit);` - private static final MethodHandle MH_SET_RESTORE_RATE_LIMIT; + private static final MethodHandle MH_SET_RESTORE_RATE_LIMIT = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_restore_rate_limit", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_backup_engine_options_get_restore_rate_limit(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_RESTORE_RATE_LIMIT; + private static final MethodHandle MH_GET_RESTORE_RATE_LIMIT = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_restore_rate_limit", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_max_background_operations(rocksdb_backup_engine_options_t* options, int val);` - private static final MethodHandle MH_SET_MAX_BACKGROUND_OPERATIONS; + private static final MethodHandle MH_SET_MAX_BACKGROUND_OPERATIONS = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_max_background_operations", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_backup_engine_options_get_max_background_operations(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_MAX_BACKGROUND_OPERATIONS; + private static final MethodHandle MH_GET_MAX_BACKGROUND_OPERATIONS = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_max_background_operations", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_callback_trigger_interval_size(rocksdb_backup_engine_options_t* options, uint64_t size);` - private static final MethodHandle MH_SET_CALLBACK_TRIGGER_INTERVAL_SIZE; + private static final MethodHandle MH_SET_CALLBACK_TRIGGER_INTERVAL_SIZE = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_callback_trigger_interval_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_backup_engine_options_get_callback_trigger_interval_size(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_CALLBACK_TRIGGER_INTERVAL_SIZE; + private static final MethodHandle MH_GET_CALLBACK_TRIGGER_INTERVAL_SIZE = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_callback_trigger_interval_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_max_valid_backups_to_open(rocksdb_backup_engine_options_t* options, int val);` - private static final MethodHandle MH_SET_MAX_VALID_BACKUPS_TO_OPEN; + private static final MethodHandle MH_SET_MAX_VALID_BACKUPS_TO_OPEN = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_max_valid_backups_to_open", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_backup_engine_options_get_max_valid_backups_to_open(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_MAX_VALID_BACKUPS_TO_OPEN; + private static final MethodHandle MH_GET_MAX_VALID_BACKUPS_TO_OPEN = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_max_valid_backups_to_open", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_backup_engine_options_set_share_files_with_checksum_naming(rocksdb_backup_engine_options_t* options, int val);` - private static final MethodHandle MH_SET_SHARE_FILES_WITH_CHECKSUM_NAMING; + private static final MethodHandle MH_SET_SHARE_FILES_WITH_CHECKSUM_NAMING = NativeLibrary.downcall( + "rocksdb_backup_engine_options_set_share_files_with_checksum_naming", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_backup_engine_options_get_share_files_with_checksum_naming(rocksdb_backup_engine_options_t* options);` - private static final MethodHandle MH_GET_SHARE_FILES_WITH_CHECKSUM_NAMING; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_backup_engine_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_backup_engine_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_BACKUP_DIR = NativeLibrary.downcall("rocksdb_backup_engine_options_set_backup_dir", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_ENV = NativeLibrary.downcall("rocksdb_backup_engine_options_set_env", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_SHARE_TABLE_FILES = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_share_table_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SHARE_TABLE_FILES = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_share_table_files", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SYNC = NativeLibrary.downcall("rocksdb_backup_engine_options_set_sync", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SYNC = NativeLibrary.downcall("rocksdb_backup_engine_options_get_sync", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DESTROY_OLD_DATA = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_destroy_old_data", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_DESTROY_OLD_DATA = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_destroy_old_data", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BACKUP_LOG_FILES = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_backup_log_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_BACKUP_LOG_FILES = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_backup_log_files", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BACKUP_RATE_LIMIT = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_backup_rate_limit", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_BACKUP_RATE_LIMIT = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_backup_rate_limit", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_RESTORE_RATE_LIMIT = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_restore_rate_limit", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_RESTORE_RATE_LIMIT = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_restore_rate_limit", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_BACKGROUND_OPERATIONS = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_max_background_operations", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_BACKGROUND_OPERATIONS = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_max_background_operations", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_CALLBACK_TRIGGER_INTERVAL_SIZE = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_callback_trigger_interval_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_CALLBACK_TRIGGER_INTERVAL_SIZE = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_callback_trigger_interval_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_VALID_BACKUPS_TO_OPEN = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_max_valid_backups_to_open", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_VALID_BACKUPS_TO_OPEN = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_max_valid_backups_to_open", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_SHARE_FILES_WITH_CHECKSUM_NAMING = NativeLibrary.downcall( - "rocksdb_backup_engine_options_set_share_files_with_checksum_naming", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_SHARE_FILES_WITH_CHECKSUM_NAMING = NativeLibrary.downcall( - "rocksdb_backup_engine_options_get_share_files_with_checksum_naming", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_SHARE_FILES_WITH_CHECKSUM_NAMING = NativeLibrary.downcall( + "rocksdb_backup_engine_options_get_share_files_with_checksum_naming", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private BackupEngineOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockBasedTableOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockBasedTableOptions.java index 1e744a94..e9ca7a00 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockBasedTableOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockBasedTableOptions.java @@ -306,441 +306,309 @@ static OptimizeKeyCommonPrefix fromValue(int value) { // ----------------------------------------------------------------------- /// `rocksdb_block_based_table_options_t* rocksdb_block_based_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_block_based_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_destroy(rocksdb_block_based_table_options_t* options);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_block_based_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_block_size(rocksdb_block_based_table_options_t* options, size_t block_size);` - private static final MethodHandle MH_SET_BLOCK_SIZE; + private static final MethodHandle MH_SET_BLOCK_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_block_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_block_based_options_set_filter_policy(rocksdb_block_based_table_options_t* options, rocksdb_filterpolicy_t* filter_policy);` - private static final MethodHandle MH_SET_FILTER_POLICY; + private static final MethodHandle MH_SET_FILTER_POLICY = NativeLibrary.downcall( + "rocksdb_block_based_options_set_filter_policy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_no_block_cache(rocksdb_block_based_table_options_t* options, unsigned char no_block_cache);` - private static final MethodHandle MH_SET_NO_BLOCK_CACHE; + private static final MethodHandle MH_SET_NO_BLOCK_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_no_block_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_block_based_options_set_block_cache(rocksdb_block_based_table_options_t* options, rocksdb_cache_t* block_cache);` - private static final MethodHandle MH_SET_BLOCK_CACHE; + private static final MethodHandle MH_SET_BLOCK_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_block_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_cache_index_and_filter_blocks(rocksdb_block_based_table_options_t*, unsigned char);` - private static final MethodHandle MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS; + private static final MethodHandle MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS = NativeLibrary.downcall( + "rocksdb_block_based_options_set_cache_index_and_filter_blocks", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_block_based_options_set_index_type(rocksdb_block_based_table_options_t*, int);` - private static final MethodHandle MH_SET_INDEX_TYPE; + private static final MethodHandle MH_SET_INDEX_TYPE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_index_type", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_block_based_options_set_format_version(rocksdb_block_based_table_options_t*, int);` - private static final MethodHandle MH_SET_FORMAT_VERSION; + private static final MethodHandle MH_SET_FORMAT_VERSION = NativeLibrary.downcall( + "rocksdb_block_based_options_set_format_version", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_block_based_options_get_format_version(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_FORMAT_VERSION; + private static final MethodHandle MH_GET_FORMAT_VERSION = NativeLibrary.downcall( + "rocksdb_block_based_options_get_format_version", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_whole_key_filtering(rocksdb_block_based_table_options_t*, unsigned char);` - private static final MethodHandle MH_SET_WHOLE_KEY_FILTERING; + private static final MethodHandle MH_SET_WHOLE_KEY_FILTERING = NativeLibrary.downcall( + "rocksdb_block_based_options_set_whole_key_filtering", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_block_based_options_set_partition_filters(rocksdb_block_based_table_options_t* options, unsigned char partition_filters);` - private static final MethodHandle MH_SET_PARTITION_FILTERS; + private static final MethodHandle MH_SET_PARTITION_FILTERS = NativeLibrary.downcall( + "rocksdb_block_based_options_set_partition_filters", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_block_based_options_set_max_auto_readahead_size(rocksdb_block_based_table_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_MAX_AUTO_READAHEAD_SIZE; + private static final MethodHandle MH_SET_MAX_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_max_auto_readahead_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_block_based_options_get_max_auto_readahead_size(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_MAX_AUTO_READAHEAD_SIZE; + private static final MethodHandle MH_GET_MAX_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_max_auto_readahead_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_initial_auto_readahead_size(rocksdb_block_based_table_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_INITIAL_AUTO_READAHEAD_SIZE; + private static final MethodHandle MH_SET_INITIAL_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_initial_auto_readahead_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_block_based_options_get_initial_auto_readahead_size(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_INITIAL_AUTO_READAHEAD_SIZE; + private static final MethodHandle MH_GET_INITIAL_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_initial_auto_readahead_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_num_file_reads_for_auto_readahead(rocksdb_block_based_table_options_t* opt, uint64_t v);` - private static final MethodHandle MH_SET_NUM_FILE_READS_FOR_AUTO_READAHEAD; + private static final MethodHandle MH_SET_NUM_FILE_READS_FOR_AUTO_READAHEAD = NativeLibrary.downcall( + "rocksdb_block_based_options_set_num_file_reads_for_auto_readahead", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_block_based_options_get_num_file_reads_for_auto_readahead(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_NUM_FILE_READS_FOR_AUTO_READAHEAD; + private static final MethodHandle MH_GET_NUM_FILE_READS_FOR_AUTO_READAHEAD = NativeLibrary.downcall( + "rocksdb_block_based_options_get_num_file_reads_for_auto_readahead", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY; + private static final MethodHandle MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY = NativeLibrary.downcall( + "rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_cache_index_and_filter_blocks_with_high_priority(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY; + private static final MethodHandle MH_GET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY = NativeLibrary.downcall( + "rocksdb_block_based_options_get_cache_index_and_filter_blocks_with_high_priority", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE; + private static final MethodHandle MH_SET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_pin_l0_filter_and_index_blocks_in_cache(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE; + private static final MethodHandle MH_GET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_pin_l0_filter_and_index_blocks_in_cache", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_pin_top_level_index_and_filter(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_PIN_TOP_LEVEL_INDEX_AND_FILTER; + private static final MethodHandle MH_SET_PIN_TOP_LEVEL_INDEX_AND_FILTER = NativeLibrary.downcall( + "rocksdb_block_based_options_set_pin_top_level_index_and_filter", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_pin_top_level_index_and_filter(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_PIN_TOP_LEVEL_INDEX_AND_FILTER; + private static final MethodHandle MH_GET_PIN_TOP_LEVEL_INDEX_AND_FILTER = NativeLibrary.downcall( + "rocksdb_block_based_options_get_pin_top_level_index_and_filter", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_top_level_index_pinning_tier(rocksdb_block_based_table_options_t* options, int v);` - private static final MethodHandle MH_SET_TOP_LEVEL_INDEX_PINNING_TIER; + private static final MethodHandle MH_SET_TOP_LEVEL_INDEX_PINNING_TIER = NativeLibrary.downcall( + "rocksdb_block_based_options_set_top_level_index_pinning_tier", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_block_based_options_set_partition_pinning_tier(rocksdb_block_based_table_options_t* options, int v);` - private static final MethodHandle MH_SET_PARTITION_PINNING_TIER; + private static final MethodHandle MH_SET_PARTITION_PINNING_TIER = NativeLibrary.downcall( + "rocksdb_block_based_options_set_partition_pinning_tier", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_block_based_options_set_unpartitioned_pinning_tier(rocksdb_block_based_table_options_t* options, int v);` - private static final MethodHandle MH_SET_UNPARTITIONED_PINNING_TIER; + private static final MethodHandle MH_SET_UNPARTITIONED_PINNING_TIER = NativeLibrary.downcall( + "rocksdb_block_based_options_set_unpartitioned_pinning_tier", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_block_based_options_set_block_restart_interval(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_BLOCK_RESTART_INTERVAL; + private static final MethodHandle MH_SET_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( + "rocksdb_block_based_options_set_block_restart_interval", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_block_restart_interval(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_BLOCK_RESTART_INTERVAL; + private static final MethodHandle MH_GET_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( + "rocksdb_block_based_options_get_block_restart_interval", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_index_block_restart_interval(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_INDEX_BLOCK_RESTART_INTERVAL; + private static final MethodHandle MH_SET_INDEX_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( + "rocksdb_block_based_options_set_index_block_restart_interval", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_index_block_restart_interval(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_INDEX_BLOCK_RESTART_INTERVAL; + private static final MethodHandle MH_GET_INDEX_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( + "rocksdb_block_based_options_get_index_block_restart_interval", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_metadata_block_size(rocksdb_block_based_table_options_t* opt, uint64_t v);` - private static final MethodHandle MH_SET_METADATA_BLOCK_SIZE; + private static final MethodHandle MH_SET_METADATA_BLOCK_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_metadata_block_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_block_based_options_get_metadata_block_size(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_METADATA_BLOCK_SIZE; + private static final MethodHandle MH_GET_METADATA_BLOCK_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_metadata_block_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_block_size_deviation(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_BLOCK_SIZE_DEVIATION; + private static final MethodHandle MH_SET_BLOCK_SIZE_DEVIATION = NativeLibrary.downcall( + "rocksdb_block_based_options_set_block_size_deviation", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_block_size_deviation(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_BLOCK_SIZE_DEVIATION; + private static final MethodHandle MH_GET_BLOCK_SIZE_DEVIATION = NativeLibrary.downcall( + "rocksdb_block_based_options_get_block_size_deviation", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_use_delta_encoding(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_DELTA_ENCODING; + private static final MethodHandle MH_SET_USE_DELTA_ENCODING = NativeLibrary.downcall( + "rocksdb_block_based_options_set_use_delta_encoding", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_use_delta_encoding(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_USE_DELTA_ENCODING; + private static final MethodHandle MH_GET_USE_DELTA_ENCODING = NativeLibrary.downcall( + "rocksdb_block_based_options_get_use_delta_encoding", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_separate_key_value_in_data_block(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK; + private static final MethodHandle MH_SET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK = NativeLibrary.downcall( + "rocksdb_block_based_options_set_separate_key_value_in_data_block", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_separate_key_value_in_data_block(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK; + private static final MethodHandle MH_GET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK = NativeLibrary.downcall( + "rocksdb_block_based_options_get_separate_key_value_in_data_block", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_optimize_filters_for_memory(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_OPTIMIZE_FILTERS_FOR_MEMORY; + private static final MethodHandle MH_SET_OPTIMIZE_FILTERS_FOR_MEMORY = NativeLibrary.downcall( + "rocksdb_block_based_options_set_optimize_filters_for_memory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_optimize_filters_for_memory(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_OPTIMIZE_FILTERS_FOR_MEMORY; + private static final MethodHandle MH_GET_OPTIMIZE_FILTERS_FOR_MEMORY = NativeLibrary.downcall( + "rocksdb_block_based_options_get_optimize_filters_for_memory", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_decouple_partitioned_filters(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_DECOUPLE_PARTITIONED_FILTERS; + private static final MethodHandle MH_SET_DECOUPLE_PARTITIONED_FILTERS = NativeLibrary.downcall( + "rocksdb_block_based_options_set_decouple_partitioned_filters", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_decouple_partitioned_filters(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_DECOUPLE_PARTITIONED_FILTERS; + private static final MethodHandle MH_GET_DECOUPLE_PARTITIONED_FILTERS = NativeLibrary.downcall( + "rocksdb_block_based_options_get_decouple_partitioned_filters", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_data_block_hash_table_util_ratio(rocksdb_block_based_table_options_t* opt, double v);` - private static final MethodHandle MH_SET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO; + private static final MethodHandle MH_SET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO = NativeLibrary.downcall( + "rocksdb_block_based_options_set_data_block_hash_table_util_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_block_based_options_get_data_block_hash_table_util_ratio(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO; + private static final MethodHandle MH_GET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO = NativeLibrary.downcall( + "rocksdb_block_based_options_get_data_block_hash_table_util_ratio", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_index_shortening(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_INDEX_SHORTENING; + private static final MethodHandle MH_SET_INDEX_SHORTENING = NativeLibrary.downcall( + "rocksdb_block_based_options_set_index_shortening", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_index_shortening(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_INDEX_SHORTENING; + private static final MethodHandle MH_GET_INDEX_SHORTENING = NativeLibrary.downcall( + "rocksdb_block_based_options_get_index_shortening", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_data_block_index_type(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_DATA_BLOCK_INDEX_TYPE; + private static final MethodHandle MH_SET_DATA_BLOCK_INDEX_TYPE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_data_block_index_type", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_data_block_index_type(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_DATA_BLOCK_INDEX_TYPE; + private static final MethodHandle MH_GET_DATA_BLOCK_INDEX_TYPE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_data_block_index_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_optimize_key_common_prefix(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_OPTIMIZE_KEY_COMMON_PREFIX; + private static final MethodHandle MH_SET_OPTIMIZE_KEY_COMMON_PREFIX = NativeLibrary.downcall( + "rocksdb_block_based_options_set_optimize_key_common_prefix", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_optimize_key_common_prefix(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_OPTIMIZE_KEY_COMMON_PREFIX; + private static final MethodHandle MH_GET_OPTIMIZE_KEY_COMMON_PREFIX = NativeLibrary.downcall( + "rocksdb_block_based_options_get_optimize_key_common_prefix", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_index_block_search_type(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_INDEX_BLOCK_SEARCH_TYPE; + private static final MethodHandle MH_SET_INDEX_BLOCK_SEARCH_TYPE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_index_block_search_type", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_index_block_search_type(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_INDEX_BLOCK_SEARCH_TYPE; + private static final MethodHandle MH_GET_INDEX_BLOCK_SEARCH_TYPE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_index_block_search_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_enable_index_compression(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ENABLE_INDEX_COMPRESSION; + private static final MethodHandle MH_SET_ENABLE_INDEX_COMPRESSION = NativeLibrary.downcall( + "rocksdb_block_based_options_set_enable_index_compression", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_enable_index_compression(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_ENABLE_INDEX_COMPRESSION; + private static final MethodHandle MH_GET_ENABLE_INDEX_COMPRESSION = NativeLibrary.downcall( + "rocksdb_block_based_options_get_enable_index_compression", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_uniform_cv_threshold(rocksdb_block_based_table_options_t* opt, double v);` - private static final MethodHandle MH_SET_UNIFORM_CV_THRESHOLD; + private static final MethodHandle MH_SET_UNIFORM_CV_THRESHOLD = NativeLibrary.downcall( + "rocksdb_block_based_options_set_uniform_cv_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_block_based_options_get_uniform_cv_threshold(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_UNIFORM_CV_THRESHOLD; + private static final MethodHandle MH_GET_UNIFORM_CV_THRESHOLD = NativeLibrary.downcall( + "rocksdb_block_based_options_get_uniform_cv_threshold", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_checksum(rocksdb_block_based_table_options_t* opt, char v);` - private static final MethodHandle MH_SET_CHECKSUM; + private static final MethodHandle MH_SET_CHECKSUM = NativeLibrary.downcall( + "rocksdb_block_based_options_set_checksum", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `int rocksdb_block_based_options_get_checksum(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_CHECKSUM; + private static final MethodHandle MH_GET_CHECKSUM = NativeLibrary.downcall( + "rocksdb_block_based_options_get_checksum", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_verify_compression(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_VERIFY_COMPRESSION; + private static final MethodHandle MH_SET_VERIFY_COMPRESSION = NativeLibrary.downcall( + "rocksdb_block_based_options_set_verify_compression", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_verify_compression(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_VERIFY_COMPRESSION; + private static final MethodHandle MH_GET_VERIFY_COMPRESSION = NativeLibrary.downcall( + "rocksdb_block_based_options_get_verify_compression", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_detect_filter_construct_corruption(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_DETECT_FILTER_CONSTRUCT_CORRUPTION; + private static final MethodHandle MH_SET_DETECT_FILTER_CONSTRUCT_CORRUPTION = NativeLibrary.downcall( + "rocksdb_block_based_options_set_detect_filter_construct_corruption", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_detect_filter_construct_corruption(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_DETECT_FILTER_CONSTRUCT_CORRUPTION; + private static final MethodHandle MH_GET_DETECT_FILTER_CONSTRUCT_CORRUPTION = NativeLibrary.downcall( + "rocksdb_block_based_options_get_detect_filter_construct_corruption", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_read_amp_bytes_per_bit(rocksdb_block_based_table_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_READ_AMP_BYTES_PER_BIT; + private static final MethodHandle MH_SET_READ_AMP_BYTES_PER_BIT = NativeLibrary.downcall( + "rocksdb_block_based_options_set_read_amp_bytes_per_bit", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_block_based_options_get_read_amp_bytes_per_bit(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_READ_AMP_BYTES_PER_BIT; + private static final MethodHandle MH_GET_READ_AMP_BYTES_PER_BIT = NativeLibrary.downcall( + "rocksdb_block_based_options_get_read_amp_bytes_per_bit", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_block_align(rocksdb_block_based_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_BLOCK_ALIGN; + private static final MethodHandle MH_SET_BLOCK_ALIGN = NativeLibrary.downcall( + "rocksdb_block_based_options_set_block_align", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_block_based_options_get_block_align(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_BLOCK_ALIGN; + private static final MethodHandle MH_GET_BLOCK_ALIGN = NativeLibrary.downcall( + "rocksdb_block_based_options_get_block_align", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_super_block_alignment_size(rocksdb_block_based_table_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_SUPER_BLOCK_ALIGNMENT_SIZE; + private static final MethodHandle MH_SET_SUPER_BLOCK_ALIGNMENT_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_super_block_alignment_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_block_based_options_get_super_block_alignment_size(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_SUPER_BLOCK_ALIGNMENT_SIZE; + private static final MethodHandle MH_GET_SUPER_BLOCK_ALIGNMENT_SIZE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_super_block_alignment_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_super_block_alignment_space_overhead_ratio(rocksdb_block_based_table_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO; + private static final MethodHandle MH_SET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO = NativeLibrary.downcall( + "rocksdb_block_based_options_set_super_block_alignment_space_overhead_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_block_based_options_get_super_block_alignment_space_overhead_ratio(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO; + private static final MethodHandle MH_GET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO = NativeLibrary.downcall( + "rocksdb_block_based_options_get_super_block_alignment_space_overhead_ratio", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_prepopulate_block_cache(rocksdb_block_based_table_options_t* opt, int v);` - private static final MethodHandle MH_SET_PREPOPULATE_BLOCK_CACHE; + private static final MethodHandle MH_SET_PREPOPULATE_BLOCK_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_set_prepopulate_block_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_block_based_options_get_prepopulate_block_cache(rocksdb_block_based_table_options_t* opt);` - private static final MethodHandle MH_GET_PREPOPULATE_BLOCK_CACHE; + private static final MethodHandle MH_GET_PREPOPULATE_BLOCK_CACHE = NativeLibrary.downcall( + "rocksdb_block_based_options_get_prepopulate_block_cache", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_set_user_defined_index_factory_from_string(rocksdb_block_based_table_options_t* options, const char* value, size_t value_len, char** errptr);` - private static final MethodHandle MH_SET_UDI_FACTORY_FROM_STRING; + private static final MethodHandle MH_SET_UDI_FACTORY_FROM_STRING = NativeLibrary.downcall( + "rocksdb_block_based_options_set_user_defined_index_factory_from_string", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_block_based_options_clear_user_defined_index_factory(rocksdb_block_based_table_options_t* options);` - private static final MethodHandle MH_CLEAR_UDI_FACTORY; + private static final MethodHandle MH_CLEAR_UDI_FACTORY = NativeLibrary.downcall( + "rocksdb_block_based_options_clear_user_defined_index_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `const char* rocksdb_block_based_options_get_user_defined_index_factory_name(const rocksdb_block_based_table_options_t* options, size_t* name_len);` - private static final MethodHandle MH_GET_UDI_FACTORY_NAME; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_block_based_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_block_based_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_BLOCK_SIZE = NativeLibrary.downcall("rocksdb_block_based_options_set_block_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_FILTER_POLICY = NativeLibrary.downcall("rocksdb_block_based_options_set_filter_policy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_NO_BLOCK_CACHE = NativeLibrary.downcall("rocksdb_block_based_options_set_no_block_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_BLOCK_CACHE = NativeLibrary.downcall("rocksdb_block_based_options_set_block_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS = NativeLibrary.downcall( - "rocksdb_block_based_options_set_cache_index_and_filter_blocks", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_INDEX_TYPE = NativeLibrary.downcall("rocksdb_block_based_options_set_index_type", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SET_FORMAT_VERSION = NativeLibrary.downcall("rocksdb_block_based_options_set_format_version", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_FORMAT_VERSION = NativeLibrary.downcall("rocksdb_block_based_options_get_format_version", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_WHOLE_KEY_FILTERING = NativeLibrary.downcall( - "rocksdb_block_based_options_set_whole_key_filtering", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_PARTITION_FILTERS = NativeLibrary.downcall( - "rocksdb_block_based_options_set_partition_filters", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_MAX_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_max_auto_readahead_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_MAX_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_max_auto_readahead_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_INITIAL_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_initial_auto_readahead_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_INITIAL_AUTO_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_initial_auto_readahead_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_NUM_FILE_READS_FOR_AUTO_READAHEAD = NativeLibrary.downcall( - "rocksdb_block_based_options_set_num_file_reads_for_auto_readahead", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_NUM_FILE_READS_FOR_AUTO_READAHEAD = NativeLibrary.downcall( - "rocksdb_block_based_options_get_num_file_reads_for_auto_readahead", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY = NativeLibrary.downcall( - "rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_CACHE_INDEX_AND_FILTER_BLOCKS_WITH_HIGH_PRIORITY = NativeLibrary.downcall( - "rocksdb_block_based_options_get_cache_index_and_filter_blocks_with_high_priority", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_PIN_L0_FILTER_AND_INDEX_BLOCKS_IN_CACHE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_pin_l0_filter_and_index_blocks_in_cache", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_PIN_TOP_LEVEL_INDEX_AND_FILTER = NativeLibrary.downcall( - "rocksdb_block_based_options_set_pin_top_level_index_and_filter", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_PIN_TOP_LEVEL_INDEX_AND_FILTER = NativeLibrary.downcall( - "rocksdb_block_based_options_get_pin_top_level_index_and_filter", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TOP_LEVEL_INDEX_PINNING_TIER = NativeLibrary.downcall( - "rocksdb_block_based_options_set_top_level_index_pinning_tier", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SET_PARTITION_PINNING_TIER = NativeLibrary.downcall( - "rocksdb_block_based_options_set_partition_pinning_tier", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SET_UNPARTITIONED_PINNING_TIER = NativeLibrary.downcall( - "rocksdb_block_based_options_set_unpartitioned_pinning_tier", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SET_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( - "rocksdb_block_based_options_set_block_restart_interval", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( - "rocksdb_block_based_options_get_block_restart_interval", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_INDEX_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( - "rocksdb_block_based_options_set_index_block_restart_interval", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_INDEX_BLOCK_RESTART_INTERVAL = NativeLibrary.downcall( - "rocksdb_block_based_options_get_index_block_restart_interval", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_METADATA_BLOCK_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_metadata_block_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_METADATA_BLOCK_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_metadata_block_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_BLOCK_SIZE_DEVIATION = NativeLibrary.downcall( - "rocksdb_block_based_options_set_block_size_deviation", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BLOCK_SIZE_DEVIATION = NativeLibrary.downcall( - "rocksdb_block_based_options_get_block_size_deviation", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_USE_DELTA_ENCODING = NativeLibrary.downcall( - "rocksdb_block_based_options_set_use_delta_encoding", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_DELTA_ENCODING = NativeLibrary.downcall( - "rocksdb_block_based_options_get_use_delta_encoding", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK = NativeLibrary.downcall( - "rocksdb_block_based_options_set_separate_key_value_in_data_block", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SEPARATE_KEY_VALUE_IN_DATA_BLOCK = NativeLibrary.downcall( - "rocksdb_block_based_options_get_separate_key_value_in_data_block", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_OPTIMIZE_FILTERS_FOR_MEMORY = NativeLibrary.downcall( - "rocksdb_block_based_options_set_optimize_filters_for_memory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_OPTIMIZE_FILTERS_FOR_MEMORY = NativeLibrary.downcall( - "rocksdb_block_based_options_get_optimize_filters_for_memory", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DECOUPLE_PARTITIONED_FILTERS = NativeLibrary.downcall( - "rocksdb_block_based_options_set_decouple_partitioned_filters", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_DECOUPLE_PARTITIONED_FILTERS = NativeLibrary.downcall( - "rocksdb_block_based_options_get_decouple_partitioned_filters", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO = NativeLibrary.downcall( - "rocksdb_block_based_options_set_data_block_hash_table_util_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_DATA_BLOCK_HASH_TABLE_UTIL_RATIO = NativeLibrary.downcall( - "rocksdb_block_based_options_get_data_block_hash_table_util_ratio", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_INDEX_SHORTENING = NativeLibrary.downcall("rocksdb_block_based_options_set_index_shortening", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_INDEX_SHORTENING = NativeLibrary.downcall("rocksdb_block_based_options_get_index_shortening", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_DATA_BLOCK_INDEX_TYPE = NativeLibrary.downcall("rocksdb_block_based_options_set_data_block_index_type", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_DATA_BLOCK_INDEX_TYPE = NativeLibrary.downcall("rocksdb_block_based_options_get_data_block_index_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_OPTIMIZE_KEY_COMMON_PREFIX = NativeLibrary.downcall("rocksdb_block_based_options_set_optimize_key_common_prefix", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_OPTIMIZE_KEY_COMMON_PREFIX = NativeLibrary.downcall("rocksdb_block_based_options_get_optimize_key_common_prefix", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_INDEX_BLOCK_SEARCH_TYPE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_index_block_search_type", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_INDEX_BLOCK_SEARCH_TYPE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_index_block_search_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_ENABLE_INDEX_COMPRESSION = NativeLibrary.downcall( - "rocksdb_block_based_options_set_enable_index_compression", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ENABLE_INDEX_COMPRESSION = NativeLibrary.downcall( - "rocksdb_block_based_options_get_enable_index_compression", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_UNIFORM_CV_THRESHOLD = NativeLibrary.downcall("rocksdb_block_based_options_set_uniform_cv_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_UNIFORM_CV_THRESHOLD = NativeLibrary.downcall("rocksdb_block_based_options_get_uniform_cv_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_CHECKSUM = NativeLibrary.downcall("rocksdb_block_based_options_set_checksum", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_CHECKSUM = NativeLibrary.downcall("rocksdb_block_based_options_get_checksum", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_VERIFY_COMPRESSION = NativeLibrary.downcall("rocksdb_block_based_options_set_verify_compression", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_VERIFY_COMPRESSION = NativeLibrary.downcall("rocksdb_block_based_options_get_verify_compression", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DETECT_FILTER_CONSTRUCT_CORRUPTION = NativeLibrary.downcall( - "rocksdb_block_based_options_set_detect_filter_construct_corruption", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_DETECT_FILTER_CONSTRUCT_CORRUPTION = NativeLibrary.downcall( - "rocksdb_block_based_options_get_detect_filter_construct_corruption", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_READ_AMP_BYTES_PER_BIT = NativeLibrary.downcall( - "rocksdb_block_based_options_set_read_amp_bytes_per_bit", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_READ_AMP_BYTES_PER_BIT = NativeLibrary.downcall( - "rocksdb_block_based_options_get_read_amp_bytes_per_bit", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_BLOCK_ALIGN = NativeLibrary.downcall("rocksdb_block_based_options_set_block_align", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_BLOCK_ALIGN = NativeLibrary.downcall("rocksdb_block_based_options_get_block_align", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SUPER_BLOCK_ALIGNMENT_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_super_block_alignment_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_SUPER_BLOCK_ALIGNMENT_SIZE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_super_block_alignment_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO = NativeLibrary.downcall( - "rocksdb_block_based_options_set_super_block_alignment_space_overhead_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_SUPER_BLOCK_ALIGNMENT_SPACE_OVERHEAD_RATIO = NativeLibrary.downcall( - "rocksdb_block_based_options_get_super_block_alignment_space_overhead_ratio", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_PREPOPULATE_BLOCK_CACHE = NativeLibrary.downcall( - "rocksdb_block_based_options_set_prepopulate_block_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_PREPOPULATE_BLOCK_CACHE = NativeLibrary.downcall( - "rocksdb_block_based_options_get_prepopulate_block_cache", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_UDI_FACTORY_FROM_STRING = NativeLibrary.downcall( - "rocksdb_block_based_options_set_user_defined_index_factory_from_string", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_CLEAR_UDI_FACTORY = NativeLibrary.downcall( - "rocksdb_block_based_options_clear_user_defined_index_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_GET_UDI_FACTORY_NAME = NativeLibrary.downcall( - "rocksdb_block_based_options_get_user_defined_index_factory_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_UDI_FACTORY_NAME = NativeLibrary.downcall( + "rocksdb_block_based_options_get_user_defined_index_factory_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private BlockBasedTableOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceOptions.java index bfe0448e..8999fabb 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceOptions.java @@ -14,27 +14,21 @@ public final class BlockCacheTraceOptions extends NativeObject { /// `rocksdb_block_cache_trace_options_t* rocksdb_block_cache_trace_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_block_cache_trace_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_cache_trace_options_destroy(rocksdb_block_cache_trace_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_block_cache_trace_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_cache_trace_options_set_sampling_frequency(rocksdb_block_cache_trace_options_t*, uint64_t);` - private static final MethodHandle MH_SET_SAMPLING_FREQUENCY; + private static final MethodHandle MH_SET_SAMPLING_FREQUENCY = NativeLibrary.downcall( + "rocksdb_block_cache_trace_options_set_sampling_frequency", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_block_cache_trace_options_get_sampling_frequency(rocksdb_block_cache_trace_options_t*);` - private static final MethodHandle MH_GET_SAMPLING_FREQUENCY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_block_cache_trace_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_block_cache_trace_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SAMPLING_FREQUENCY = NativeLibrary.downcall("rocksdb_block_cache_trace_options_set_sampling_frequency", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_SAMPLING_FREQUENCY = NativeLibrary.downcall("rocksdb_block_cache_trace_options_get_sampling_frequency", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_SAMPLING_FREQUENCY = NativeLibrary.downcall( + "rocksdb_block_cache_trace_options_get_sampling_frequency", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); private BlockCacheTraceOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceWriterOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceWriterOptions.java index 3eece720..98a00e8a 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceWriterOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/BlockCacheTraceWriterOptions.java @@ -14,29 +14,21 @@ public final class BlockCacheTraceWriterOptions extends NativeObject { /// `rocksdb_block_cache_trace_writer_options_t* rocksdb_block_cache_trace_writer_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_block_cache_trace_writer_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_cache_trace_writer_options_destroy(rocksdb_block_cache_trace_writer_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_block_cache_trace_writer_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_block_cache_trace_writer_options_set_max_trace_file_size(rocksdb_block_cache_trace_writer_options_t*, uint64_t);` - private static final MethodHandle MH_SET_MAX_TRACE_FILE_SIZE; + private static final MethodHandle MH_SET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_block_cache_trace_writer_options_set_max_trace_file_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_block_cache_trace_writer_options_get_max_trace_file_size(rocksdb_block_cache_trace_writer_options_t*);` - private static final MethodHandle MH_GET_MAX_TRACE_FILE_SIZE; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_block_cache_trace_writer_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_block_cache_trace_writer_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( - "rocksdb_block_cache_trace_writer_options_set_max_trace_file_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( - "rocksdb_block_cache_trace_writer_options_get_max_trace_file_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_block_cache_trace_writer_options_get_max_trace_file_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); private BlockCacheTraceWriterOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Cache.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Cache.java index aa41a6d3..f5fe2f04 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Cache.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Cache.java @@ -13,47 +13,37 @@ public abstract class Cache extends NativeObject { /// `void rocksdb_cache_destroy(rocksdb_cache_t* cache);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_cache_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_cache_set_capacity(rocksdb_cache_t* cache, size_t capacity);` - private static final MethodHandle MH_SET_CAPACITY; + private static final MethodHandle MH_SET_CAPACITY = NativeLibrary.downcall( + "rocksdb_cache_set_capacity", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_cache_get_capacity(const rocksdb_cache_t* cache);` - private static final MethodHandle MH_GET_CAPACITY; + private static final MethodHandle MH_GET_CAPACITY = NativeLibrary.downcall( + "rocksdb_cache_get_capacity", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_cache_get_usage(const rocksdb_cache_t* cache);` - private static final MethodHandle MH_GET_USAGE; + private static final MethodHandle MH_GET_USAGE = NativeLibrary.downcall( + "rocksdb_cache_get_usage", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_cache_get_pinned_usage(const rocksdb_cache_t* cache);` - private static final MethodHandle MH_GET_PINNED_USAGE; + private static final MethodHandle MH_GET_PINNED_USAGE = NativeLibrary.downcall( + "rocksdb_cache_get_pinned_usage", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache);` - private static final MethodHandle MH_GET_TABLE_ADDRESS_COUNT; + private static final MethodHandle MH_GET_TABLE_ADDRESS_COUNT = NativeLibrary.downcall( + "rocksdb_cache_get_table_address_count", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache);` - private static final MethodHandle MH_GET_OCCUPANCY_COUNT; + private static final MethodHandle MH_GET_OCCUPANCY_COUNT = NativeLibrary.downcall( + "rocksdb_cache_get_occupancy_count", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_cache_disown_data(rocksdb_cache_t* cache);` - private static final MethodHandle MH_DISOWN_DATA; - - static { - MH_DESTROY = NativeLibrary.downcall("rocksdb_cache_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_CAPACITY = NativeLibrary.downcall("rocksdb_cache_set_capacity", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_CAPACITY = NativeLibrary.downcall("rocksdb_cache_get_capacity", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_GET_USAGE = NativeLibrary.downcall("rocksdb_cache_get_usage", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_GET_PINNED_USAGE = NativeLibrary.downcall("rocksdb_cache_get_pinned_usage", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_GET_TABLE_ADDRESS_COUNT = NativeLibrary.downcall("rocksdb_cache_get_table_address_count", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_GET_OCCUPANCY_COUNT = NativeLibrary.downcall("rocksdb_cache_get_occupancy_count", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_DISOWN_DATA = NativeLibrary.downcall("rocksdb_cache_disown_data", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DISOWN_DATA = NativeLibrary.downcall( + "rocksdb_cache_disown_data", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// Constructs a cache wrapping the given native pointer. /// diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Checkpoint.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Checkpoint.java index 015893bc..f03b813c 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Checkpoint.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Checkpoint.java @@ -28,28 +28,25 @@ public final class Checkpoint extends NativeObject { /// `rocksdb_checkpoint_t* rocksdb_checkpoint_object_create(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_checkpoint_object_create", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_checkpoint_create(rocksdb_checkpoint_t* checkpoint, const char* checkpoint_dir, uint64_t log_size_for_flush, char** errptr);` - private static final MethodHandle MH_EXPORT; + private static final MethodHandle MH_EXPORT = NativeLibrary.downcall( + "rocksdb_checkpoint_create", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // checkpoint + ValueLayout.ADDRESS, // checkpoint_dir + ValueLayout.JAVA_LONG, // log_size_for_flush + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_checkpoint_object_destroy(rocksdb_checkpoint_t* checkpoint);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_checkpoint_object_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS)); // errptr - - MH_EXPORT = NativeLibrary.downcall("rocksdb_checkpoint_create", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // checkpoint - ValueLayout.ADDRESS, // checkpoint_dir - ValueLayout.JAVA_LONG, // log_size_for_flush - ValueLayout.ADDRESS)); // errptr - - MH_DESTROY = NativeLibrary.downcall("rocksdb_checkpoint_object_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_checkpoint_object_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private Checkpoint(NativeObjectWithChildren owningDb, MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/ColumnFamilyHandle.java b/core/src/main/java/io/github/dfa1/rocksdbffm/ColumnFamilyHandle.java index 59349d30..b114ef8c 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/ColumnFamilyHandle.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/ColumnFamilyHandle.java @@ -21,28 +21,21 @@ public final class ColumnFamilyHandle extends NativeObject { /// `void rocksdb_column_family_handle_destroy(rocksdb_column_family_handle_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_column_family_handle_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `rocksdb_column_family_handle_t* rocksdb_get_default_column_family_handle(rocksdb_t* db);` - private static final MethodHandle MH_GET_DEFAULT; + private static final MethodHandle MH_GET_DEFAULT = NativeLibrary.downcall( + "rocksdb_get_default_column_family_handle", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_column_family_handle_get_id(rocksdb_column_family_handle_t* handle);` - private static final MethodHandle MH_GET_ID; + private static final MethodHandle MH_GET_ID = NativeLibrary.downcall( + "rocksdb_column_family_handle_get_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `char* rocksdb_column_family_handle_get_name(rocksdb_column_family_handle_t* handle, size_t* name_len);` - private static final MethodHandle MH_GET_NAME; - - static { - MH_DESTROY = NativeLibrary.downcall("rocksdb_column_family_handle_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_GET_DEFAULT = NativeLibrary.downcall("rocksdb_get_default_column_family_handle", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_GET_ID = NativeLibrary.downcall("rocksdb_column_family_handle_get_id", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_GET_NAME = NativeLibrary.downcall("rocksdb_column_family_handle_get_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_NAME = NativeLibrary.downcall( + "rocksdb_column_family_handle_get_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private ColumnFamilyHandle(NativeObjectWithChildren owningDb, MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactOptions.java index a2d2727c..91944001 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactOptions.java @@ -15,65 +15,45 @@ public final class CompactOptions extends NativeObject { /// `rocksdb_compactoptions_t* rocksdb_compactoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_compactoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_compactoptions_destroy(rocksdb_compactoptions_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_compactoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_compactoptions_set_exclusive_manual_compaction(rocksdb_compactoptions_t*, unsigned char);` - private static final MethodHandle MH_SET_EXCLUSIVE; + private static final MethodHandle MH_SET_EXCLUSIVE = NativeLibrary.downcall( + "rocksdb_compactoptions_set_exclusive_manual_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_compactoptions_get_exclusive_manual_compaction(rocksdb_compactoptions_t*);` - private static final MethodHandle MH_GET_EXCLUSIVE; + private static final MethodHandle MH_GET_EXCLUSIVE = NativeLibrary.downcall( + "rocksdb_compactoptions_get_exclusive_manual_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_compactoptions_set_bottommost_level_compaction(rocksdb_compactoptions_t*, unsigned char);` - private static final MethodHandle MH_SET_BOTTOMMOST; + private static final MethodHandle MH_SET_BOTTOMMOST = NativeLibrary.downcall( + "rocksdb_compactoptions_set_bottommost_level_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_compactoptions_get_bottommost_level_compaction(rocksdb_compactoptions_t*);` - private static final MethodHandle MH_GET_BOTTOMMOST; + private static final MethodHandle MH_GET_BOTTOMMOST = NativeLibrary.downcall( + "rocksdb_compactoptions_get_bottommost_level_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_compactoptions_set_change_level(rocksdb_compactoptions_t*, unsigned char);` - private static final MethodHandle MH_SET_CHANGE_LEVEL; + private static final MethodHandle MH_SET_CHANGE_LEVEL = NativeLibrary.downcall( + "rocksdb_compactoptions_set_change_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_compactoptions_get_change_level(rocksdb_compactoptions_t*);` - private static final MethodHandle MH_GET_CHANGE_LEVEL; + private static final MethodHandle MH_GET_CHANGE_LEVEL = NativeLibrary.downcall( + "rocksdb_compactoptions_get_change_level", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_compactoptions_set_target_level(rocksdb_compactoptions_t*, int);` - private static final MethodHandle MH_SET_TARGET_LEVEL; + private static final MethodHandle MH_SET_TARGET_LEVEL = NativeLibrary.downcall( + "rocksdb_compactoptions_set_target_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_compactoptions_get_target_level(rocksdb_compactoptions_t*);` - private static final MethodHandle MH_GET_TARGET_LEVEL; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_compactoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_compactoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_EXCLUSIVE = NativeLibrary.downcall( - "rocksdb_compactoptions_set_exclusive_manual_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_EXCLUSIVE = NativeLibrary.downcall( - "rocksdb_compactoptions_get_exclusive_manual_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BOTTOMMOST = NativeLibrary.downcall( - "rocksdb_compactoptions_set_bottommost_level_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_BOTTOMMOST = NativeLibrary.downcall( - "rocksdb_compactoptions_get_bottommost_level_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_CHANGE_LEVEL = NativeLibrary.downcall( - "rocksdb_compactoptions_set_change_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_CHANGE_LEVEL = NativeLibrary.downcall( - "rocksdb_compactoptions_get_change_level", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TARGET_LEVEL = NativeLibrary.downcall( - "rocksdb_compactoptions_set_target_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_TARGET_LEVEL = NativeLibrary.downcall( - "rocksdb_compactoptions_get_target_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_TARGET_LEVEL = NativeLibrary.downcall( + "rocksdb_compactoptions_get_target_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private CompactOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilter.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilter.java index a168bf1e..6f0c1b77 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilter.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilter.java @@ -5,7 +5,6 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.util.Arrays; import java.util.concurrent.ConcurrentHashMap; @@ -53,6 +52,8 @@ /// ``` public final class CompactionFilter extends NativeObject { + private static final System.Logger LOG = System.getLogger(CompactionFilter.class.getName()); + /// `rocksdb_compactionfilter_t* rocksdb_compactionfilter_create(void* state, void (*destructor)(void*), unsigned char (*filter)(void*, int level, const char* key, size_t key_length, const char* existing_value, size_t value_length, char** new_value, size_t* new_value_length, unsigned char* value_changed), const char* (*name)(void*));` private static final MethodHandle MH_COMPACTIONFILTER_CREATE = NativeLibrary.downcall( "rocksdb_compactionfilter_create", @@ -60,24 +61,29 @@ public final class CompactionFilter extends NativeObject { ValueLayout.ADDRESS, // state ValueLayout.ADDRESS, // destructor ValueLayout.ADDRESS, // filter - ValueLayout.ADDRESS)); // name + ValueLayout.ADDRESS) // name + ); /// `void rocksdb_compactionfilter_set_ignore_snapshots(rocksdb_compactionfilter_t*, unsigned char);` private static final MethodHandle MH_SET_IGNORE_SNAPSHOTS = NativeLibrary.downcall( - "rocksdb_compactionfilter_set_ignore_snapshots", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); + "rocksdb_compactionfilter_set_ignore_snapshots", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_compactionfilter_destroy(rocksdb_compactionfilter_t*);` private static final MethodHandle MH_COMPACTIONFILTER_DESTROY = NativeLibrary.downcall( - "rocksdb_compactionfilter_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + "rocksdb_compactionfilter_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_compaction_filter(rocksdb_options_t*, rocksdb_compactionfilter_t*);` private static final MethodHandle MH_SET_COMPACTION_FILTER = NativeLibrary.downcall( - "rocksdb_options_set_compaction_filter", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_options_set_compaction_filter", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); - private static final FunctionDescriptor FILTER_DESC = FunctionDescriptor.of(ValueLayout.JAVA_BYTE, + // One global upcall stub per callback shape, shared by every instance. Lives for the JVM + // lifetime so the function pointers are always valid; dispatch is keyed off the `state` + // pointer, which carries a registry ID rather than real memory (same trick as MergeOperator.Custom). + private static final MemorySegment FILTER_STUB = NativeLibrary.upcall( + "filterDispatch", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, // state ValueLayout.JAVA_INT, // level ValueLayout.ADDRESS, // key @@ -86,18 +92,14 @@ public final class CompactionFilter extends NativeObject { NativeCalls.SIZE_T, // value_length ValueLayout.ADDRESS, // new_value ValueLayout.ADDRESS, // new_value_length - ValueLayout.ADDRESS); // value_changed - - private static final FunctionDescriptor DESTRUCTOR_DESC = FunctionDescriptor.ofVoid(ValueLayout.ADDRESS); - - private static final FunctionDescriptor NAME_DESC = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS); - - // One global upcall stub per callback shape, shared by every instance. Lives for the JVM - // lifetime so the function pointers are always valid; dispatch is keyed off the `state` - // pointer, which carries a registry ID rather than real memory (same trick as MergeOperator.Custom). - private static final MemorySegment FILTER_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "filterDispatch", FILTER_DESC); - private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "destructorDispatch", DESTRUCTOR_DESC); - private static final MemorySegment NAME_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "nameDispatch", NAME_DESC); + ValueLayout.ADDRESS) + ); + private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall( + "destructorDispatch", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); + private static final MemorySegment NAME_STUB = NativeLibrary.upcall( + "nameDispatch", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `scratchBuffers` backs [#scratchBuffer(State, byte[])] — one buffer per compaction thread /// that has returned a [FilterDecision.ChangeValue], reused and grown as needed rather than @@ -123,7 +125,6 @@ private record ScratchBuffer(Arena arena, MemorySegment segment) { // so this entry lives for the JVM; a filter closed before it is attached is destroyed by tryClose, which // fires destructorDispatch (same rationale as MergeOperator.Custom). private static final UpcallRegistry REGISTRY = new UpcallRegistry<>(); - private static final System.Logger LOG = System.getLogger(CompactionFilter.class.getName()); private CompactionFilter(MemorySegment ptr) { super(ptr); @@ -158,7 +159,7 @@ public static CompactionFilter create(String name, FilterFn fn) { /// **`false` does not work in the pinned RocksDB version:** `CompactionJob::SetupAndValidateCompactionFilter` /// (`db/compaction/compaction_job.cc`) rejects every compaction that uses a filter with /// `IgnoreSnapshots() == false`, returning `Status::NotSupported("CompactionFilter::IgnoreSnapshots() = false is - /// not supported anymore.")` — confirmed by upstream's own `DBTestCompactionFilter.IgnoreSnapshotsFalse` test. + /// not supported anymore.")` — confirmed by upstream's own `DBTestCompactionFilter.IgnoreSnapshotsFalse` test. /// `rocksdb_compact_range` (what `compactRange()` wraps) takes no `errptr` and returns `void`, so this failure /// is silent: the compaction simply does nothing, and the caller has no way to detect it. Passing `false` here /// is kept only for parity with the C API's setter; leave this at its `true` default. @@ -351,6 +352,7 @@ private static MemorySegment scratchBuffer(State s, byte[] data) { } /// Called from [#FILTER_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static byte filterDispatch(MemorySegment state, int level, MemorySegment key, long keyLength, MemorySegment existingValue, long valueLength, MemorySegment newValue, MemorySegment newValueLength, MemorySegment valueChanged) { @@ -391,6 +393,7 @@ private static byte filterDispatch(MemorySegment state, int level, MemorySegment /// immortal. Also frees every scratch /// buffer [#scratchBuffer(State, byte[])] handed out — safe because no `Filter()` call can /// still be in flight once RocksDB itself is destroying this filter. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void destructorDispatch(MemorySegment state) { State s = REGISTRY.unregister(state); if (s != null) { @@ -406,6 +409,7 @@ private static void destructorDispatch(MemorySegment state) { /// Called from [#NAME_STUB]. Must not throw, and must never return a value that isn't a /// valid NUL-terminated native string (see [#EMPTY_NAME]). + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment nameDispatch(MemorySegment state) { try { State s = REGISTRY.get(state); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterContext.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterContext.java index 5a6d3625..f698a729 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterContext.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterContext.java @@ -15,13 +15,13 @@ public final class CompactionFilterContext { /// `unsigned char rocksdb_compactionfiltercontext_is_full_compaction(rocksdb_compactionfiltercontext_t* context);` private static final MethodHandle MH_IS_FULL_COMPACTION = NativeLibrary.downcall( - "rocksdb_compactionfiltercontext_is_full_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); + "rocksdb_compactionfiltercontext_is_full_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_compactionfiltercontext_is_manual_compaction(rocksdb_compactionfiltercontext_t* context);` private static final MethodHandle MH_IS_MANUAL_COMPACTION = NativeLibrary.downcall( - "rocksdb_compactionfiltercontext_is_manual_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); + "rocksdb_compactionfiltercontext_is_manual_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterFactory.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterFactory.java index f4afa36e..aad453c2 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterFactory.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionFilterFactory.java @@ -5,7 +5,6 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; /// A factory that creates a fresh [CompactionFilter] for every compaction, attached via /// [Options#setCompactionFilterFactory(CompactionFilterFactory)]. @@ -33,22 +32,23 @@ public final class CompactionFilterFactory extends NativeObject { /// `rocksdb_compactionfilterfactory_t* rocksdb_compactionfilterfactory_create(void* state, void (*destructor)(void*), rocksdb_compactionfilter_t* (*create_compaction_filter)(void*, rocksdb_compactionfiltercontext_t* context), const char* (*name)(void*));` private static final MethodHandle MH_COMPACTIONFILTERFACTORY_CREATE = NativeLibrary.downcall( - "rocksdb_compactionfilterfactory_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // state - ValueLayout.ADDRESS, // destructor - ValueLayout.ADDRESS, // create_compaction_filter - ValueLayout.ADDRESS)); // name + "rocksdb_compactionfilterfactory_create", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // state + ValueLayout.ADDRESS, // destructor + ValueLayout.ADDRESS, // create_compaction_filter + ValueLayout.ADDRESS) // name + ); /// `void rocksdb_compactionfilterfactory_destroy(rocksdb_compactionfilterfactory_t*);` private static final MethodHandle MH_COMPACTIONFILTERFACTORY_DESTROY = NativeLibrary.downcall( - "rocksdb_compactionfilterfactory_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + "rocksdb_compactionfilterfactory_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_compaction_filter_factory(rocksdb_options_t*, rocksdb_compactionfilterfactory_t*);` private static final MethodHandle MH_SET_COMPACTION_FILTER_FACTORY = NativeLibrary.downcall( - "rocksdb_options_set_compaction_filter_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_options_set_compaction_filter_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private static final FunctionDescriptor CREATE_FILTER_DESC = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, // state @@ -61,9 +61,15 @@ public final class CompactionFilterFactory extends NativeObject { // One global upcall stub per callback shape, shared by every instance. Lives for the JVM // lifetime so the function pointers are always valid; dispatch is keyed off the `state` // pointer, which carries a registry ID rather than real memory (same trick as CompactionFilter). - private static final MemorySegment CREATE_FILTER_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "createCompactionFilterDispatch", CREATE_FILTER_DESC); - private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "destructorDispatch", DESTRUCTOR_DESC); - private static final MemorySegment NAME_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "nameDispatch", NAME_DESC); + private static final MemorySegment CREATE_FILTER_STUB = NativeLibrary.upcall( + "createCompactionFilterDispatch", CREATE_FILTER_DESC + ); + private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall( + "destructorDispatch", DESTRUCTOR_DESC + ); + private static final MemorySegment NAME_STUB = NativeLibrary.upcall( + "nameDispatch", NAME_DESC + ); private record State(CreateFilterFn fn, MemorySegment nameSeg) { } @@ -141,6 +147,7 @@ public interface CreateFilterFn { } /// Called from [#CREATE_FILTER_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment createCompactionFilterDispatch(MemorySegment state, MemorySegment contextPtr) { BackgroundUpcallThreads.track(); try { @@ -176,6 +183,7 @@ private static MemorySegment createCompactionFilterDispatch(MemorySegment state, /// Called from [#DESTRUCTOR_STUB] when RocksDB's internal `shared_ptr` refcount hits zero. /// This is the only reliable unregistration point: ownership transfer via [#applyTo] means /// [#tryClose(MemorySegment)] may never run for this instance. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void destructorDispatch(MemorySegment state) { REGISTRY.unregister(state); } @@ -188,6 +196,7 @@ private static void destructorDispatch(MemorySegment state) { /// Called from [#NAME_STUB]. Must not throw, and must never return a value that isn't a /// valid NUL-terminated native string (see [#EMPTY_NAME]). + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment nameDispatch(MemorySegment state) { try { State s = REGISTRY.get(state); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionJobInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionJobInfo.java index 01b4e2af..478174ed 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionJobInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CompactionJobInfo.java @@ -20,104 +20,113 @@ public final class CompactionJobInfo { /// `uint32_t rocksdb_compactionjobinfo_cf_id(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_CF_ID = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_cf_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_cf_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_compactionjobinfo_cf_name(const rocksdb_compactionjobinfo_t*, size_t* size);` private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_cf_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_cf_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_compactionjobinfo_status(const rocksdb_compactionjobinfo_t*, char** errptr);` private static final MethodHandle MH_STATUS = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_status", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_status", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_thread_id(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_THREAD_ID = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_thread_id", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_thread_id", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `int rocksdb_compactionjobinfo_job_id(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_JOB_ID = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_job_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_job_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `int rocksdb_compactionjobinfo_num_l0_files(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_NUM_L0_FILES = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_num_l0_files", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_num_l0_files", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `int rocksdb_compactionjobinfo_base_input_level(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_BASE_INPUT_LEVEL = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_base_input_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_base_input_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `int rocksdb_compactionjobinfo_output_level(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_OUTPUT_LEVEL = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_output_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_output_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_compactionjobinfo_compaction_reason(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_COMPACTION_REASON = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_compaction_reason", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_compaction_reason", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_compactionjobinfo_compression(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_COMPRESSION = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_compression", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_compression", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_compactionjobinfo_blob_compression_type(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_blob_compression_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_blob_compression_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_compactionjobinfo_aborted(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_ABORTED = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_aborted", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_aborted", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_compactionjobinfo_input_files_count(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_INPUT_FILES_COUNT = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_input_files_count", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_input_files_count", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_compactionjobinfo_output_files_count(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_OUTPUT_FILES_COUNT = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_output_files_count", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_output_files_count", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_elapsed_micros(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_ELAPSED_MICROS = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_elapsed_micros", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_elapsed_micros", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_num_corrupt_keys(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_NUM_CORRUPT_KEYS = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_num_corrupt_keys", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_num_corrupt_keys", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_input_records(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_INPUT_RECORDS = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_input_records", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_input_records", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_output_records(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_OUTPUT_RECORDS = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_output_records", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_output_records", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_total_input_bytes(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_TOTAL_INPUT_BYTES = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_total_input_bytes", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_total_input_bytes", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_compactionjobinfo_total_output_bytes(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_TOTAL_OUTPUT_BYTES = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_total_output_bytes", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_total_output_bytes", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_compactionjobinfo_num_input_files(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_NUM_INPUT_FILES = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_num_input_files", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_num_input_files", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_compactionjobinfo_num_input_files_at_output_level(const rocksdb_compactionjobinfo_t*);` private static final MethodHandle MH_NUM_INPUT_FILES_AT_OUTPUT_LEVEL = NativeLibrary.downcall( - "rocksdb_compactionjobinfo_num_input_files_at_output_level", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); + "rocksdb_compactionjobinfo_num_input_files_at_output_level", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/CuckooTableOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/CuckooTableOptions.java index 380d5eaf..6c761a3e 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/CuckooTableOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/CuckooTableOptions.java @@ -23,67 +23,53 @@ public final class CuckooTableOptions extends NativeObject { /// `rocksdb_cuckoo_table_options_t* rocksdb_cuckoo_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_cuckoo_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_destroy(rocksdb_cuckoo_table_options_t* options);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_cuckoo_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_set_hash_table_ratio(rocksdb_cuckoo_table_options_t* opt, double v);` - private static final MethodHandle MH_SET_HASH_TABLE_RATIO; + private static final MethodHandle MH_SET_HASH_TABLE_RATIO = NativeLibrary.downcall( + "rocksdb_cuckoo_options_set_hash_table_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_cuckoo_options_get_hash_table_ratio(rocksdb_cuckoo_table_options_t* opt);` - private static final MethodHandle MH_GET_HASH_TABLE_RATIO; + private static final MethodHandle MH_GET_HASH_TABLE_RATIO = NativeLibrary.downcall( + "rocksdb_cuckoo_options_get_hash_table_ratio", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_set_max_search_depth(rocksdb_cuckoo_table_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_MAX_SEARCH_DEPTH; + private static final MethodHandle MH_SET_MAX_SEARCH_DEPTH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_set_max_search_depth", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_cuckoo_options_get_max_search_depth(rocksdb_cuckoo_table_options_t* opt);` - private static final MethodHandle MH_GET_MAX_SEARCH_DEPTH; + private static final MethodHandle MH_GET_MAX_SEARCH_DEPTH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_get_max_search_depth", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_set_cuckoo_block_size(rocksdb_cuckoo_table_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_CUCKOO_BLOCK_SIZE; + private static final MethodHandle MH_SET_CUCKOO_BLOCK_SIZE = NativeLibrary.downcall( + "rocksdb_cuckoo_options_set_cuckoo_block_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_cuckoo_options_get_cuckoo_block_size(rocksdb_cuckoo_table_options_t* opt);` - private static final MethodHandle MH_GET_CUCKOO_BLOCK_SIZE; + private static final MethodHandle MH_GET_CUCKOO_BLOCK_SIZE = NativeLibrary.downcall( + "rocksdb_cuckoo_options_get_cuckoo_block_size", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_set_identity_as_first_hash(rocksdb_cuckoo_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_IDENTITY_AS_FIRST_HASH; + private static final MethodHandle MH_SET_IDENTITY_AS_FIRST_HASH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_set_identity_as_first_hash", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_cuckoo_options_get_identity_as_first_hash(rocksdb_cuckoo_table_options_t* opt);` - private static final MethodHandle MH_GET_IDENTITY_AS_FIRST_HASH; + private static final MethodHandle MH_GET_IDENTITY_AS_FIRST_HASH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_get_identity_as_first_hash", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_cuckoo_options_set_use_module_hash(rocksdb_cuckoo_table_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_MODULE_HASH; + private static final MethodHandle MH_SET_USE_MODULE_HASH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_set_use_module_hash", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_cuckoo_options_get_use_module_hash(rocksdb_cuckoo_table_options_t* opt);` - private static final MethodHandle MH_GET_USE_MODULE_HASH; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_cuckoo_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_cuckoo_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_HASH_TABLE_RATIO = NativeLibrary.downcall("rocksdb_cuckoo_options_set_hash_table_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_HASH_TABLE_RATIO = NativeLibrary.downcall("rocksdb_cuckoo_options_get_hash_table_ratio", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_MAX_SEARCH_DEPTH = NativeLibrary.downcall("rocksdb_cuckoo_options_set_max_search_depth", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_SEARCH_DEPTH = NativeLibrary.downcall("rocksdb_cuckoo_options_get_max_search_depth", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_CUCKOO_BLOCK_SIZE = NativeLibrary.downcall("rocksdb_cuckoo_options_set_cuckoo_block_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_CUCKOO_BLOCK_SIZE = NativeLibrary.downcall("rocksdb_cuckoo_options_get_cuckoo_block_size", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_IDENTITY_AS_FIRST_HASH = NativeLibrary.downcall("rocksdb_cuckoo_options_set_identity_as_first_hash", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_IDENTITY_AS_FIRST_HASH = NativeLibrary.downcall("rocksdb_cuckoo_options_get_identity_as_first_hash", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_MODULE_HASH = NativeLibrary.downcall("rocksdb_cuckoo_options_set_use_module_hash", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_MODULE_HASH = NativeLibrary.downcall("rocksdb_cuckoo_options_get_use_module_hash", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_USE_MODULE_HASH = NativeLibrary.downcall( + "rocksdb_cuckoo_options_get_use_module_hash", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private CuckooTableOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Env.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Env.java index e5d2ccd9..2a353ac0 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Env.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Env.java @@ -24,44 +24,33 @@ public final class Env extends NativeObject { /// `rocksdb_env_t* rocksdb_create_default_env(void);` - private static final MethodHandle MH_CREATE_DEFAULT; + private static final MethodHandle MH_CREATE_DEFAULT = NativeLibrary.downcall( + "rocksdb_create_default_env", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `rocksdb_env_t* rocksdb_create_mem_env(void);` - private static final MethodHandle MH_CREATE_MEM; + private static final MethodHandle MH_CREATE_MEM = NativeLibrary.downcall( + "rocksdb_create_mem_env", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_env_destroy(rocksdb_env_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_env_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_env_set_background_threads(rocksdb_env_t* env, int n);` - private static final MethodHandle MH_SET_BACKGROUND_THREADS; + private static final MethodHandle MH_SET_BACKGROUND_THREADS = NativeLibrary.downcall( + "rocksdb_env_set_background_threads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_env_get_background_threads(rocksdb_env_t* env);` - private static final MethodHandle MH_GET_BACKGROUND_THREADS; + private static final MethodHandle MH_GET_BACKGROUND_THREADS = NativeLibrary.downcall( + "rocksdb_env_get_background_threads", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_env_set_high_priority_background_threads(rocksdb_env_t* env, int n);` - private static final MethodHandle MH_SET_HIGH_PRIORITY_BACKGROUND_THREADS; + private static final MethodHandle MH_SET_HIGH_PRIORITY_BACKGROUND_THREADS = NativeLibrary.downcall( + "rocksdb_env_set_high_priority_background_threads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_env_get_high_priority_background_threads(rocksdb_env_t* env);` - private static final MethodHandle MH_GET_HIGH_PRIORITY_BACKGROUND_THREADS; - - static { - MH_CREATE_DEFAULT = NativeLibrary.downcall("rocksdb_create_default_env", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_CREATE_MEM = NativeLibrary.downcall("rocksdb_create_mem_env", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_env_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_BACKGROUND_THREADS = NativeLibrary.downcall("rocksdb_env_set_background_threads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BACKGROUND_THREADS = NativeLibrary.downcall("rocksdb_env_get_background_threads", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_HIGH_PRIORITY_BACKGROUND_THREADS = NativeLibrary.downcall( - "rocksdb_env_set_high_priority_background_threads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_HIGH_PRIORITY_BACKGROUND_THREADS = NativeLibrary.downcall( - "rocksdb_env_get_high_priority_background_threads", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_HIGH_PRIORITY_BACKGROUND_THREADS = NativeLibrary.downcall( + "rocksdb_env_get_high_priority_background_threads", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// Wrapper around `Env::Default()` for the tracing/[Replayer] overloads that take no [Env]; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/EnvOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/EnvOptions.java index d4c5d6d4..cccefedb 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/EnvOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/EnvOptions.java @@ -23,136 +23,105 @@ public final class EnvOptions extends NativeObjectWithChildren { /// `rocksdb_envoptions_t* rocksdb_envoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_envoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_destroy(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_envoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_use_mmap_reads(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_MMAP_READS; + private static final MethodHandle MH_SET_USE_MMAP_READS = NativeLibrary.downcall( + "rocksdb_envoptions_set_use_mmap_reads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_use_mmap_reads(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_USE_MMAP_READS; + private static final MethodHandle MH_GET_USE_MMAP_READS = NativeLibrary.downcall( + "rocksdb_envoptions_get_use_mmap_reads", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_use_mmap_writes(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_MMAP_WRITES; + private static final MethodHandle MH_SET_USE_MMAP_WRITES = NativeLibrary.downcall( + "rocksdb_envoptions_set_use_mmap_writes", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_use_mmap_writes(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_USE_MMAP_WRITES; + private static final MethodHandle MH_GET_USE_MMAP_WRITES = NativeLibrary.downcall( + "rocksdb_envoptions_get_use_mmap_writes", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_use_direct_reads(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_DIRECT_READS; + private static final MethodHandle MH_SET_USE_DIRECT_READS = NativeLibrary.downcall( + "rocksdb_envoptions_set_use_direct_reads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_use_direct_reads(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_USE_DIRECT_READS; + private static final MethodHandle MH_GET_USE_DIRECT_READS = NativeLibrary.downcall( + "rocksdb_envoptions_get_use_direct_reads", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_use_direct_writes(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_DIRECT_WRITES; + private static final MethodHandle MH_SET_USE_DIRECT_WRITES = NativeLibrary.downcall( + "rocksdb_envoptions_set_use_direct_writes", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_use_direct_writes(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_USE_DIRECT_WRITES; + private static final MethodHandle MH_GET_USE_DIRECT_WRITES = NativeLibrary.downcall( + "rocksdb_envoptions_get_use_direct_writes", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_allow_fallocate(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ALLOW_FALLOCATE; + private static final MethodHandle MH_SET_ALLOW_FALLOCATE = NativeLibrary.downcall( + "rocksdb_envoptions_set_allow_fallocate", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_allow_fallocate(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_ALLOW_FALLOCATE; + private static final MethodHandle MH_GET_ALLOW_FALLOCATE = NativeLibrary.downcall( + "rocksdb_envoptions_get_allow_fallocate", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_fd_cloexec(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_FD_CLOEXEC; + private static final MethodHandle MH_SET_FD_CLOEXEC = NativeLibrary.downcall( + "rocksdb_envoptions_set_fd_cloexec", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_fd_cloexec(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_FD_CLOEXEC; + private static final MethodHandle MH_GET_FD_CLOEXEC = NativeLibrary.downcall( + "rocksdb_envoptions_get_fd_cloexec", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_bytes_per_sync(rocksdb_envoptions_t* opt, uint64_t v);` - private static final MethodHandle MH_SET_BYTES_PER_SYNC; + private static final MethodHandle MH_SET_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_envoptions_set_bytes_per_sync", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_envoptions_get_bytes_per_sync(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_BYTES_PER_SYNC; + private static final MethodHandle MH_GET_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_envoptions_get_bytes_per_sync", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_strict_bytes_per_sync(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_STRICT_BYTES_PER_SYNC; + private static final MethodHandle MH_SET_STRICT_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_envoptions_set_strict_bytes_per_sync", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_strict_bytes_per_sync(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_STRICT_BYTES_PER_SYNC; + private static final MethodHandle MH_GET_STRICT_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_envoptions_get_strict_bytes_per_sync", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_fallocate_with_keep_size(rocksdb_envoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_FALLOCATE_WITH_KEEP_SIZE; + private static final MethodHandle MH_SET_FALLOCATE_WITH_KEEP_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_set_fallocate_with_keep_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_envoptions_get_fallocate_with_keep_size(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_FALLOCATE_WITH_KEEP_SIZE; + private static final MethodHandle MH_GET_FALLOCATE_WITH_KEEP_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_get_fallocate_with_keep_size", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_compaction_readahead_size(rocksdb_envoptions_t* opt, size_t v);` - private static final MethodHandle MH_SET_COMPACTION_READAHEAD_SIZE; + private static final MethodHandle MH_SET_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_set_compaction_readahead_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_envoptions_get_compaction_readahead_size(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_COMPACTION_READAHEAD_SIZE; + private static final MethodHandle MH_GET_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_get_compaction_readahead_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_writable_file_max_buffer_size(rocksdb_envoptions_t* opt, size_t v);` - private static final MethodHandle MH_SET_WRITABLE_FILE_MAX_BUFFER_SIZE; + private static final MethodHandle MH_SET_WRITABLE_FILE_MAX_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_set_writable_file_max_buffer_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_envoptions_get_writable_file_max_buffer_size(rocksdb_envoptions_t* opt);` - private static final MethodHandle MH_GET_WRITABLE_FILE_MAX_BUFFER_SIZE; + private static final MethodHandle MH_GET_WRITABLE_FILE_MAX_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_envoptions_get_writable_file_max_buffer_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_envoptions_set_rate_limiter(rocksdb_envoptions_t* opt, rocksdb_ratelimiter_t* rate_limiter);` - private static final MethodHandle MH_SET_RATE_LIMITER; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_envoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_envoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_USE_MMAP_READS = NativeLibrary.downcall("rocksdb_envoptions_set_use_mmap_reads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_MMAP_READS = NativeLibrary.downcall("rocksdb_envoptions_get_use_mmap_reads", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_MMAP_WRITES = NativeLibrary.downcall("rocksdb_envoptions_set_use_mmap_writes", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_MMAP_WRITES = NativeLibrary.downcall("rocksdb_envoptions_get_use_mmap_writes", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_DIRECT_READS = NativeLibrary.downcall("rocksdb_envoptions_set_use_direct_reads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_DIRECT_READS = NativeLibrary.downcall("rocksdb_envoptions_get_use_direct_reads", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_DIRECT_WRITES = NativeLibrary.downcall("rocksdb_envoptions_set_use_direct_writes", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_DIRECT_WRITES = NativeLibrary.downcall("rocksdb_envoptions_get_use_direct_writes", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_ALLOW_FALLOCATE = NativeLibrary.downcall("rocksdb_envoptions_set_allow_fallocate", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ALLOW_FALLOCATE = NativeLibrary.downcall("rocksdb_envoptions_get_allow_fallocate", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_FD_CLOEXEC = NativeLibrary.downcall("rocksdb_envoptions_set_fd_cloexec", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_FD_CLOEXEC = NativeLibrary.downcall("rocksdb_envoptions_get_fd_cloexec", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_envoptions_set_bytes_per_sync", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_envoptions_get_bytes_per_sync", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_STRICT_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_envoptions_set_strict_bytes_per_sync", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_STRICT_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_envoptions_get_strict_bytes_per_sync", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_FALLOCATE_WITH_KEEP_SIZE = NativeLibrary.downcall("rocksdb_envoptions_set_fallocate_with_keep_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_FALLOCATE_WITH_KEEP_SIZE = NativeLibrary.downcall("rocksdb_envoptions_get_fallocate_with_keep_size", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_envoptions_set_compaction_readahead_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_envoptions_get_compaction_readahead_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_WRITABLE_FILE_MAX_BUFFER_SIZE = NativeLibrary.downcall( - "rocksdb_envoptions_set_writable_file_max_buffer_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_WRITABLE_FILE_MAX_BUFFER_SIZE = NativeLibrary.downcall( - "rocksdb_envoptions_get_writable_file_max_buffer_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_RATE_LIMITER = NativeLibrary.downcall("rocksdb_envoptions_set_rate_limiter", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_SET_RATE_LIMITER = NativeLibrary.downcall( + "rocksdb_envoptions_set_rate_limiter", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// Default file-I/O options for the `SstFileWriter`/tracing/[Replayer] overloads that take none; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/EventNotifierBridge.java b/core/src/main/java/io/github/dfa1/rocksdbffm/EventNotifierBridge.java index f681c054..e8a0c4e1 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/EventNotifierBridge.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/EventNotifierBridge.java @@ -5,7 +5,6 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; @@ -29,20 +28,18 @@ private EventNotifierBridge() { /// `rocksdb_eventlistener_t* rocksdb_eventlistener_create(void* state_, void (*destructor_)(void*), on_flush_begin_cb on_flush_begin, on_flush_completed_cb on_flush_completed, on_compaction_begin_cb on_compaction_begin, on_compaction_completed_cb on_compaction_completed, on_subcompaction_begin_cb on_subcompaction_begin, on_subcompaction_completed_cb on_subcompaction_completed, on_external_file_ingested_cb on_external_file_ingested, on_background_error_cb on_background_error, on_stall_conditions_changed_cb on_stall_conditions_changed, on_memtable_sealed_cb on_memtable_sealed);` private static final MethodHandle MH_EVENTLISTENER_CREATE = NativeLibrary.downcall( - "rocksdb_eventlistener_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_eventlistener_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_add_eventlistener(rocksdb_options_t*, rocksdb_eventlistener_t*);` private static final MethodHandle MH_OPTIONS_ADD_EVENTLISTENER = NativeLibrary.downcall( - "rocksdb_options_add_eventlistener", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_options_add_eventlistener", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_status_ptr_get_error(rocksdb_status_ptr_t* status, char** errptr);` private static final MethodHandle MH_STATUS_PTR_GET_ERROR = NativeLibrary.downcall( - "rocksdb_status_ptr_get_error", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_status_ptr_get_error", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private static final FunctionDescriptor DB_SCOPED_INFO_DESC = FunctionDescriptor.ofVoid( ValueLayout.ADDRESS, // state @@ -66,19 +63,39 @@ private EventNotifierBridge() { // One global upcall stub per callback, shared by every attached EventNotifier. Live for the // JVM lifetime so the function pointers stay valid; dispatch is keyed off the `state` pointer, // which carries a registry id rather than real memory (same trick as Logger/MergeOperator.Custom). - private static final MemorySegment FLUSH_BEGIN_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "flushBeginDispatch", DB_SCOPED_INFO_DESC); - private static final MemorySegment FLUSH_COMPLETED_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "flushCompletedDispatch", DB_SCOPED_INFO_DESC); - private static final MemorySegment COMPACTION_BEGIN_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "compactionBeginDispatch", DB_SCOPED_INFO_DESC); - private static final MemorySegment COMPACTION_COMPLETED_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "compactionCompletedDispatch", DB_SCOPED_INFO_DESC); + private static final MemorySegment FLUSH_BEGIN_STUB = NativeLibrary.upcall( + "flushBeginDispatch", DB_SCOPED_INFO_DESC + ); + private static final MemorySegment FLUSH_COMPLETED_STUB = NativeLibrary.upcall( + "flushCompletedDispatch", DB_SCOPED_INFO_DESC + ); + private static final MemorySegment COMPACTION_BEGIN_STUB = NativeLibrary.upcall( + "compactionBeginDispatch", DB_SCOPED_INFO_DESC + ); + private static final MemorySegment COMPACTION_COMPLETED_STUB = NativeLibrary.upcall( + "compactionCompletedDispatch", DB_SCOPED_INFO_DESC + ); // RocksDB's C struct calls on_subcompaction_begin/on_subcompaction_completed unconditionally // (db/c.cc has no null check), so both slots still need a valid function pointer even though // EventNotifier does not expose subcompaction callbacks; one shared no-op stub covers both. - private static final MemorySegment SUBCOMPACTION_NOOP_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "subcompactionNoopDispatch", INFO_ONLY_DESC); - private static final MemorySegment EXTERNAL_FILE_INGESTED_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "externalFileIngestedDispatch", DB_SCOPED_INFO_DESC); - private static final MemorySegment BACKGROUND_ERROR_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "backgroundErrorDispatch", BACKGROUND_ERROR_DESC); - private static final MemorySegment STALL_CONDITIONS_CHANGED_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "stallConditionsChangedDispatch", INFO_ONLY_DESC); - private static final MemorySegment MEMTABLE_SEALED_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "memTableSealedDispatch", INFO_ONLY_DESC); - private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "destructorDispatch", DESTRUCTOR_DESC); + private static final MemorySegment SUBCOMPACTION_NOOP_STUB = NativeLibrary.upcall( + "subcompactionNoopDispatch", INFO_ONLY_DESC + ); + private static final MemorySegment EXTERNAL_FILE_INGESTED_STUB = NativeLibrary.upcall( + "externalFileIngestedDispatch", DB_SCOPED_INFO_DESC + ); + private static final MemorySegment BACKGROUND_ERROR_STUB = NativeLibrary.upcall( + "backgroundErrorDispatch", BACKGROUND_ERROR_DESC + ); + private static final MemorySegment STALL_CONDITIONS_CHANGED_STUB = NativeLibrary.upcall( + "stallConditionsChangedDispatch", INFO_ONLY_DESC + ); + private static final MemorySegment MEMTABLE_SEALED_STUB = NativeLibrary.upcall( + "memTableSealedDispatch", INFO_ONLY_DESC + ); + private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall( + "destructorDispatch", DESTRUCTOR_DESC + ); private static final UpcallRegistry REGISTRY = new UpcallRegistry<>(); private static final System.Logger LOG = System.getLogger(EventNotifierBridge.class.getName()); @@ -106,47 +123,56 @@ static void attach(MemorySegment optionsPtr, EventNotifier notifier) { } /// Called from [#FLUSH_BEGIN_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void flushBeginDispatch(MemorySegment state, MemorySegment db, MemorySegment info) { dispatchView(state, info, FlushJobInfo::new, EventNotifier::onFlushBegin, "onFlushBegin"); } /// Called from [#FLUSH_COMPLETED_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void flushCompletedDispatch(MemorySegment state, MemorySegment db, MemorySegment info) { dispatchView(state, info, FlushJobInfo::new, EventNotifier::onFlushCompleted, "onFlushCompleted"); } /// Called from [#COMPACTION_BEGIN_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void compactionBeginDispatch(MemorySegment state, MemorySegment db, MemorySegment info) { dispatchView(state, info, CompactionJobInfo::new, EventNotifier::onCompactionBegin, "onCompactionBegin"); } /// Called from [#COMPACTION_COMPLETED_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void compactionCompletedDispatch(MemorySegment state, MemorySegment db, MemorySegment info) { dispatchView(state, info, CompactionJobInfo::new, EventNotifier::onCompactionCompleted, "onCompactionCompleted"); } /// Called from [#SUBCOMPACTION_NOOP_STUB]. Deliberately does nothing: subcompaction events are /// not exposed on [EventNotifier]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void subcompactionNoopDispatch(MemorySegment state, MemorySegment info) { // intentionally empty: db/c.cc invokes this callback without a null check } /// Called from [#EXTERNAL_FILE_INGESTED_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void externalFileIngestedDispatch(MemorySegment state, MemorySegment db, MemorySegment info) { dispatchView(state, info, ExternalFileIngestionInfo::new, EventNotifier::onExternalFileIngested, "onExternalFileIngested"); } /// Called from [#STALL_CONDITIONS_CHANGED_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void stallConditionsChangedDispatch(MemorySegment state, MemorySegment info) { dispatchView(state, info, WriteStallInfo::new, EventNotifier::onStallConditionsChanged, "onStallConditionsChanged"); } /// Called from [#MEMTABLE_SEALED_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void memTableSealedDispatch(MemorySegment state, MemorySegment info) { dispatchView(state, info, MemTableInfo::new, EventNotifier::onMemTableSealed, "onMemTableSealed"); } /// Called from [#BACKGROUND_ERROR_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void backgroundErrorDispatch(MemorySegment state, int reason, MemorySegment statusPtr) { dispatch(state, n -> { try (Arena arena = Arena.ofConfined()) { @@ -170,6 +196,7 @@ private static void backgroundErrorDispatch(MemorySegment state, int reason, Mem /// Called from [#DESTRUCTOR_STUB] when RocksDB's internal `shared_ptr` refcount hits zero. /// This is the only reliable unregistration point, since [#attach(MemorySegment, EventNotifier)] /// transfers ownership immediately. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void destructorDispatch(MemorySegment state) { REGISTRY.unregister(state); } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/ExternalFileIngestionInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/ExternalFileIngestionInfo.java index f4bd75c8..34630bf8 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/ExternalFileIngestionInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/ExternalFileIngestionInfo.java @@ -17,23 +17,23 @@ public final class ExternalFileIngestionInfo { /// `const char* rocksdb_externalfileingestioninfo_cf_name(const rocksdb_externalfileingestioninfo_t*, size_t* size);` private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( - "rocksdb_externalfileingestioninfo_cf_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_externalfileingestioninfo_cf_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_externalfileingestioninfo_external_file_path(const rocksdb_externalfileingestioninfo_t*, size_t* size);` private static final MethodHandle MH_EXTERNAL_FILE_PATH = NativeLibrary.downcall( - "rocksdb_externalfileingestioninfo_external_file_path", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_externalfileingestioninfo_external_file_path", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_externalfileingestioninfo_internal_file_path(const rocksdb_externalfileingestioninfo_t*, size_t* size);` private static final MethodHandle MH_INTERNAL_FILE_PATH = NativeLibrary.downcall( - "rocksdb_externalfileingestioninfo_internal_file_path", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_externalfileingestioninfo_internal_file_path", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_externalfileingestioninfo_global_seqno(const rocksdb_externalfileingestioninfo_t*);` private static final MethodHandle MH_GLOBAL_SEQNO = NativeLibrary.downcall( - "rocksdb_externalfileingestioninfo_global_seqno", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_externalfileingestioninfo_global_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/FifoCompactionOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/FifoCompactionOptions.java index 67522107..360171ef 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/FifoCompactionOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/FifoCompactionOptions.java @@ -25,63 +25,45 @@ public final class FifoCompactionOptions extends NativeObject { /// `rocksdb_fifo_compaction_options_t* rocksdb_fifo_compaction_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_fifo_compaction_options_destroy(rocksdb_fifo_compaction_options_t* fifo_opts);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_fifo_compaction_options_set_allow_compaction(rocksdb_fifo_compaction_options_t* fifo_opts, unsigned char allow_compaction);` - private static final MethodHandle MH_SET_ALLOW_COMPACTION; + private static final MethodHandle MH_SET_ALLOW_COMPACTION = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_set_allow_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_fifo_compaction_options_get_allow_compaction(rocksdb_fifo_compaction_options_t* fifo_opts);` - private static final MethodHandle MH_GET_ALLOW_COMPACTION; + private static final MethodHandle MH_GET_ALLOW_COMPACTION = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_get_allow_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_fifo_compaction_options_set_max_table_files_size(rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size);` - private static final MethodHandle MH_SET_MAX_TABLE_FILES_SIZE; + private static final MethodHandle MH_SET_MAX_TABLE_FILES_SIZE = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_set_max_table_files_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_fifo_compaction_options_get_max_table_files_size(rocksdb_fifo_compaction_options_t* fifo_opts);` - private static final MethodHandle MH_GET_MAX_TABLE_FILES_SIZE; + private static final MethodHandle MH_GET_MAX_TABLE_FILES_SIZE = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_get_max_table_files_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_fifo_compaction_options_set_max_data_files_size(rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size);` - private static final MethodHandle MH_SET_MAX_DATA_FILES_SIZE; + private static final MethodHandle MH_SET_MAX_DATA_FILES_SIZE = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_set_max_data_files_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_fifo_compaction_options_get_max_data_files_size(rocksdb_fifo_compaction_options_t* fifo_opts);` - private static final MethodHandle MH_GET_MAX_DATA_FILES_SIZE; + private static final MethodHandle MH_GET_MAX_DATA_FILES_SIZE = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_get_max_data_files_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_fifo_compaction_options_set_use_kv_ratio_compaction(rocksdb_fifo_compaction_options_t* fifo_opts, unsigned char use_kv_ratio_compaction);` - private static final MethodHandle MH_SET_USE_KV_RATIO_COMPACTION; + private static final MethodHandle MH_SET_USE_KV_RATIO_COMPACTION = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_set_use_kv_ratio_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_fifo_compaction_options_get_use_kv_ratio_compaction(rocksdb_fifo_compaction_options_t* fifo_opts);` - private static final MethodHandle MH_GET_USE_KV_RATIO_COMPACTION; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_fifo_compaction_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_fifo_compaction_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_ALLOW_COMPACTION = NativeLibrary.downcall("rocksdb_fifo_compaction_options_set_allow_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ALLOW_COMPACTION = NativeLibrary.downcall("rocksdb_fifo_compaction_options_get_allow_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_MAX_TABLE_FILES_SIZE = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_set_max_table_files_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_TABLE_FILES_SIZE = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_get_max_table_files_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_DATA_FILES_SIZE = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_set_max_data_files_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_DATA_FILES_SIZE = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_get_max_data_files_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_USE_KV_RATIO_COMPACTION = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_set_use_kv_ratio_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_KV_RATIO_COMPACTION = NativeLibrary.downcall( - "rocksdb_fifo_compaction_options_get_use_kv_ratio_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_USE_KV_RATIO_COMPACTION = NativeLibrary.downcall( + "rocksdb_fifo_compaction_options_get_use_kv_ratio_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private FifoCompactionOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/FileChecksumGenFactory.java b/core/src/main/java/io/github/dfa1/rocksdbffm/FileChecksumGenFactory.java index e38182da..a552a7a7 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/FileChecksumGenFactory.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/FileChecksumGenFactory.java @@ -13,33 +13,33 @@ /// so both objects may be closed independently. public final class FileChecksumGenFactory extends NativeObject { - /// `rocksdb_file_checksum_gen_factory_t* rocksdb_file_checksum_gen_crc32c_factory_create(void);` - private static final MethodHandle MH_CREATE = NativeLibrary.downcall( - "rocksdb_file_checksum_gen_crc32c_factory_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - /// `void rocksdb_file_checksum_gen_factory_destroy(rocksdb_file_checksum_gen_factory_t* factory);` - private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( - "rocksdb_file_checksum_gen_factory_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - private FileChecksumGenFactory(MemorySegment ptr) { - super(ptr); - } - - /// Creates a factory that generates CRC32C file checksums. - /// - /// @return a new factory; the caller must close it when finished - public static FileChecksumGenFactory newCrc32cFactory() { - try { - return new FileChecksumGenFactory((MemorySegment) MH_CREATE.invokeExact()); - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("FileChecksumGenFactory.newCrc32cFactory failed", t); - } - } - - @Override - protected void tryClose(MemorySegment ptr) throws Throwable { - MH_DESTROY.invokeExact(ptr); - } + /// `rocksdb_file_checksum_gen_factory_t* rocksdb_file_checksum_gen_crc32c_factory_create(void);` + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_file_checksum_gen_crc32c_factory_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); + + /// `void rocksdb_file_checksum_gen_factory_destroy(rocksdb_file_checksum_gen_factory_t* factory);` + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_file_checksum_gen_factory_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); + + private FileChecksumGenFactory(MemorySegment ptr) { + super(ptr); + } + + /// Creates a factory that generates CRC32C file checksums. + /// + /// @return a new factory; the caller must close it when finished + public static FileChecksumGenFactory newCrc32cFactory() { + try { + return new FileChecksumGenFactory((MemorySegment) MH_CREATE.invokeExact()); + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("FileChecksumGenFactory.newCrc32cFactory failed", t); + } + } + + @Override + protected void tryClose(MemorySegment ptr) throws Throwable { + MH_DESTROY.invokeExact(ptr); + } } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/FilterPolicy.java b/core/src/main/java/io/github/dfa1/rocksdbffm/FilterPolicy.java index 080f72b2..ede5e613 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/FilterPolicy.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/FilterPolicy.java @@ -23,27 +23,21 @@ public final class FilterPolicy extends NativeObject { /// `rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_bloom(double bits_per_key);` - private static final MethodHandle MH_CREATE_BLOOM; + private static final MethodHandle MH_CREATE_BLOOM = NativeLibrary.downcall( + "rocksdb_filterpolicy_create_bloom", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_ribbon(double bloom_equivalent_bits_per_key);` - private static final MethodHandle MH_CREATE_RIBBON; + private static final MethodHandle MH_CREATE_RIBBON = NativeLibrary.downcall( + "rocksdb_filterpolicy_create_ribbon", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `rocksdb_filterpolicy_t* rocksdb_filterpolicy_create_ribbon_hybrid(double bloom_equivalent_bits_per_key, int bloom_before_level);` - private static final MethodHandle MH_CREATE_RIBBON_HYBRID; + private static final MethodHandle MH_CREATE_RIBBON_HYBRID = NativeLibrary.downcall( + "rocksdb_filterpolicy_create_ribbon_hybrid", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE, ValueLayout.JAVA_INT) + ); /// `void rocksdb_filterpolicy_destroy(rocksdb_filterpolicy_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE_BLOOM = NativeLibrary.downcall("rocksdb_filterpolicy_create_bloom", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_CREATE_RIBBON = NativeLibrary.downcall("rocksdb_filterpolicy_create_ribbon", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_CREATE_RIBBON_HYBRID = NativeLibrary.downcall("rocksdb_filterpolicy_create_ribbon_hybrid", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE, ValueLayout.JAVA_INT)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_filterpolicy_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_filterpolicy_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private FilterPolicy(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/FlushJobInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/FlushJobInfo.java index d1fd6c62..0395f76a 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/FlushJobInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/FlushJobInfo.java @@ -17,61 +17,68 @@ public final class FlushJobInfo { /// `uint32_t rocksdb_flushjobinfo_cf_id(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_CF_ID = NativeLibrary.downcall( - "rocksdb_flushjobinfo_cf_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_cf_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_flushjobinfo_cf_name(const rocksdb_flushjobinfo_t*, size_t* size);` private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( - "rocksdb_flushjobinfo_cf_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_cf_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_flushjobinfo_file_path(const rocksdb_flushjobinfo_t*, size_t* size);` private static final MethodHandle MH_FILE_PATH = NativeLibrary.downcall( - "rocksdb_flushjobinfo_file_path", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_file_path", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_flushjobinfo_file_number(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_FILE_NUMBER = NativeLibrary.downcall( - "rocksdb_flushjobinfo_file_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_file_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_flushjobinfo_oldest_blob_file_number(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_OLDEST_BLOB_FILE_NUMBER = NativeLibrary.downcall( - "rocksdb_flushjobinfo_oldest_blob_file_number", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_oldest_blob_file_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_flushjobinfo_thread_id(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_THREAD_ID = NativeLibrary.downcall( - "rocksdb_flushjobinfo_thread_id", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_thread_id", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `int rocksdb_flushjobinfo_job_id(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_JOB_ID = NativeLibrary.downcall( - "rocksdb_flushjobinfo_job_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_job_id", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_flushjobinfo_triggered_writes_slowdown(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_TRIGGERED_WRITES_SLOWDOWN = NativeLibrary.downcall( - "rocksdb_flushjobinfo_triggered_writes_slowdown", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_triggered_writes_slowdown", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_flushjobinfo_triggered_writes_stop(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_TRIGGERED_WRITES_STOP = NativeLibrary.downcall( - "rocksdb_flushjobinfo_triggered_writes_stop", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_triggered_writes_stop", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_flushjobinfo_smallest_seqno(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_SMALLEST_SEQNO = NativeLibrary.downcall( - "rocksdb_flushjobinfo_smallest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_smallest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_flushjobinfo_largest_seqno(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_LARGEST_SEQNO = NativeLibrary.downcall( - "rocksdb_flushjobinfo_largest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_largest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_flushjobinfo_flush_reason(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_FLUSH_REASON = NativeLibrary.downcall( - "rocksdb_flushjobinfo_flush_reason", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_flush_reason", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `uint32_t rocksdb_flushjobinfo_blob_compression_type(const rocksdb_flushjobinfo_t*);` private static final MethodHandle MH_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall( - "rocksdb_flushjobinfo_blob_compression_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); + "rocksdb_flushjobinfo_blob_compression_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/FlushOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/FlushOptions.java index 5837c7a3..a117e9f4 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/FlushOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/FlushOptions.java @@ -18,27 +18,21 @@ public final class FlushOptions extends NativeObject { /// `rocksdb_flushoptions_t* rocksdb_flushoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_flushoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_flushoptions_destroy(rocksdb_flushoptions_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_flushoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_flushoptions_set_wait(rocksdb_flushoptions_t*, unsigned char);` - private static final MethodHandle MH_SET_WAIT; + private static final MethodHandle MH_SET_WAIT = NativeLibrary.downcall( + "rocksdb_flushoptions_set_wait", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_flushoptions_get_wait(rocksdb_flushoptions_t*);` - private static final MethodHandle MH_GET_WAIT; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_flushoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_flushoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_WAIT = NativeLibrary.downcall("rocksdb_flushoptions_set_wait", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_WAIT = NativeLibrary.downcall("rocksdb_flushoptions_get_wait", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_WAIT = NativeLibrary.downcall( + "rocksdb_flushoptions_get_wait", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private FlushOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/HyperClockCache.java b/core/src/main/java/io/github/dfa1/rocksdbffm/HyperClockCache.java index b9a1a036..8aef51ed 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/HyperClockCache.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/HyperClockCache.java @@ -22,37 +22,25 @@ public final class HyperClockCache extends Cache { /// `rocksdb_hyper_clock_cache_options_t* rocksdb_hyper_clock_cache_options_create(size_t capacity, size_t estimated_entry_charge);` - private static final MethodHandle MH_OPTS_CREATE; + private static final MethodHandle MH_OPTS_CREATE = NativeLibrary.downcall( + "rocksdb_hyper_clock_cache_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, NativeCalls.SIZE_T) + ); /// `void rocksdb_hyper_clock_cache_options_destroy(rocksdb_hyper_clock_cache_options_t*);` - private static final MethodHandle MH_OPTS_DESTROY; + private static final MethodHandle MH_OPTS_DESTROY = NativeLibrary.downcall( + "rocksdb_hyper_clock_cache_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_hyper_clock_cache_options_set_num_shard_bits(rocksdb_hyper_clock_cache_options_t*, int);` - private static final MethodHandle MH_OPTS_SET_NUM_SHARD_BITS; + private static final MethodHandle MH_OPTS_SET_NUM_SHARD_BITS = NativeLibrary.downcall( + "rocksdb_hyper_clock_cache_options_set_num_shard_bits", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `rocksdb_cache_t* rocksdb_cache_create_hyper_clock(size_t capacity, size_t estimated_entry_charge);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_cache_create_hyper_clock", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, NativeCalls.SIZE_T) + ); /// `rocksdb_cache_t* rocksdb_cache_create_hyper_clock_opts(const rocksdb_hyper_clock_cache_options_t*);` - private static final MethodHandle MH_CREATE_OPTS; - - static { - MH_OPTS_CREATE = NativeLibrary.downcall("rocksdb_hyper_clock_cache_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - NativeCalls.SIZE_T)); - - MH_OPTS_DESTROY = NativeLibrary.downcall("rocksdb_hyper_clock_cache_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_OPTS_SET_NUM_SHARD_BITS = NativeLibrary.downcall( - "rocksdb_hyper_clock_cache_options_set_num_shard_bits", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_CREATE = NativeLibrary.downcall("rocksdb_cache_create_hyper_clock", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - NativeCalls.SIZE_T)); - - MH_CREATE_OPTS = NativeLibrary.downcall("rocksdb_cache_create_hyper_clock_opts", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CREATE_OPTS = NativeLibrary.downcall( + "rocksdb_cache_create_hyper_clock_opts", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private HyperClockCache(MemorySegment ptr) { super(ptr); @@ -60,8 +48,8 @@ private HyperClockCache(MemorySegment ptr) { /// Creates a HyperClockCache. /// - /// @param capacity total cache capacity - /// @param estimatedEntryCharge expected average size of a cached block; use + /// @param capacity total cache capacity + /// @param estimatedEntryCharge expected average size of a cached block; use /// [MemorySize#ZERO] to let RocksDB choose /// @return a new [HyperClockCache]; caller must close it public static HyperClockCache newHyperClockCache( @@ -76,10 +64,10 @@ public static HyperClockCache newHyperClockCache( /// Creates a HyperClockCache with an explicit shard count. /// - /// @param capacity total cache capacity - /// @param estimatedEntryCharge expected average size of a cached block; use + /// @param capacity total cache capacity + /// @param estimatedEntryCharge expected average size of a cached block; use /// [MemorySize#ZERO] to let RocksDB choose - /// @param numShardBits number of shard bits (`shards = 1 << numShardBits`); + /// @param numShardBits number of shard bits (`shards = 1 << numShardBits`); /// pass `-1` to let RocksDB choose automatically /// @return a new [HyperClockCache]; caller must close it public static HyperClockCache newHyperClockCache( diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/IngestExternalFileOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/IngestExternalFileOptions.java index 5539900b..b2cfd76e 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/IngestExternalFileOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/IngestExternalFileOptions.java @@ -17,48 +17,37 @@ public final class IngestExternalFileOptions extends NativeObject { /// `rocksdb_ingestexternalfileoptions_t* rocksdb_ingestexternalfileoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_ingestexternalfileoptions_destroy(rocksdb_ingestexternalfileoptions_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_ingestexternalfileoptions_set_move_files(rocksdb_ingestexternalfileoptions_t* opt, unsigned char move_files);` - private static final MethodHandle MH_SET_MOVE_FILES; + private static final MethodHandle MH_SET_MOVE_FILES = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_move_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ingestexternalfileoptions_set_snapshot_consistency(rocksdb_ingestexternalfileoptions_t* opt, unsigned char snapshot_consistency);` - private static final MethodHandle MH_SET_SNAPSHOT_CONSISTENCY; + private static final MethodHandle MH_SET_SNAPSHOT_CONSISTENCY = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_snapshot_consistency", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ingestexternalfileoptions_set_allow_global_seqno(rocksdb_ingestexternalfileoptions_t* opt, unsigned char allow_global_seqno);` - private static final MethodHandle MH_SET_ALLOW_GLOBAL_SEQNO; + private static final MethodHandle MH_SET_ALLOW_GLOBAL_SEQNO = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_allow_global_seqno", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ingestexternalfileoptions_set_allow_blocking_flush(rocksdb_ingestexternalfileoptions_t* opt, unsigned char allow_blocking_flush);` - private static final MethodHandle MH_SET_ALLOW_BLOCKING_FLUSH; + private static final MethodHandle MH_SET_ALLOW_BLOCKING_FLUSH = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_allow_blocking_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ingestexternalfileoptions_set_ingest_behind(rocksdb_ingestexternalfileoptions_t* opt, unsigned char ingest_behind);` - private static final MethodHandle MH_SET_INGEST_BEHIND; + private static final MethodHandle MH_SET_INGEST_BEHIND = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_ingest_behind", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level(rocksdb_ingestexternalfileoptions_t* opt, unsigned char fail_if_not_bottommost_level);` - private static final MethodHandle MH_SET_FAIL_IF_NOT_BOTTOMMOST_LEVEL; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_MOVE_FILES = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_set_move_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_SNAPSHOT_CONSISTENCY = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_set_snapshot_consistency", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_ALLOW_GLOBAL_SEQNO = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_set_allow_global_seqno", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_ALLOW_BLOCKING_FLUSH = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_set_allow_blocking_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_INGEST_BEHIND = NativeLibrary.downcall("rocksdb_ingestexternalfileoptions_set_ingest_behind", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_SET_FAIL_IF_NOT_BOTTOMMOST_LEVEL = NativeLibrary.downcall( - "rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - } + private static final MethodHandle MH_SET_FAIL_IF_NOT_BOTTOMMOST_LEVEL = NativeLibrary.downcall( + "rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// Default options for [RocksDBWriteOperations#ingestExternalFile(java.util.List)]; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LRUCache.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LRUCache.java index 7421d080..29e1cf81 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LRUCache.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LRUCache.java @@ -16,42 +16,33 @@ public final class LRUCache extends Cache { /// `rocksdb_cache_t* rocksdb_cache_create_lru(size_t capacity);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_cache_create_lru", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `rocksdb_cache_t* rocksdb_cache_create_lru_with_strict_capacity_limit(size_t capacity);` - private static final MethodHandle MH_CREATE_STRICT; + private static final MethodHandle MH_CREATE_STRICT = NativeLibrary.downcall( + "rocksdb_cache_create_lru_with_strict_capacity_limit", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `rocksdb_lru_cache_options_t* rocksdb_lru_cache_options_create(void);` - private static final MethodHandle MH_OPTS_CREATE; + private static final MethodHandle MH_OPTS_CREATE = NativeLibrary.downcall( + "rocksdb_lru_cache_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_lru_cache_options_destroy(rocksdb_lru_cache_options_t*);` - private static final MethodHandle MH_OPTS_DESTROY; + private static final MethodHandle MH_OPTS_DESTROY = NativeLibrary.downcall( + "rocksdb_lru_cache_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_lru_cache_options_set_capacity(rocksdb_lru_cache_options_t*, size_t);` - private static final MethodHandle MH_OPTS_SET_CAPACITY; + private static final MethodHandle MH_OPTS_SET_CAPACITY = NativeLibrary.downcall( + "rocksdb_lru_cache_options_set_capacity", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_lru_cache_options_set_num_shard_bits(rocksdb_lru_cache_options_t*, int);` - private static final MethodHandle MH_OPTS_SET_NUM_SHARD_BITS; + private static final MethodHandle MH_OPTS_SET_NUM_SHARD_BITS = NativeLibrary.downcall( + "rocksdb_lru_cache_options_set_num_shard_bits", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `rocksdb_cache_t* rocksdb_cache_create_lru_opts(const rocksdb_lru_cache_options_t*);` - private static final MethodHandle MH_CREATE_OPTS; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_cache_create_lru", - FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_CREATE_STRICT = NativeLibrary.downcall("rocksdb_cache_create_lru_with_strict_capacity_limit", - FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_OPTS_CREATE = NativeLibrary.downcall("rocksdb_lru_cache_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_OPTS_DESTROY = NativeLibrary.downcall("rocksdb_lru_cache_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_OPTS_SET_CAPACITY = NativeLibrary.downcall("rocksdb_lru_cache_options_set_capacity", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_OPTS_SET_NUM_SHARD_BITS = NativeLibrary.downcall("rocksdb_lru_cache_options_set_num_shard_bits", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_CREATE_OPTS = NativeLibrary.downcall("rocksdb_cache_create_lru_opts", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CREATE_OPTS = NativeLibrary.downcall( + "rocksdb_cache_create_lru_opts", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private LRUCache(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileInfo.java index 3959ad70..658b8cdb 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileInfo.java @@ -25,64 +25,49 @@ public final class LiveFileInfo { /// `const char* rocksdb_livefiles_column_family_name(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_CF_NAME; + private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( + "rocksdb_livefiles_column_family_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `const char* rocksdb_livefiles_name(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_NAME; + private static final MethodHandle MH_NAME = NativeLibrary.downcall( + "rocksdb_livefiles_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `const char* rocksdb_livefiles_directory(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_DIRECTORY; + private static final MethodHandle MH_DIRECTORY = NativeLibrary.downcall( + "rocksdb_livefiles_directory", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_livefiles_level(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_LEVEL; + private static final MethodHandle MH_LEVEL = NativeLibrary.downcall( + "rocksdb_livefiles_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `size_t rocksdb_livefiles_size(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_SIZE; + private static final MethodHandle MH_SIZE = NativeLibrary.downcall( + "rocksdb_livefiles_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `const char* rocksdb_livefiles_smallestkey(const rocksdb_livefiles_t*, int index, size_t* size);` - private static final MethodHandle MH_SMALLESTKEY; + private static final MethodHandle MH_SMALLESTKEY = NativeLibrary.downcall( + "rocksdb_livefiles_smallestkey", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_livefiles_largestkey(const rocksdb_livefiles_t*, int index, size_t* size);` - private static final MethodHandle MH_LARGESTKEY; + private static final MethodHandle MH_LARGESTKEY = NativeLibrary.downcall( + "rocksdb_livefiles_largestkey", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_livefiles_smallest_seqno(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_SMALLEST_SEQNO; + private static final MethodHandle MH_SMALLEST_SEQNO = NativeLibrary.downcall( + "rocksdb_livefiles_smallest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint64_t rocksdb_livefiles_largest_seqno(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_LARGEST_SEQNO; + private static final MethodHandle MH_LARGEST_SEQNO = NativeLibrary.downcall( + "rocksdb_livefiles_largest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint64_t rocksdb_livefiles_entries(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_ENTRIES; + private static final MethodHandle MH_ENTRIES = NativeLibrary.downcall( + "rocksdb_livefiles_entries", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint64_t rocksdb_livefiles_deletions(const rocksdb_livefiles_t*, int index);` - private static final MethodHandle MH_DELETIONS; - - static { - MH_CF_NAME = NativeLibrary.downcall("rocksdb_livefiles_column_family_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_NAME = NativeLibrary.downcall("rocksdb_livefiles_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_DIRECTORY = NativeLibrary.downcall("rocksdb_livefiles_directory", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_LEVEL = NativeLibrary.downcall("rocksdb_livefiles_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SIZE = NativeLibrary.downcall("rocksdb_livefiles_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SMALLESTKEY = NativeLibrary.downcall("rocksdb_livefiles_smallestkey", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_LARGESTKEY = NativeLibrary.downcall("rocksdb_livefiles_largestkey", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SMALLEST_SEQNO = NativeLibrary.downcall("rocksdb_livefiles_smallest_seqno", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_LARGEST_SEQNO = NativeLibrary.downcall("rocksdb_livefiles_largest_seqno", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_ENTRIES = NativeLibrary.downcall("rocksdb_livefiles_entries", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_DELETIONS = NativeLibrary.downcall("rocksdb_livefiles_deletions", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - } + private static final MethodHandle MH_DELETIONS = NativeLibrary.downcall( + "rocksdb_livefiles_deletions", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); private final LiveFiles owner; private final int index; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileStorageInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileStorageInfo.java index b049e467..2fcdf6be 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileStorageInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFileStorageInfo.java @@ -23,58 +23,45 @@ public final class LiveFileStorageInfo { private static final long CRC32C_LENGTH = 4; /// `const char* rocksdb_livefiles_storage_info_relative_filename(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_RELATIVE_FILENAME; + private static final MethodHandle MH_RELATIVE_FILENAME = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_relative_filename", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `const char* rocksdb_livefiles_storage_info_directory(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_DIRECTORY; + private static final MethodHandle MH_DIRECTORY = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_directory", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `uint64_t rocksdb_livefiles_storage_info_file_number(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_FILE_NUMBER; + private static final MethodHandle MH_FILE_NUMBER = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_file_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `int rocksdb_livefiles_storage_info_file_type(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_FILE_TYPE; + private static final MethodHandle MH_FILE_TYPE = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_file_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `uint64_t rocksdb_livefiles_storage_info_size(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_SIZE; + private static final MethodHandle MH_SIZE = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `int rocksdb_livefiles_storage_info_temperature(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_TEMPERATURE; + private static final MethodHandle MH_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `const char* rocksdb_livefiles_storage_info_file_checksum(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_FILE_CHECKSUM; + private static final MethodHandle MH_FILE_CHECKSUM = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_file_checksum", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `const char* rocksdb_livefiles_storage_info_file_checksum_func_name(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_FILE_CHECKSUM_FUNC_NAME; + private static final MethodHandle MH_FILE_CHECKSUM_FUNC_NAME = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_file_checksum_func_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `const char* rocksdb_livefiles_storage_info_replacement_contents(const rocksdb_livefiles_storage_info_t*, size_t index, size_t* size);` - private static final MethodHandle MH_REPLACEMENT_CONTENTS; + private static final MethodHandle MH_REPLACEMENT_CONTENTS = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_replacement_contents", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_livefiles_storage_info_trim_to_size(const rocksdb_livefiles_storage_info_t*, size_t index);` - private static final MethodHandle MH_TRIM_TO_SIZE; - - static { - MH_RELATIVE_FILENAME = NativeLibrary.downcall("rocksdb_livefiles_storage_info_relative_filename", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DIRECTORY = NativeLibrary.downcall("rocksdb_livefiles_storage_info_directory", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_FILE_NUMBER = NativeLibrary.downcall("rocksdb_livefiles_storage_info_file_number", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_FILE_TYPE = NativeLibrary.downcall("rocksdb_livefiles_storage_info_file_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SIZE = NativeLibrary.downcall("rocksdb_livefiles_storage_info_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_TEMPERATURE = NativeLibrary.downcall("rocksdb_livefiles_storage_info_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_FILE_CHECKSUM = NativeLibrary.downcall("rocksdb_livefiles_storage_info_file_checksum", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_FILE_CHECKSUM_FUNC_NAME = NativeLibrary.downcall("rocksdb_livefiles_storage_info_file_checksum_func_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_REPLACEMENT_CONTENTS = NativeLibrary.downcall("rocksdb_livefiles_storage_info_replacement_contents", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_TRIM_TO_SIZE = NativeLibrary.downcall("rocksdb_livefiles_storage_info_trim_to_size", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - } + private static final MethodHandle MH_TRIM_TO_SIZE = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_trim_to_size", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); private final LiveFilesStorageInfo owner; private final int index; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFiles.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFiles.java index 689de311..b5faf9c6 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFiles.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFiles.java @@ -40,22 +40,17 @@ public final class LiveFiles extends NativeObject implements Iterable { /// `const rocksdb_livefiles_t* rocksdb_livefiles(rocksdb_t* db);` - private static final MethodHandle MH_LIVEFILES; + private static final MethodHandle MH_LIVEFILES = NativeLibrary.downcall( + "rocksdb_livefiles", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `int rocksdb_livefiles_count(const rocksdb_livefiles_t*);` - private static final MethodHandle MH_COUNT; + private static final MethodHandle MH_COUNT = NativeLibrary.downcall( + "rocksdb_livefiles_count", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_destroy(const rocksdb_livefiles_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_LIVEFILES = NativeLibrary.downcall("rocksdb_livefiles", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_COUNT = NativeLibrary.downcall("rocksdb_livefiles_count", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_livefiles_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_livefiles_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); // Cached at fetch time so size()/get() keep working after close() instead of going through // ptr() (which would throw IllegalStateException) — not a performance optimization, since diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfo.java index 74a25b80..f12d79d9 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfo.java @@ -30,23 +30,17 @@ public final class LiveFilesStorageInfo extends NativeObject implements Iterable { /// `rocksdb_livefiles_storage_info_t* rocksdb_get_livefiles_storage_info(rocksdb_t* db, const rocksdb_livefiles_storage_info_options_t* options, char** errptr);` - private static final MethodHandle MH_GET; + private static final MethodHandle MH_GET = NativeLibrary.downcall( + "rocksdb_get_livefiles_storage_info", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_livefiles_storage_info_count(const rocksdb_livefiles_storage_info_t* info);` - private static final MethodHandle MH_COUNT; + private static final MethodHandle MH_COUNT = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_count", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_storage_info_destroy(rocksdb_livefiles_storage_info_t* info);` - private static final MethodHandle MH_DESTROY; - - static { - MH_GET = NativeLibrary.downcall("rocksdb_get_livefiles_storage_info", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_COUNT = NativeLibrary.downcall("rocksdb_livefiles_storage_info_count", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_livefiles_storage_info_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); // See LiveFiles.count for why this is cached rather than re-derived: size()/get() need to // keep working after close() without touching ptr(), not a performance concern. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfoOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfoOptions.java index c3d4f328..e4d5fa73 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfoOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/LiveFilesStorageInfoOptions.java @@ -16,53 +16,37 @@ public final class LiveFilesStorageInfoOptions extends NativeObject { /// `rocksdb_livefiles_storage_info_options_t* rocksdb_livefiles_storage_info_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_storage_info_options_destroy(rocksdb_livefiles_storage_info_options_t* options);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_storage_info_options_set_include_checksum_info(rocksdb_livefiles_storage_info_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_INCLUDE_CHECKSUM_INFO; + private static final MethodHandle MH_SET_INCLUDE_CHECKSUM_INFO = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_set_include_checksum_info", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_livefiles_storage_info_options_get_include_checksum_info(rocksdb_livefiles_storage_info_options_t* opt);` - private static final MethodHandle MH_GET_INCLUDE_CHECKSUM_INFO; + private static final MethodHandle MH_GET_INCLUDE_CHECKSUM_INFO = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_get_include_checksum_info", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_storage_info_options_set_wal_size_for_flush(rocksdb_livefiles_storage_info_options_t* opt, uint64_t v);` - private static final MethodHandle MH_SET_WAL_SIZE_FOR_FLUSH; + private static final MethodHandle MH_SET_WAL_SIZE_FOR_FLUSH = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_set_wal_size_for_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_livefiles_storage_info_options_get_wal_size_for_flush(rocksdb_livefiles_storage_info_options_t* opt);` - private static final MethodHandle MH_GET_WAL_SIZE_FOR_FLUSH; + private static final MethodHandle MH_GET_WAL_SIZE_FOR_FLUSH = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_get_wal_size_for_flush", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_livefiles_storage_info_options_set_atomic_flush(rocksdb_livefiles_storage_info_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ATOMIC_FLUSH; + private static final MethodHandle MH_SET_ATOMIC_FLUSH = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_set_atomic_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_livefiles_storage_info_options_get_atomic_flush(rocksdb_livefiles_storage_info_options_t* opt);` - private static final MethodHandle MH_GET_ATOMIC_FLUSH; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_livefiles_storage_info_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_livefiles_storage_info_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_INCLUDE_CHECKSUM_INFO = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_set_include_checksum_info", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_INCLUDE_CHECKSUM_INFO = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_get_include_checksum_info", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_WAL_SIZE_FOR_FLUSH = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_set_wal_size_for_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_WAL_SIZE_FOR_FLUSH = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_get_wal_size_for_flush", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_ATOMIC_FLUSH = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_set_atomic_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ATOMIC_FLUSH = NativeLibrary.downcall( - "rocksdb_livefiles_storage_info_options_get_atomic_flush", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_ATOMIC_FLUSH = NativeLibrary.downcall( + "rocksdb_livefiles_storage_info_options_get_atomic_flush", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private LiveFilesStorageInfoOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Logger.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Logger.java index 95829b94..6abe0ba3 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Logger.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Logger.java @@ -5,7 +5,6 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.nio.charset.StandardCharsets; /// FFM wrapper for `rocksdb_logger_t`. @@ -47,11 +46,17 @@ public interface LogCallback { private static final int STDERR_CALLBACK_ID = -1; /// `rocksdb_logger_t* rocksdb_logger_create_stderr_logger(int log_level, const char* prefix);` - private static final MethodHandle MH_CREATE_STDERR; + private static final MethodHandle MH_CREATE_STDERR = NativeLibrary.downcall( + "rocksdb_logger_create_stderr_logger", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `rocksdb_logger_t* rocksdb_logger_create_callback_logger(int log_level, void (*)(void* priv, unsigned lev, char* msg, size_t len), void* priv);` - private static final MethodHandle MH_CREATE_CALLBACK; + private static final MethodHandle MH_CREATE_CALLBACK = NativeLibrary.downcall( + "rocksdb_logger_create_callback_logger", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_logger_destroy(rocksdb_logger_t* logger);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_logger_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private static final FunctionDescriptor CALLBACK_DESC = FunctionDescriptor.ofVoid( ValueLayout.ADDRESS, // void* priv — carries the callback ID @@ -65,18 +70,9 @@ public interface LogCallback { // One global upcall stub shared by all callback loggers. // Lives for the JVM lifetime so the function pointer is always valid. - private static final MemorySegment GLOBAL_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "dispatch", CALLBACK_DESC); - - static { - MH_CREATE_STDERR = NativeLibrary.downcall("rocksdb_logger_create_stderr_logger", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_CREATE_CALLBACK = NativeLibrary.downcall("rocksdb_logger_create_callback_logger", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_logger_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MemorySegment GLOBAL_STUB = NativeLibrary.upcall( + "dispatch", CALLBACK_DESC + ); /// `-1` for stderr loggers; the registry key for callback loggers. private final long callbackId; @@ -133,6 +129,7 @@ protected void tryClose(MemorySegment ptr) throws Throwable { } /// Called from the single global upcall stub. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void dispatch(MemorySegment priv, int lev, MemorySegment msg, long len) { BackgroundUpcallThreads.track(); try { diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/MemTableInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/MemTableInfo.java index 9c0b8742..9c7a65d3 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/MemTableInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/MemTableInfo.java @@ -16,29 +16,33 @@ public final class MemTableInfo { /// `const char* rocksdb_memtableinfo_cf_name(const rocksdb_memtableinfo_t*, size_t* size);` private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( - "rocksdb_memtableinfo_cf_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_cf_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_memtableinfo_first_seqno(const rocksdb_memtableinfo_t*);` private static final MethodHandle MH_FIRST_SEQNO = NativeLibrary.downcall( - "rocksdb_memtableinfo_first_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_first_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_memtableinfo_earliest_seqno(const rocksdb_memtableinfo_t*);` private static final MethodHandle MH_EARLIEST_SEQNO = NativeLibrary.downcall( - "rocksdb_memtableinfo_earliest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_earliest_seqno", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_memtableinfo_num_entries(const rocksdb_memtableinfo_t*);` private static final MethodHandle MH_NUM_ENTRIES = NativeLibrary.downcall( - "rocksdb_memtableinfo_num_entries", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_num_entries", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_memtableinfo_num_deletes(const rocksdb_memtableinfo_t*);` private static final MethodHandle MH_NUM_DELETES = NativeLibrary.downcall( - "rocksdb_memtableinfo_num_deletes", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_num_deletes", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `const char* rocksdb_memtableinfo_newest_udt(const rocksdb_memtableinfo_t*, size_t* size);` private static final MethodHandle MH_NEWEST_UDT = NativeLibrary.downcall( - "rocksdb_memtableinfo_newest_udt", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_memtableinfo_newest_udt", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/MergeOperator.java b/core/src/main/java/io/github/dfa1/rocksdbffm/MergeOperator.java index 6f4f8098..bb1c4d08 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/MergeOperator.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/MergeOperator.java @@ -5,7 +5,6 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.ValueLayout; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.List; @@ -86,8 +85,8 @@ record Uint64Add() implements MergeOperator { /// `void rocksdb_options_set_uint64add_merge_operator(rocksdb_options_t*);` private static final MethodHandle MH_SET_UINT64ADD_MERGE_OPERATOR = NativeLibrary.downcall( - "rocksdb_options_set_uint64add_merge_operator", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + "rocksdb_options_set_uint64add_merge_operator", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); void applyTo(MemorySegment optionsPtr) { try { @@ -103,24 +102,25 @@ final class Custom extends NativeObject implements MergeOperator { /// `rocksdb_mergeoperator_t* rocksdb_mergeoperator_create(void* state, void (*destructor)(void*), char* (*full_merge)(void*, const char* key, size_t key_length, const char* existing_value, size_t existing_value_length, const char* const* operands_list, const size_t* operands_list_length, int num_operands, unsigned char* success, size_t* new_value_length), char* (*partial_merge)(void*, const char* key, size_t key_length, const char* const* operands_list, const size_t* operands_list_length, int num_operands, unsigned char* success, size_t* new_value_length), void (*delete_value)(void*, const char* value, size_t value_length), const char* (*name)(void*));` private static final MethodHandle MH_MERGEOPERATOR_CREATE = NativeLibrary.downcall( - "rocksdb_mergeoperator_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // state - ValueLayout.ADDRESS, // destructor - ValueLayout.ADDRESS, // full_merge - ValueLayout.ADDRESS, // partial_merge - ValueLayout.ADDRESS, // delete_value - ValueLayout.ADDRESS)); // name + "rocksdb_mergeoperator_create", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // state + ValueLayout.ADDRESS, // destructor + ValueLayout.ADDRESS, // full_merge + ValueLayout.ADDRESS, // partial_merge + ValueLayout.ADDRESS, // delete_value + ValueLayout.ADDRESS) // name + ); /// `void rocksdb_mergeoperator_destroy(rocksdb_mergeoperator_t*);` private static final MethodHandle MH_MERGEOPERATOR_DESTROY = NativeLibrary.downcall( - "rocksdb_mergeoperator_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + "rocksdb_mergeoperator_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_merge_operator(rocksdb_options_t*, rocksdb_mergeoperator_t*);` private static final MethodHandle MH_SET_MERGE_OPERATOR = NativeLibrary.downcall( - "rocksdb_options_set_merge_operator", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_options_set_merge_operator", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private static final FunctionDescriptor FULL_MERGE_DESC = FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, // state @@ -156,11 +156,21 @@ final class Custom extends NativeObject implements MergeOperator { // One global upcall stub per callback shape, shared by every Custom instance. Lives for the // JVM lifetime so the function pointers are always valid; dispatch is keyed off the `state` // pointer, which carries a registry ID rather than real memory (same trick as Logger). - private static final MemorySegment FULL_MERGE_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "fullMergeDispatch", FULL_MERGE_DESC); - private static final MemorySegment PARTIAL_MERGE_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "partialMergeDispatch", PARTIAL_MERGE_DESC); - private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "destructorDispatch", DESTRUCTOR_DESC); - private static final MemorySegment NAME_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "nameDispatch", NAME_DESC); - private static final MemorySegment DELETE_VALUE_STUB = NativeLibrary.upcall(MethodHandles.lookup(), "deleteValueDispatch", DELETE_VALUE_DESC); + private static final MemorySegment FULL_MERGE_STUB = NativeLibrary.upcall( + "fullMergeDispatch", FULL_MERGE_DESC + ); + private static final MemorySegment PARTIAL_MERGE_STUB = NativeLibrary.upcall( + "partialMergeDispatch", PARTIAL_MERGE_DESC + ); + private static final MemorySegment DESTRUCTOR_STUB = NativeLibrary.upcall( + "destructorDispatch", DESTRUCTOR_DESC + ); + private static final MemorySegment NAME_STUB = NativeLibrary.upcall( + "nameDispatch", NAME_DESC + ); + private static final MemorySegment DELETE_VALUE_STUB = NativeLibrary.upcall( + "deleteValueDispatch", DELETE_VALUE_DESC + ); /// Per-thread buffer every merge result is returned in, grown as needed. Safe to reuse: `db/c.cc` copies the /// result out (`assign`) before the calling thread can merge again, and [#deleteValueDispatch] keeps RocksDB @@ -270,6 +280,7 @@ private static List readOperandViews(MemorySegment operandsList, } /// Called from [#FULL_MERGE_STUB]. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment fullMergeDispatch(MemorySegment state, MemorySegment key, long keyLen, MemorySegment existingValue, long existingValueLen, MemorySegment operandsList, MemorySegment operandsLen, int numOperands, MemorySegment success, MemorySegment newValueLen) { @@ -297,6 +308,7 @@ private static MemorySegment fullMergeDispatch(MemorySegment state, MemorySegmen /// Called from [#PARTIAL_MERGE_STUB]. Always declines: RocksDB then keeps accumulating /// operands and calls [#fullMergeDispatch] later instead. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment partialMergeDispatch(MemorySegment state, MemorySegment key, long keyLen, MemorySegment operandsList, MemorySegment operandsLen, int numOperands, MemorySegment success, MemorySegment newValueLen) { @@ -317,6 +329,7 @@ private static MemorySegment partialMergeDispatch(MemorySegment state, MemorySeg /// Called from [#DESTRUCTOR_STUB] when RocksDB's internal `shared_ptr` refcount hits zero. /// This is the only reliable unregistration point: ownership transfer via [#applyTo] means /// [#tryClose(MemorySegment)] may never run for this instance. Must not throw. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void destructorDispatch(MemorySegment state) { REGISTRY.unregister(state); } @@ -324,6 +337,7 @@ private static void destructorDispatch(MemorySegment state) { /// Called from [#DELETE_VALUE_STUB] once RocksDB has copied a merge result out. Deliberately a no-op: /// every result is [#SCRATCH] or [#EMPTY], both owned on the Java side; its mere presence stops `db/c.cc` /// from calling `free()` on them instead. + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static void deleteValueDispatch(MemorySegment state, MemorySegment value, long valueLength) { // nothing to release } @@ -337,6 +351,7 @@ private static void deleteValueDispatch(MemorySegment state, MemorySegment value /// Called from [#NAME_STUB]. Must not throw, and must never return a value that isn't /// a valid NUL-terminated native string (see [#EMPTY]). + @SuppressWarnings("unused") // only reached by name, from NativeLibrary.upcall private static MemorySegment nameDispatch(MemorySegment state) { try { State s = REGISTRY.get(state); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeCalls.java b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeCalls.java index 8c4c0b40..5327c34f 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeCalls.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeCalls.java @@ -25,7 +25,9 @@ final class NativeCalls { static final ValueLayout.OfLong SIZE_T = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("size_t"); /// `void rocksdb_free(void* ptr);` - private static final MethodHandle MH_FREE = NativeLibrary.downcall("rocksdb_free", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + private static final MethodHandle MH_FREE = NativeLibrary.downcall( + "rocksdb_free", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private NativeCalls() { } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeDB.java index 593c4489..9a40172c 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeDB.java @@ -26,7 +26,9 @@ abstract class NativeDB extends NativeObjectWithChildren { /// `void rocksdb_close(rocksdb_t* db);` - private static final MethodHandle MH_CLOSE = NativeLibrary.downcall("rocksdb_close", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); + private static final MethodHandle MH_CLOSE = NativeLibrary.downcall( + "rocksdb_close", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// In open order, then creation order. An immutable snapshot replaced wholesale on every change /// (copy-on-write): lookups are lock-free, and changes happen only on open, create and drop. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeLibrary.java b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeLibrary.java index eb5f3bdd..6749c936 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/NativeLibrary.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/NativeLibrary.java @@ -31,33 +31,34 @@ public class NativeLibrary { private static final Linker LINKER = Linker.nativeLinker(); private static final SymbolLookup LIB = SymbolLookup.libraryLookup(resolveLibPath(), Arena.ofAuto()); - /// Creates a downcall handle for the symbol `name` of the bundled `librocksdb`, the only library this project binds - /// (never libc: see `AGENTS.md`, "No C `malloc`"). Meant for a `private static final` `MH_` field: a missing - /// symbol fails class initialization. - /// - /// @param name the C symbol, as declared in `rocksdb/c.h` - /// @param fd the native signature of `name` - /// @param options linker options, e.g. `Linker.Option.critical(...)` for a pure accessor that cannot block - /// @return a handle invoking `name` - /// @throws UnsatisfiedLinkError if `librocksdb` does not export `name` - static MethodHandle downcall(String name, FunctionDescriptor fd, Linker.Option... options) { + /// Creates a downcall handle for the symbol `name` of the bundled `librocksdb`, the only library this project binds + /// (never libc: see `AGENTS.md`, "No C `malloc`"). Meant for a `private static final` `MH_` field: a missing + /// symbol fails class initialization. + /// + /// @param name the C symbol, as declared in `rocksdb/c.h` + /// @param fd the native signature of `name` + /// @param options linker options, e.g. `Linker.Option.critical(...)` for a pure accessor that cannot block + /// @return a handle invoking `name` + /// @throws UnsatisfiedLinkError if `librocksdb` does not export `name` + static MethodHandle downcall(String name, FunctionDescriptor fd, Linker.Option... options) { return LINKER.downcallHandle( LIB.find(name).orElseThrow(() -> - new UnsatisfiedLinkError("Symbol not found: " + name)), + new UnsatisfiedLinkError("Symbol not found: " + name)), fd, options); } - /// Creates a global-lifetime upcall stub for the private static method `name` of `lookup`'s class, whose Java - /// signature is derived from `fd`. Meant for the `static` block of a callback host: a method that does not match + /// Creates a global-lifetime upcall stub for the private static method `name` of the calling class, whose Java + /// signature is derived from `fd`. Meant for a field initializer of a callback host: a method that does not match /// `fd` fails class initialization. /// - /// @param lookup the caller's own lookup (`MethodHandles.lookup()`), so private dispatch methods are reachable /// @param name name of the static method to expose to native code - /// @param fd the native signature the stub presents + /// @param fd the native signature the stub presents /// @return the stub's native entry point, valid for the life of the JVM - static MemorySegment upcall(MethodHandles.Lookup lookup, String name, FunctionDescriptor fd) { + static MemorySegment upcall(String name, FunctionDescriptor fd) { + Class host = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).getCallerClass(); try { - return LINKER.upcallStub(lookup.findStatic(lookup.lookupClass(), name, fd.toMethodType()), fd, Arena.global()); + MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(host, MethodHandles.lookup()); + return LINKER.upcallStub(lookup.findStatic(host, name, fd.toMethodType()), fd, Arena.global()); } catch (ReflectiveOperationException e) { throw new ExceptionInInitializerError(e); } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionDB.java index f228c3ab..69e526b7 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionDB.java @@ -39,24 +39,17 @@ public final class OptimisticTransactionDB extends NativeDBWithBaseDB // ----------------------------------------------------------------------- /// `void rocksdb_optimistictransactiondb_close(rocksdb_optimistictransactiondb_t* otxn_db);` - private static final MethodHandle MH_CLOSE; + private static final MethodHandle MH_CLOSE = NativeLibrary.downcall( + "rocksdb_optimistictransactiondb_close", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `rocksdb_transaction_t* rocksdb_optimistictransaction_begin(rocksdb_optimistictransactiondb_t* otxn_db, const rocksdb_writeoptions_t* write_options, const rocksdb_optimistictransaction_options_t* otxn_options, rocksdb_transaction_t* old_txn);` - private static final MethodHandle MH_BEGIN; + private static final MethodHandle MH_BEGIN = NativeLibrary.downcall( + "rocksdb_optimistictransaction_begin", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_optimistictransactiondb_close_base_db(rocksdb_t* base_db);` - private static final MethodHandle MH_CLOSE_BASE_DB; - - static { - MH_CLOSE = NativeLibrary.downcall("rocksdb_optimistictransactiondb_close", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_BEGIN = NativeLibrary.downcall("rocksdb_optimistictransaction_begin", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_CLOSE_BASE_DB = NativeLibrary.downcall("rocksdb_optimistictransactiondb_close_base_db", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CLOSE_BASE_DB = NativeLibrary.downcall( + "rocksdb_optimistictransactiondb_close_base_db", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); OptimisticTransactionDB(MemorySegment ptr, MemorySegment baseDb) { super(ptr, baseDb); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionOptions.java index a1cafe0a..1d2cee85 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/OptimisticTransactionOptions.java @@ -12,29 +12,21 @@ public final class OptimisticTransactionOptions extends NativeObject { /// `rocksdb_optimistictransaction_options_t* rocksdb_optimistictransaction_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_optimistictransaction_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_optimistictransaction_options_destroy(rocksdb_optimistictransaction_options_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_optimistictransaction_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_optimistictransaction_options_set_set_snapshot(rocksdb_optimistictransaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SET_SNAPSHOT; + private static final MethodHandle MH_SET_SET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_optimistictransaction_options_set_set_snapshot", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_optimistictransaction_options_get_set_snapshot(rocksdb_optimistictransaction_options_t* opt);` - private static final MethodHandle MH_GET_SET_SNAPSHOT; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_optimistictransaction_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_optimistictransaction_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SET_SNAPSHOT = NativeLibrary.downcall( - "rocksdb_optimistictransaction_options_set_set_snapshot", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SET_SNAPSHOT = NativeLibrary.downcall( - "rocksdb_optimistictransaction_options_get_set_snapshot", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_SET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_optimistictransaction_options_get_set_snapshot", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// Default options for [OptimisticTransactionDB#beginTransaction(WriteOptions)]; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Options.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Options.java index 414273ac..906ea3b6 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Options.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Options.java @@ -25,667 +25,517 @@ public final class Options extends NativeObject { private static final System.Logger LOG = System.getLogger(Options.class.getName()); /// `rocksdb_options_t* rocksdb_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_destroy(rocksdb_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `rocksdb_options_t* rocksdb_options_create_copy(rocksdb_options_t*);` - private static final MethodHandle MH_CREATE_COPY; + private static final MethodHandle MH_CREATE_COPY = NativeLibrary.downcall( + "rocksdb_options_create_copy", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_get_options_from_string(const rocksdb_options_t* base_options, const char* opts_str, rocksdb_options_t* new_options, char** errptr);` - private static final MethodHandle MH_GET_OPTIONS_FROM_STRING; + private static final MethodHandle MH_GET_OPTIONS_FROM_STRING = NativeLibrary.downcall( + "rocksdb_get_options_from_string", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_create_if_missing(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_CREATE_IF_MISSING; + private static final MethodHandle MH_SET_CREATE_IF_MISSING = NativeLibrary.downcall( + "rocksdb_options_set_create_if_missing", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_create_if_missing(rocksdb_options_t*);` - private static final MethodHandle MH_GET_CREATE_IF_MISSING; + private static final MethodHandle MH_GET_CREATE_IF_MISSING = NativeLibrary.downcall( + "rocksdb_options_get_create_if_missing", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_successive_merges(rocksdb_options_t*, size_t);` - private static final MethodHandle MH_SET_MAX_SUCCESSIVE_MERGES; + private static final MethodHandle MH_SET_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall( + "rocksdb_options_set_max_successive_merges", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_options_get_max_successive_merges(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_SUCCESSIVE_MERGES; + private static final MethodHandle MH_GET_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall( + "rocksdb_options_get_max_successive_merges", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_strict_max_successive_merges(rocksdb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_STRICT_MAX_SUCCESSIVE_MERGES; + private static final MethodHandle MH_SET_STRICT_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall( + "rocksdb_options_set_strict_max_successive_merges", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_strict_max_successive_merges(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_STRICT_MAX_SUCCESSIVE_MERGES; + private static final MethodHandle MH_GET_STRICT_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall( + "rocksdb_options_get_strict_max_successive_merges", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_block_based_table_factory(rocksdb_options_t* opt, rocksdb_block_based_table_options_t* table_options);` - private static final MethodHandle MH_SET_BLOCK_BASED_TABLE_FACTORY; + private static final MethodHandle MH_SET_BLOCK_BASED_TABLE_FACTORY = NativeLibrary.downcall( + "rocksdb_options_set_block_based_table_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_cuckoo_table_factory(rocksdb_options_t* opt, rocksdb_cuckoo_table_options_t* table_options);` - private static final MethodHandle MH_SET_CUCKOO_TABLE_FACTORY; + private static final MethodHandle MH_SET_CUCKOO_TABLE_FACTORY = NativeLibrary.downcall( + "rocksdb_options_set_cuckoo_table_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_plain_table_factory(rocksdb_options_t*, uint32_t, int, double, size_t, size_t, char, unsigned char, unsigned char);` - private static final MethodHandle MH_SET_PLAIN_TABLE_FACTORY; + private static final MethodHandle MH_SET_PLAIN_TABLE_FACTORY = NativeLibrary.downcall( + "rocksdb_options_set_plain_table_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT, ValueLayout.JAVA_DOUBLE, NativeCalls.SIZE_T, NativeCalls.SIZE_T, ValueLayout.JAVA_BYTE, ValueLayout.JAVA_BYTE, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_options_enable_statistics(rocksdb_options_t*);` - private static final MethodHandle MH_ENABLE_STATISTICS; + private static final MethodHandle MH_ENABLE_STATISTICS = NativeLibrary.downcall( + "rocksdb_options_enable_statistics", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_statistics_level(rocksdb_options_t*, int level);` - private static final MethodHandle MH_SET_STATISTICS_LEVEL; + private static final MethodHandle MH_SET_STATISTICS_LEVEL = NativeLibrary.downcall( + "rocksdb_options_set_statistics_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_statistics_level(rocksdb_options_t*);` - private static final MethodHandle MH_GET_STATISTICS_LEVEL; + private static final MethodHandle MH_GET_STATISTICS_LEVEL = NativeLibrary.downcall( + "rocksdb_options_get_statistics_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `char* rocksdb_options_statistics_get_string(rocksdb_options_t* opt);` - private static final MethodHandle MH_STATISTICS_GET_STRING; + private static final MethodHandle MH_STATISTICS_GET_STRING = NativeLibrary.downcall( + "rocksdb_options_statistics_get_string", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_options_statistics_get_ticker_count(rocksdb_options_t* opt, uint32_t ticker_type);` - private static final MethodHandle MH_STATISTICS_GET_TICKER_COUNT; + private static final MethodHandle MH_STATISTICS_GET_TICKER_COUNT = NativeLibrary.downcall( + "rocksdb_options_statistics_get_ticker_count", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_options_statistics_get_histogram_data(rocksdb_options_t* opt, uint32_t histogram_type, rocksdb_statistics_histogram_data_t* const data);` - private static final MethodHandle MH_STATISTICS_GET_HISTOGRAM_DATA; + private static final MethodHandle MH_STATISTICS_GET_HISTOGRAM_DATA = NativeLibrary.downcall( + "rocksdb_options_statistics_get_histogram_data", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_compression(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_COMPRESSION; + private static final MethodHandle MH_SET_COMPRESSION = NativeLibrary.downcall( + "rocksdb_options_set_compression", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_compression(rocksdb_options_t*);` - private static final MethodHandle MH_GET_COMPRESSION; + private static final MethodHandle MH_GET_COMPRESSION = NativeLibrary.downcall( + "rocksdb_options_get_compression", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_compaction_style(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_COMPACTION_STYLE; + private static final MethodHandle MH_SET_COMPACTION_STYLE = NativeLibrary.downcall( + "rocksdb_options_set_compaction_style", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_compaction_style(rocksdb_options_t*);` - private static final MethodHandle MH_GET_COMPACTION_STYLE; + private static final MethodHandle MH_GET_COMPACTION_STYLE = NativeLibrary.downcall( + "rocksdb_options_get_compaction_style", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_fifo_compaction_options(rocksdb_options_t* opt, rocksdb_fifo_compaction_options_t* fifo);` - private static final MethodHandle MH_SET_FIFO_COMPACTION_OPTIONS; + private static final MethodHandle MH_SET_FIFO_COMPACTION_OPTIONS = NativeLibrary.downcall( + "rocksdb_options_set_fifo_compaction_options", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_universal_compaction_options(rocksdb_options_t*, rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_SET_UNIVERSAL_COMPACTION_OPTIONS; + private static final MethodHandle MH_SET_UNIVERSAL_COMPACTION_OPTIONS = NativeLibrary.downcall( + "rocksdb_options_set_universal_compaction_options", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_enable_blob_files(rocksdb_options_t* opt, unsigned char val);` - private static final MethodHandle MH_SET_ENABLE_BLOB_FILES; + private static final MethodHandle MH_SET_ENABLE_BLOB_FILES = NativeLibrary.downcall( + "rocksdb_options_set_enable_blob_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_enable_blob_files(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_ENABLE_BLOB_FILES; + private static final MethodHandle MH_GET_ENABLE_BLOB_FILES = NativeLibrary.downcall( + "rocksdb_options_get_enable_blob_files", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_min_blob_size(rocksdb_options_t* opt, uint64_t val);` - private static final MethodHandle MH_SET_MIN_BLOB_SIZE; + private static final MethodHandle MH_SET_MIN_BLOB_SIZE = NativeLibrary.downcall( + "rocksdb_options_set_min_blob_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_min_blob_size(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_MIN_BLOB_SIZE; + private static final MethodHandle MH_GET_MIN_BLOB_SIZE = NativeLibrary.downcall( + "rocksdb_options_get_min_blob_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_file_size(rocksdb_options_t* opt, uint64_t val);` - private static final MethodHandle MH_SET_BLOB_FILE_SIZE; + private static final MethodHandle MH_SET_BLOB_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_options_set_blob_file_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_blob_file_size(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_FILE_SIZE; + private static final MethodHandle MH_GET_BLOB_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_options_get_blob_file_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_compression_type(rocksdb_options_t* opt, int val);` - private static final MethodHandle MH_SET_BLOB_COMPRESSION_TYPE; + private static final MethodHandle MH_SET_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall( + "rocksdb_options_set_blob_compression_type", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_blob_compression_type(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_COMPRESSION_TYPE; + private static final MethodHandle MH_GET_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall( + "rocksdb_options_get_blob_compression_type", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_enable_blob_gc(rocksdb_options_t* opt, unsigned char val);` - private static final MethodHandle MH_SET_ENABLE_BLOB_GC; + private static final MethodHandle MH_SET_ENABLE_BLOB_GC = NativeLibrary.downcall( + "rocksdb_options_set_enable_blob_gc", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_enable_blob_gc(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_ENABLE_BLOB_GC; + private static final MethodHandle MH_GET_ENABLE_BLOB_GC = NativeLibrary.downcall( + "rocksdb_options_get_enable_blob_gc", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_gc_age_cutoff(rocksdb_options_t* opt, double val);` - private static final MethodHandle MH_SET_BLOB_GC_AGE_CUTOFF; + private static final MethodHandle MH_SET_BLOB_GC_AGE_CUTOFF = NativeLibrary.downcall( + "rocksdb_options_set_blob_gc_age_cutoff", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_options_get_blob_gc_age_cutoff(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_GC_AGE_CUTOFF; + private static final MethodHandle MH_GET_BLOB_GC_AGE_CUTOFF = NativeLibrary.downcall( + "rocksdb_options_get_blob_gc_age_cutoff", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_gc_force_threshold(rocksdb_options_t* opt, double val);` - private static final MethodHandle MH_SET_BLOB_GC_FORCE_THRESHOLD; + private static final MethodHandle MH_SET_BLOB_GC_FORCE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_options_set_blob_gc_force_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_options_get_blob_gc_force_threshold(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_GC_FORCE_THRESHOLD; + private static final MethodHandle MH_GET_BLOB_GC_FORCE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_options_get_blob_gc_force_threshold", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_compaction_readahead_size(rocksdb_options_t* opt, uint64_t val);` - private static final MethodHandle MH_SET_BLOB_COMPACTION_READAHEAD_SIZE; + private static final MethodHandle MH_SET_BLOB_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_options_set_blob_compaction_readahead_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_blob_compaction_readahead_size(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_COMPACTION_READAHEAD_SIZE; + private static final MethodHandle MH_GET_BLOB_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_options_get_blob_compaction_readahead_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_file_starting_level(rocksdb_options_t* opt, int val);` - private static final MethodHandle MH_SET_BLOB_FILE_STARTING_LEVEL; + private static final MethodHandle MH_SET_BLOB_FILE_STARTING_LEVEL = NativeLibrary.downcall( + "rocksdb_options_set_blob_file_starting_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_blob_file_starting_level(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_BLOB_FILE_STARTING_LEVEL; + private static final MethodHandle MH_GET_BLOB_FILE_STARTING_LEVEL = NativeLibrary.downcall( + "rocksdb_options_get_blob_file_starting_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_blob_cache(rocksdb_options_t* opt, rocksdb_cache_t* blob_cache);` - private static final MethodHandle MH_SET_BLOB_CACHE; + private static final MethodHandle MH_SET_BLOB_CACHE = NativeLibrary.downcall( + "rocksdb_options_set_blob_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_prepopulate_blob_cache(rocksdb_options_t* opt, int val);` - private static final MethodHandle MH_SET_PREPOPULATE_BLOB_CACHE; + private static final MethodHandle MH_SET_PREPOPULATE_BLOB_CACHE = NativeLibrary.downcall( + "rocksdb_options_set_prepopulate_blob_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_prepopulate_blob_cache(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_PREPOPULATE_BLOB_CACHE; + private static final MethodHandle MH_GET_PREPOPULATE_BLOB_CACHE = NativeLibrary.downcall( + "rocksdb_options_get_prepopulate_blob_cache", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_info_log(rocksdb_options_t*, rocksdb_logger_t*);` - private static final MethodHandle MH_SET_INFO_LOG; + private static final MethodHandle MH_SET_INFO_LOG = NativeLibrary.downcall( + "rocksdb_options_set_info_log", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_info_log_level(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_INFO_LOG_LEVEL; + private static final MethodHandle MH_SET_INFO_LOG_LEVEL = NativeLibrary.downcall( + "rocksdb_options_set_info_log_level", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_info_log_level(rocksdb_options_t*);` - private static final MethodHandle MH_GET_INFO_LOG_LEVEL; + private static final MethodHandle MH_GET_INFO_LOG_LEVEL = NativeLibrary.downcall( + "rocksdb_options_get_info_log_level", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_ratelimiter(rocksdb_options_t* opt, rocksdb_ratelimiter_t* limiter);` - private static final MethodHandle MH_SET_RATELIMITER; + private static final MethodHandle MH_SET_RATELIMITER = NativeLibrary.downcall( + "rocksdb_options_set_ratelimiter", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_write_buffer_manager(rocksdb_options_t* opt, rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_SET_WRITE_BUFFER_MANAGER; + private static final MethodHandle MH_SET_WRITE_BUFFER_MANAGER = NativeLibrary.downcall( + "rocksdb_options_set_write_buffer_manager", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_env(rocksdb_options_t*, rocksdb_env_t*);` - private static final MethodHandle MH_SET_ENV; + private static final MethodHandle MH_SET_ENV = NativeLibrary.downcall( + "rocksdb_options_set_env", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_sst_file_manager(rocksdb_options_t* opt, rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_SET_SST_FILE_MANAGER; + private static final MethodHandle MH_SET_SST_FILE_MANAGER = NativeLibrary.downcall( + "rocksdb_options_set_sst_file_manager", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_sst_partitioner_factory(rocksdb_options_t*, rocksdb_sst_partitioner_factory_t*);` - private static final MethodHandle MH_SET_SST_PARTITIONER_FACTORY; + private static final MethodHandle MH_SET_SST_PARTITIONER_FACTORY = NativeLibrary.downcall( + "rocksdb_options_set_sst_partitioner_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_prefix_extractor(rocksdb_options_t*, rocksdb_slicetransform_t*);` - private static final MethodHandle MH_SET_FILE_CHECKSUM_GEN_FACTORY = NativeLibrary.downcall("rocksdb_options_set_file_checksum_gen_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - /// `void rocksdb_options_set_file_checksum_gen_factory(rocksdb_options_t*, rocksdb_file_checksum_gen_factory_t*);` - private static final MethodHandle MH_SET_PREFIX_EXTRACTOR; + private static final MethodHandle MH_SET_FILE_CHECKSUM_GEN_FACTORY = NativeLibrary.downcall( + "rocksdb_options_set_file_checksum_gen_factory", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); + /// `void rocksdb_options_set_file_checksum_gen_factory(rocksdb_options_t*, rocksdb_file_checksum_gen_factory_t*);` + private static final MethodHandle MH_SET_PREFIX_EXTRACTOR = NativeLibrary.downcall( + "rocksdb_options_set_prefix_extractor", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_dbpath_t* rocksdb_dbpath_create(const char* path, uint64_t target_size);` - private static final MethodHandle MH_DBPATH_CREATE; + private static final MethodHandle MH_DBPATH_CREATE = NativeLibrary.downcall( + "rocksdb_dbpath_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `void rocksdb_dbpath_destroy(rocksdb_dbpath_t*);` - private static final MethodHandle MH_DBPATH_DESTROY; + private static final MethodHandle MH_DBPATH_DESTROY = NativeLibrary.downcall( + "rocksdb_dbpath_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_db_paths(rocksdb_options_t*, const rocksdb_dbpath_t** path_values, size_t num_paths);` - private static final MethodHandle MH_SET_DB_PATHS; + private static final MethodHandle MH_SET_DB_PATHS = NativeLibrary.downcall( + "rocksdb_options_set_db_paths", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_options_set_cf_paths(rocksdb_options_t*, const rocksdb_dbpath_t** path_values, size_t num_paths);` - private static final MethodHandle MH_SET_CF_PATHS; + private static final MethodHandle MH_SET_CF_PATHS = NativeLibrary.downcall( + "rocksdb_options_set_cf_paths", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_options_set_metadata_write_temperature(rocksdb_options_t* opt, int v);` - private static final MethodHandle MH_SET_METADATA_WRITE_TEMPERATURE; + private static final MethodHandle MH_SET_METADATA_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_set_metadata_write_temperature", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_metadata_write_temperature(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_METADATA_WRITE_TEMPERATURE; + private static final MethodHandle MH_GET_METADATA_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_get_metadata_write_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_wal_write_temperature(rocksdb_options_t* opt, int v);` - private static final MethodHandle MH_SET_WAL_WRITE_TEMPERATURE; + private static final MethodHandle MH_SET_WAL_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_set_wal_write_temperature", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_wal_write_temperature(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_WAL_WRITE_TEMPERATURE; + private static final MethodHandle MH_GET_WAL_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_get_wal_write_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_last_level_temperature(rocksdb_options_t* opt, int v);` - private static final MethodHandle MH_SET_LAST_LEVEL_TEMPERATURE; + private static final MethodHandle MH_SET_LAST_LEVEL_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_set_last_level_temperature", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_last_level_temperature(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_LAST_LEVEL_TEMPERATURE; + private static final MethodHandle MH_GET_LAST_LEVEL_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_get_last_level_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_default_write_temperature(rocksdb_options_t* opt, int v);` - private static final MethodHandle MH_SET_DEFAULT_WRITE_TEMPERATURE; + private static final MethodHandle MH_SET_DEFAULT_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_set_default_write_temperature", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_default_write_temperature(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_DEFAULT_WRITE_TEMPERATURE; + private static final MethodHandle MH_GET_DEFAULT_WRITE_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_get_default_write_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_default_temperature(rocksdb_options_t* opt, int v);` - private static final MethodHandle MH_SET_DEFAULT_TEMPERATURE; + private static final MethodHandle MH_SET_DEFAULT_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_set_default_temperature", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_default_temperature(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_DEFAULT_TEMPERATURE; + private static final MethodHandle MH_GET_DEFAULT_TEMPERATURE = NativeLibrary.downcall( + "rocksdb_options_get_default_temperature", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_write_buffer_size(rocksdb_options_t*, size_t);` - private static final MethodHandle MH_SET_WRITE_BUFFER_SIZE; + private static final MethodHandle MH_SET_WRITE_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_options_set_write_buffer_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_options_get_write_buffer_size(rocksdb_options_t*);` - private static final MethodHandle MH_GET_WRITE_BUFFER_SIZE; + private static final MethodHandle MH_GET_WRITE_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_options_get_write_buffer_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_enforce_write_buffer_manager_during_recovery(rocksdb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY; + private static final MethodHandle MH_SET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY = NativeLibrary.downcall( + "rocksdb_options_set_enforce_write_buffer_manager_during_recovery", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_enforce_write_buffer_manager_during_recovery(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY; + private static final MethodHandle MH_GET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY = NativeLibrary.downcall( + "rocksdb_options_get_enforce_write_buffer_manager_during_recovery", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_num_levels(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_NUM_LEVELS; + private static final MethodHandle MH_SET_NUM_LEVELS = NativeLibrary.downcall( + "rocksdb_options_set_num_levels", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_num_levels(rocksdb_options_t*);` - private static final MethodHandle MH_GET_NUM_LEVELS; + private static final MethodHandle MH_GET_NUM_LEVELS = NativeLibrary.downcall( + "rocksdb_options_get_num_levels", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_write_buffer_number(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_MAX_WRITE_BUFFER_NUMBER; + private static final MethodHandle MH_SET_MAX_WRITE_BUFFER_NUMBER = NativeLibrary.downcall( + "rocksdb_options_set_max_write_buffer_number", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_max_write_buffer_number(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_WRITE_BUFFER_NUMBER; + private static final MethodHandle MH_GET_MAX_WRITE_BUFFER_NUMBER = NativeLibrary.downcall( + "rocksdb_options_get_max_write_buffer_number", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_hash_skip_list_rep(rocksdb_options_t*, size_t, int32_t, int32_t);` - private static final MethodHandle MH_SET_HASH_SKIP_LIST_REP; + private static final MethodHandle MH_SET_HASH_SKIP_LIST_REP = NativeLibrary.downcall( + "rocksdb_options_set_hash_skip_list_rep", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT) + ); /// `void rocksdb_options_set_hash_link_list_rep(rocksdb_options_t*, size_t);` - private static final MethodHandle MH_SET_HASH_LINK_LIST_REP; + private static final MethodHandle MH_SET_HASH_LINK_LIST_REP = NativeLibrary.downcall( + "rocksdb_options_set_hash_link_list_rep", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_options_set_memtable_vector_rep(rocksdb_options_t*);` - private static final MethodHandle MH_SET_MEMTABLE_VECTOR_REP; + private static final MethodHandle MH_SET_MEMTABLE_VECTOR_REP = NativeLibrary.downcall( + "rocksdb_options_set_memtable_vector_rep", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_level0_file_num_compaction_trigger(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER; + private static final MethodHandle MH_SET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_set_level0_file_num_compaction_trigger", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_level0_file_num_compaction_trigger(rocksdb_options_t*);` - private static final MethodHandle MH_GET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER; + private static final MethodHandle MH_GET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_get_level0_file_num_compaction_trigger", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_level0_slowdown_writes_trigger(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_LEVEL0_SLOWDOWN_WRITES_TRIGGER; + private static final MethodHandle MH_SET_LEVEL0_SLOWDOWN_WRITES_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_set_level0_slowdown_writes_trigger", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_level0_slowdown_writes_trigger(rocksdb_options_t*);` - private static final MethodHandle MH_GET_LEVEL0_SLOWDOWN_WRITES_TRIGGER; + private static final MethodHandle MH_GET_LEVEL0_SLOWDOWN_WRITES_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_get_level0_slowdown_writes_trigger", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_level0_stop_writes_trigger(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_LEVEL0_STOP_WRITES_TRIGGER; + private static final MethodHandle MH_SET_LEVEL0_STOP_WRITES_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_set_level0_stop_writes_trigger", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_level0_stop_writes_trigger(rocksdb_options_t*);` - private static final MethodHandle MH_GET_LEVEL0_STOP_WRITES_TRIGGER; + private static final MethodHandle MH_GET_LEVEL0_STOP_WRITES_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_get_level0_stop_writes_trigger", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_disable_auto_compactions(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_DISABLE_AUTO_COMPACTIONS; + private static final MethodHandle MH_SET_DISABLE_AUTO_COMPACTIONS = NativeLibrary.downcall( + "rocksdb_options_set_disable_auto_compactions", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `unsigned char rocksdb_options_get_disable_auto_compactions(rocksdb_options_t*);` - private static final MethodHandle MH_GET_DISABLE_AUTO_COMPACTIONS; + private static final MethodHandle MH_GET_DISABLE_AUTO_COMPACTIONS = NativeLibrary.downcall( + "rocksdb_options_get_disable_auto_compactions", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_target_file_size_base(rocksdb_options_t*, uint64_t);` - private static final MethodHandle MH_SET_TARGET_FILE_SIZE_BASE; + private static final MethodHandle MH_SET_TARGET_FILE_SIZE_BASE = NativeLibrary.downcall( + "rocksdb_options_set_target_file_size_base", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_target_file_size_base(rocksdb_options_t*);` - private static final MethodHandle MH_GET_TARGET_FILE_SIZE_BASE; + private static final MethodHandle MH_GET_TARGET_FILE_SIZE_BASE = NativeLibrary.downcall( + "rocksdb_options_get_target_file_size_base", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_bytes_for_level_base(rocksdb_options_t*, uint64_t);` - private static final MethodHandle MH_SET_MAX_BYTES_FOR_LEVEL_BASE; + private static final MethodHandle MH_SET_MAX_BYTES_FOR_LEVEL_BASE = NativeLibrary.downcall( + "rocksdb_options_set_max_bytes_for_level_base", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_max_bytes_for_level_base(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_BYTES_FOR_LEVEL_BASE; + private static final MethodHandle MH_GET_MAX_BYTES_FOR_LEVEL_BASE = NativeLibrary.downcall( + "rocksdb_options_get_max_bytes_for_level_base", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_background_jobs(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_MAX_BACKGROUND_JOBS; + private static final MethodHandle MH_SET_MAX_BACKGROUND_JOBS = NativeLibrary.downcall( + "rocksdb_options_set_max_background_jobs", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_max_background_jobs(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_BACKGROUND_JOBS; + private static final MethodHandle MH_GET_MAX_BACKGROUND_JOBS = NativeLibrary.downcall( + "rocksdb_options_get_max_background_jobs", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_open_files(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_MAX_OPEN_FILES; + private static final MethodHandle MH_SET_MAX_OPEN_FILES = NativeLibrary.downcall( + "rocksdb_options_set_max_open_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_max_open_files(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_OPEN_FILES; + private static final MethodHandle MH_GET_MAX_OPEN_FILES = NativeLibrary.downcall( + "rocksdb_options_get_max_open_files", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_max_file_opening_threads(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_MAX_FILE_OPENING_THREADS; + private static final MethodHandle MH_SET_MAX_FILE_OPENING_THREADS = NativeLibrary.downcall( + "rocksdb_options_set_max_file_opening_threads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_max_file_opening_threads(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MAX_FILE_OPENING_THREADS; + private static final MethodHandle MH_GET_MAX_FILE_OPENING_THREADS = NativeLibrary.downcall( + "rocksdb_options_get_max_file_opening_threads", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_advise_random_on_open(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_ADVISE_RANDOM_ON_OPEN; + private static final MethodHandle MH_SET_ADVISE_RANDOM_ON_OPEN = NativeLibrary.downcall( + "rocksdb_options_set_advise_random_on_open", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_advise_random_on_open(rocksdb_options_t*);` - private static final MethodHandle MH_GET_ADVISE_RANDOM_ON_OPEN; + private static final MethodHandle MH_GET_ADVISE_RANDOM_ON_OPEN = NativeLibrary.downcall( + "rocksdb_options_get_advise_random_on_open", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_skip_stats_update_on_db_open(rocksdb_options_t* opt, unsigned char val);` - private static final MethodHandle MH_SET_SKIP_STATS_UPDATE_ON_DB_OPEN; + private static final MethodHandle MH_SET_SKIP_STATS_UPDATE_ON_DB_OPEN = NativeLibrary.downcall( + "rocksdb_options_set_skip_stats_update_on_db_open", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_skip_stats_update_on_db_open(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_SKIP_STATS_UPDATE_ON_DB_OPEN; + private static final MethodHandle MH_GET_SKIP_STATS_UPDATE_ON_DB_OPEN = NativeLibrary.downcall( + "rocksdb_options_get_skip_stats_update_on_db_open", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_increase_parallelism(rocksdb_options_t* opt, int total_threads);` - private static final MethodHandle MH_INCREASE_PARALLELISM; + private static final MethodHandle MH_INCREASE_PARALLELISM = NativeLibrary.downcall( + "rocksdb_options_increase_parallelism", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `void rocksdb_options_set_unordered_write(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_UNORDERED_WRITE; + private static final MethodHandle MH_SET_UNORDERED_WRITE = NativeLibrary.downcall( + "rocksdb_options_set_unordered_write", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_unordered_write(rocksdb_options_t*);` - private static final MethodHandle MH_GET_UNORDERED_WRITE; + private static final MethodHandle MH_GET_UNORDERED_WRITE = NativeLibrary.downcall( + "rocksdb_options_get_unordered_write", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_bytes_per_sync(rocksdb_options_t*, uint64_t);` - private static final MethodHandle MH_SET_BYTES_PER_SYNC; + private static final MethodHandle MH_SET_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_options_set_bytes_per_sync", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_options_get_bytes_per_sync(rocksdb_options_t*);` - private static final MethodHandle MH_GET_BYTES_PER_SYNC; + private static final MethodHandle MH_GET_BYTES_PER_SYNC = NativeLibrary.downcall( + "rocksdb_options_get_bytes_per_sync", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_use_direct_reads(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_USE_DIRECT_READS; + private static final MethodHandle MH_SET_USE_DIRECT_READS = NativeLibrary.downcall( + "rocksdb_options_set_use_direct_reads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_use_direct_reads(rocksdb_options_t*);` - private static final MethodHandle MH_GET_USE_DIRECT_READS; + private static final MethodHandle MH_GET_USE_DIRECT_READS = NativeLibrary.downcall( + "rocksdb_options_get_use_direct_reads", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_use_direct_io_for_flush_and_compaction(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION; + private static final MethodHandle MH_SET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION = NativeLibrary.downcall( + "rocksdb_options_set_use_direct_io_for_flush_and_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_use_direct_io_for_flush_and_compaction(rocksdb_options_t*);` - private static final MethodHandle MH_GET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION; + private static final MethodHandle MH_GET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION = NativeLibrary.downcall( + "rocksdb_options_get_use_direct_io_for_flush_and_compaction", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_compaction_pri(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_COMPACTION_PRI; + private static final MethodHandle MH_SET_COMPACTION_PRI = NativeLibrary.downcall( + "rocksdb_options_set_compaction_pri", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_compaction_pri(rocksdb_options_t*);` - private static final MethodHandle MH_GET_COMPACTION_PRI; + private static final MethodHandle MH_GET_COMPACTION_PRI = NativeLibrary.downcall( + "rocksdb_options_get_compaction_pri", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_bottommost_compression(rocksdb_options_t*, int);` - private static final MethodHandle MH_SET_BOTTOMMOST_COMPRESSION; + private static final MethodHandle MH_SET_BOTTOMMOST_COMPRESSION = NativeLibrary.downcall( + "rocksdb_options_set_bottommost_compression", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_options_get_bottommost_compression(rocksdb_options_t*);` - private static final MethodHandle MH_GET_BOTTOMMOST_COMPRESSION; + private static final MethodHandle MH_GET_BOTTOMMOST_COMPRESSION = NativeLibrary.downcall( + "rocksdb_options_get_bottommost_compression", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_memtable_prefix_bloom_size_ratio(rocksdb_options_t*, double);` - private static final MethodHandle MH_SET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO; + private static final MethodHandle MH_SET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO = NativeLibrary.downcall( + "rocksdb_options_set_memtable_prefix_bloom_size_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_options_get_memtable_prefix_bloom_size_ratio(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO; + private static final MethodHandle MH_GET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO = NativeLibrary.downcall( + "rocksdb_options_get_memtable_prefix_bloom_size_ratio", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_memtable_whole_key_filtering(rocksdb_options_t*, unsigned char);` - private static final MethodHandle MH_SET_MEMTABLE_WHOLE_KEY_FILTERING; + private static final MethodHandle MH_SET_MEMTABLE_WHOLE_KEY_FILTERING = NativeLibrary.downcall( + "rocksdb_options_set_memtable_whole_key_filtering", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_options_get_memtable_whole_key_filtering(rocksdb_options_t* opt);` - private static final MethodHandle MH_GET_MEMTABLE_WHOLE_KEY_FILTERING; + private static final MethodHandle MH_GET_MEMTABLE_WHOLE_KEY_FILTERING = NativeLibrary.downcall( + "rocksdb_options_get_memtable_whole_key_filtering", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_memtable_huge_page_size(rocksdb_options_t*, size_t);` - private static final MethodHandle MH_SET_MEMTABLE_HUGE_PAGE_SIZE; + private static final MethodHandle MH_SET_MEMTABLE_HUGE_PAGE_SIZE = NativeLibrary.downcall( + "rocksdb_options_set_memtable_huge_page_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_options_get_memtable_huge_page_size(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MEMTABLE_HUGE_PAGE_SIZE; + private static final MethodHandle MH_GET_MEMTABLE_HUGE_PAGE_SIZE = NativeLibrary.downcall( + "rocksdb_options_get_memtable_huge_page_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_bloom_locality(rocksdb_options_t*, uint32_t);` - private static final MethodHandle MH_SET_BLOOM_LOCALITY; + private static final MethodHandle MH_SET_BLOOM_LOCALITY = NativeLibrary.downcall( + "rocksdb_options_set_bloom_locality", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_options_get_bloom_locality(rocksdb_options_t*);` - private static final MethodHandle MH_GET_BLOOM_LOCALITY; + private static final MethodHandle MH_GET_BLOOM_LOCALITY = NativeLibrary.downcall( + "rocksdb_options_get_bloom_locality", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_options_set_memtable_op_scan_flush_trigger(rocksdb_options_t*, uint32_t);` - private static final MethodHandle MH_SET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER; - /// `uint32_t rocksdb_options_get_memtable_op_scan_flush_trigger(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER; - /// `void rocksdb_options_set_memtable_avg_op_scan_flush_trigger(rocksdb_options_t*, uint32_t);` - private static final MethodHandle MH_SET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER; - /// `uint32_t rocksdb_options_get_memtable_avg_op_scan_flush_trigger(rocksdb_options_t*);` - private static final MethodHandle MH_GET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER; - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_CREATE_COPY = NativeLibrary.downcall("rocksdb_options_create_copy", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_GET_OPTIONS_FROM_STRING = NativeLibrary.downcall("rocksdb_get_options_from_string", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_CREATE_IF_MISSING = NativeLibrary.downcall("rocksdb_options_set_create_if_missing", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_CREATE_IF_MISSING = NativeLibrary.downcall("rocksdb_options_get_create_if_missing", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - MH_SET_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall("rocksdb_options_set_max_successive_merges", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall("rocksdb_options_get_max_successive_merges", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_STRICT_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall("rocksdb_options_set_strict_max_successive_merges", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_STRICT_MAX_SUCCESSIVE_MERGES = NativeLibrary.downcall("rocksdb_options_get_strict_max_successive_merges", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BLOCK_BASED_TABLE_FACTORY = NativeLibrary.downcall( - "rocksdb_options_set_block_based_table_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_CUCKOO_TABLE_FACTORY = NativeLibrary.downcall( - "rocksdb_options_set_cuckoo_table_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_PLAIN_TABLE_FACTORY = NativeLibrary.downcall( - "rocksdb_options_set_plain_table_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT, - ValueLayout.JAVA_DOUBLE, NativeCalls.SIZE_T, NativeCalls.SIZE_T, - ValueLayout.JAVA_BYTE, ValueLayout.JAVA_BYTE, ValueLayout.JAVA_BYTE)); - - MH_ENABLE_STATISTICS = NativeLibrary.downcall("rocksdb_options_enable_statistics", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_STATISTICS_LEVEL = NativeLibrary.downcall("rocksdb_options_set_statistics_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_STATISTICS_LEVEL = NativeLibrary.downcall("rocksdb_options_get_statistics_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_STATISTICS_GET_STRING = NativeLibrary.downcall("rocksdb_options_statistics_get_string", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_STATISTICS_GET_TICKER_COUNT = NativeLibrary.downcall("rocksdb_options_statistics_get_ticker_count", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_STATISTICS_GET_HISTOGRAM_DATA = NativeLibrary.downcall("rocksdb_options_statistics_get_histogram_data", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_COMPRESSION = NativeLibrary.downcall("rocksdb_options_set_compression", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_COMPRESSION = NativeLibrary.downcall("rocksdb_options_get_compression", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_COMPACTION_STYLE = NativeLibrary.downcall("rocksdb_options_set_compaction_style", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_COMPACTION_STYLE = NativeLibrary.downcall("rocksdb_options_get_compaction_style", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_FIFO_COMPACTION_OPTIONS = NativeLibrary.downcall("rocksdb_options_set_fifo_compaction_options", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_UNIVERSAL_COMPACTION_OPTIONS = NativeLibrary.downcall( - "rocksdb_options_set_universal_compaction_options", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_ENABLE_BLOB_FILES = NativeLibrary.downcall("rocksdb_options_set_enable_blob_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ENABLE_BLOB_FILES = NativeLibrary.downcall("rocksdb_options_get_enable_blob_files", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_MIN_BLOB_SIZE = NativeLibrary.downcall("rocksdb_options_set_min_blob_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MIN_BLOB_SIZE = NativeLibrary.downcall("rocksdb_options_get_min_blob_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_BLOB_FILE_SIZE = NativeLibrary.downcall("rocksdb_options_set_blob_file_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_BLOB_FILE_SIZE = NativeLibrary.downcall("rocksdb_options_get_blob_file_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall("rocksdb_options_set_blob_compression_type", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BLOB_COMPRESSION_TYPE = NativeLibrary.downcall("rocksdb_options_get_blob_compression_type", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_ENABLE_BLOB_GC = NativeLibrary.downcall("rocksdb_options_set_enable_blob_gc", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ENABLE_BLOB_GC = NativeLibrary.downcall("rocksdb_options_get_enable_blob_gc", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BLOB_GC_AGE_CUTOFF = NativeLibrary.downcall("rocksdb_options_set_blob_gc_age_cutoff", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_BLOB_GC_AGE_CUTOFF = NativeLibrary.downcall("rocksdb_options_get_blob_gc_age_cutoff", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_BLOB_GC_FORCE_THRESHOLD = NativeLibrary.downcall("rocksdb_options_set_blob_gc_force_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_BLOB_GC_FORCE_THRESHOLD = NativeLibrary.downcall("rocksdb_options_get_blob_gc_force_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_BLOB_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_options_set_blob_compaction_readahead_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_BLOB_COMPACTION_READAHEAD_SIZE = NativeLibrary.downcall( - "rocksdb_options_get_blob_compaction_readahead_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_BLOB_FILE_STARTING_LEVEL = NativeLibrary.downcall("rocksdb_options_set_blob_file_starting_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BLOB_FILE_STARTING_LEVEL = NativeLibrary.downcall("rocksdb_options_get_blob_file_starting_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_BLOB_CACHE = NativeLibrary.downcall("rocksdb_options_set_blob_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_PREPOPULATE_BLOB_CACHE = NativeLibrary.downcall("rocksdb_options_set_prepopulate_blob_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_PREPOPULATE_BLOB_CACHE = NativeLibrary.downcall("rocksdb_options_get_prepopulate_blob_cache", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_INFO_LOG = NativeLibrary.downcall("rocksdb_options_set_info_log", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_INFO_LOG_LEVEL = NativeLibrary.downcall("rocksdb_options_set_info_log_level", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_INFO_LOG_LEVEL = NativeLibrary.downcall("rocksdb_options_get_info_log_level", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_RATELIMITER = NativeLibrary.downcall("rocksdb_options_set_ratelimiter", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_WRITE_BUFFER_MANAGER = NativeLibrary.downcall("rocksdb_options_set_write_buffer_manager", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_ENV = NativeLibrary.downcall("rocksdb_options_set_env", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_SST_FILE_MANAGER = NativeLibrary.downcall("rocksdb_options_set_sst_file_manager", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_SST_PARTITIONER_FACTORY = NativeLibrary.downcall("rocksdb_options_set_sst_partitioner_factory", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_PREFIX_EXTRACTOR = NativeLibrary.downcall("rocksdb_options_set_prefix_extractor", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DBPATH_CREATE = NativeLibrary.downcall("rocksdb_dbpath_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_DBPATH_DESTROY = NativeLibrary.downcall("rocksdb_dbpath_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_DB_PATHS = NativeLibrary.downcall("rocksdb_options_set_db_paths", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_CF_PATHS = NativeLibrary.downcall("rocksdb_options_set_cf_paths", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_METADATA_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_set_metadata_write_temperature", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_METADATA_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_get_metadata_write_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_WAL_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_set_wal_write_temperature", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_WAL_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_get_wal_write_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_LAST_LEVEL_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_set_last_level_temperature", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_LAST_LEVEL_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_get_last_level_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_DEFAULT_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_set_default_write_temperature", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_DEFAULT_WRITE_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_get_default_write_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_DEFAULT_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_set_default_temperature", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_DEFAULT_TEMPERATURE = NativeLibrary.downcall("rocksdb_options_get_default_temperature", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_WRITE_BUFFER_SIZE = NativeLibrary.downcall("rocksdb_options_set_write_buffer_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_WRITE_BUFFER_SIZE = NativeLibrary.downcall("rocksdb_options_get_write_buffer_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY = NativeLibrary.downcall("rocksdb_options_set_enforce_write_buffer_manager_during_recovery", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ENFORCE_WRITE_BUFFER_MANAGER_DURING_RECOVERY = NativeLibrary.downcall("rocksdb_options_get_enforce_write_buffer_manager_during_recovery", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_NUM_LEVELS = NativeLibrary.downcall("rocksdb_options_set_num_levels", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_NUM_LEVELS = NativeLibrary.downcall("rocksdb_options_get_num_levels", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MAX_WRITE_BUFFER_NUMBER = NativeLibrary.downcall("rocksdb_options_set_max_write_buffer_number", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_WRITE_BUFFER_NUMBER = NativeLibrary.downcall("rocksdb_options_get_max_write_buffer_number", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_HASH_SKIP_LIST_REP = NativeLibrary.downcall("rocksdb_options_set_hash_skip_list_rep", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.JAVA_INT, ValueLayout.JAVA_INT)); - - MH_SET_HASH_LINK_LIST_REP = NativeLibrary.downcall("rocksdb_options_set_hash_link_list_rep", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_MEMTABLE_VECTOR_REP = NativeLibrary.downcall("rocksdb_options_set_memtable_vector_rep", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_set_level0_file_num_compaction_trigger", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_LEVEL0_FILE_NUM_COMPACTION_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_get_level0_file_num_compaction_trigger", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_LEVEL0_SLOWDOWN_WRITES_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_set_level0_slowdown_writes_trigger", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_LEVEL0_SLOWDOWN_WRITES_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_get_level0_slowdown_writes_trigger", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_LEVEL0_STOP_WRITES_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_set_level0_stop_writes_trigger", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_LEVEL0_STOP_WRITES_TRIGGER = NativeLibrary.downcall( - "rocksdb_options_get_level0_stop_writes_trigger", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_DISABLE_AUTO_COMPACTIONS = NativeLibrary.downcall( - "rocksdb_options_set_disable_auto_compactions", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_DISABLE_AUTO_COMPACTIONS = NativeLibrary.downcall( - "rocksdb_options_get_disable_auto_compactions", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TARGET_FILE_SIZE_BASE = NativeLibrary.downcall("rocksdb_options_set_target_file_size_base", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_TARGET_FILE_SIZE_BASE = NativeLibrary.downcall("rocksdb_options_get_target_file_size_base", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_BYTES_FOR_LEVEL_BASE = NativeLibrary.downcall("rocksdb_options_set_max_bytes_for_level_base", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_BYTES_FOR_LEVEL_BASE = NativeLibrary.downcall("rocksdb_options_get_max_bytes_for_level_base", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_BACKGROUND_JOBS = NativeLibrary.downcall("rocksdb_options_set_max_background_jobs", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_BACKGROUND_JOBS = NativeLibrary.downcall("rocksdb_options_get_max_background_jobs", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MAX_OPEN_FILES = NativeLibrary.downcall("rocksdb_options_set_max_open_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_OPEN_FILES = NativeLibrary.downcall("rocksdb_options_get_max_open_files", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MAX_FILE_OPENING_THREADS = NativeLibrary.downcall("rocksdb_options_set_max_file_opening_threads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_FILE_OPENING_THREADS = NativeLibrary.downcall("rocksdb_options_get_max_file_opening_threads", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_ADVISE_RANDOM_ON_OPEN = NativeLibrary.downcall("rocksdb_options_set_advise_random_on_open", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ADVISE_RANDOM_ON_OPEN = NativeLibrary.downcall("rocksdb_options_get_advise_random_on_open", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SKIP_STATS_UPDATE_ON_DB_OPEN = NativeLibrary.downcall( - "rocksdb_options_set_skip_stats_update_on_db_open", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SKIP_STATS_UPDATE_ON_DB_OPEN = NativeLibrary.downcall( - "rocksdb_options_get_skip_stats_update_on_db_open", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_INCREASE_PARALLELISM = NativeLibrary.downcall("rocksdb_options_increase_parallelism", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_SET_UNORDERED_WRITE = NativeLibrary.downcall("rocksdb_options_set_unordered_write", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_UNORDERED_WRITE = NativeLibrary.downcall("rocksdb_options_get_unordered_write", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_options_set_bytes_per_sync", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_BYTES_PER_SYNC = NativeLibrary.downcall("rocksdb_options_get_bytes_per_sync", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_USE_DIRECT_READS = NativeLibrary.downcall("rocksdb_options_set_use_direct_reads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_DIRECT_READS = NativeLibrary.downcall("rocksdb_options_get_use_direct_reads", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION = NativeLibrary.downcall( - "rocksdb_options_set_use_direct_io_for_flush_and_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_DIRECT_IO_FOR_FLUSH_AND_COMPACTION = NativeLibrary.downcall( - "rocksdb_options_get_use_direct_io_for_flush_and_compaction", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_COMPACTION_PRI = NativeLibrary.downcall("rocksdb_options_set_compaction_pri", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_COMPACTION_PRI = NativeLibrary.downcall("rocksdb_options_get_compaction_pri", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_BOTTOMMOST_COMPRESSION = NativeLibrary.downcall("rocksdb_options_set_bottommost_compression", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BOTTOMMOST_COMPRESSION = NativeLibrary.downcall("rocksdb_options_get_bottommost_compression", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO = NativeLibrary.downcall( - "rocksdb_options_set_memtable_prefix_bloom_size_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_MEMTABLE_PREFIX_BLOOM_SIZE_RATIO = NativeLibrary.downcall( - "rocksdb_options_get_memtable_prefix_bloom_size_ratio", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_MEMTABLE_WHOLE_KEY_FILTERING = NativeLibrary.downcall( - "rocksdb_options_set_memtable_whole_key_filtering", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_MEMTABLE_WHOLE_KEY_FILTERING = NativeLibrary.downcall( - "rocksdb_options_get_memtable_whole_key_filtering", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_MEMTABLE_HUGE_PAGE_SIZE = NativeLibrary.downcall("rocksdb_options_set_memtable_huge_page_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall("rocksdb_options_set_memtable_op_scan_flush_trigger", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall("rocksdb_options_get_memtable_op_scan_flush_trigger", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall("rocksdb_options_set_memtable_avg_op_scan_flush_trigger", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall("rocksdb_options_get_memtable_avg_op_scan_flush_trigger", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_GET_MEMTABLE_HUGE_PAGE_SIZE = NativeLibrary.downcall("rocksdb_options_get_memtable_huge_page_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_BLOOM_LOCALITY = NativeLibrary.downcall("rocksdb_options_set_bloom_locality", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_BLOOM_LOCALITY = NativeLibrary.downcall("rocksdb_options_get_bloom_locality", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_SET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_set_memtable_op_scan_flush_trigger", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); + /// `uint32_t rocksdb_options_get_memtable_op_scan_flush_trigger(rocksdb_options_t*);` + private static final MethodHandle MH_GET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_get_memtable_op_scan_flush_trigger", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); + /// `void rocksdb_options_set_memtable_avg_op_scan_flush_trigger(rocksdb_options_t*, uint32_t);` + private static final MethodHandle MH_SET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_set_memtable_avg_op_scan_flush_trigger", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); + /// `uint32_t rocksdb_options_get_memtable_avg_op_scan_flush_trigger(rocksdb_options_t*);` + private static final MethodHandle MH_GET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER = NativeLibrary.downcall( + "rocksdb_options_get_memtable_avg_op_scan_flush_trigger", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// RocksDB-default options for a [ColumnFamilyDescriptor] created without any; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. @@ -1501,20 +1351,20 @@ public Options setSstPartitionerFactory(SstPartitionerFactory factory) { } } - /// Attaches a [FileChecksumGenFactory] to generate checksums for newly written SST files. - /// - /// The factory uses shared ownership: both objects may be closed independently. - /// - /// @param factory the file checksum generator factory to attach - /// @return `this` for chaining - public Options setFileChecksumGenFactory(FileChecksumGenFactory factory) { - try { - MH_SET_FILE_CHECKSUM_GEN_FACTORY.invokeExact(ptr(), factory.ptr()); - return this; - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("setFileChecksumGenFactory failed", t); - } - } + /// Attaches a [FileChecksumGenFactory] to generate checksums for newly written SST files. + /// + /// The factory uses shared ownership: both objects may be closed independently. + /// + /// @param factory the file checksum generator factory to attach + /// @return `this` for chaining + public Options setFileChecksumGenFactory(FileChecksumGenFactory factory) { + try { + MH_SET_FILE_CHECKSUM_GEN_FACTORY.invokeExact(ptr(), factory.ptr()); + return this; + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("setFileChecksumGenFactory failed", t); + } + } /// Sets the directories SST files are spread over, for tiered storage across several mount points. /// @@ -2139,54 +1989,54 @@ public int getBloomLocality() { } /// Forces a memtable flush once a single iterator operation (`SeekToFirst()`, `Seek()` or - /// `Next()`) scans this many invisible entries (tombstones or hidden puts) from the active - /// memtable. Reduces the cost of scanning through a large number of dead entries in range-scan-heavy - /// workloads. Only forward scans are covered, and tailing iterators are not affected yet. - /// Consider enabling deletion-triggered compaction alongside this option, to compact away - /// tombstones once the memtable is flushed. `0` disables the trigger. Default: 0. - /// - /// @param trigger number of invisible entries per operation that triggers a flush, or `0` to disable - /// @return `this` for chaining - /// @throws IllegalArgumentException if `trigger` is negative - public Options setMemtableOpScanFlushTrigger(int trigger) { - if (trigger < 0) { - throw new IllegalArgumentException("memtableOpScanFlushTrigger must not be negative: " + trigger); - } - NativeFields.setInt(MH_SET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER, ptr(), trigger); - return this; - } - - /// Returns the configured per-operation scan flush trigger. - /// - /// @return invisible entries per operation that trigger a flush, or `0` if disabled - public int getMemtableOpScanFlushTrigger() { - return NativeFields.getInt(MH_GET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER, ptr()); - } - - /// Like [#setMemtableOpScanFlushTrigger], but applied to the average number of invisible - /// entries scanned from the active memtable per `Next()` call between `Seek()`s (or until - /// the iterator is destroyed). Only takes effect once at least - /// [#setMemtableOpScanFlushTrigger] invisible entries have been scanned within the window, - /// so it is only effective when that option is also set. Should be set lower than - /// [#setMemtableOpScanFlushTrigger]. `0` disables the trigger. Default: 0. - /// - /// @param trigger average invisible entries per operation that triggers a flush, or `0` to disable - /// @return `this` for chaining - /// @throws IllegalArgumentException if `trigger` is negative - public Options setMemtableAvgOpScanFlushTrigger(int trigger) { - if (trigger < 0) { - throw new IllegalArgumentException("memtableAvgOpScanFlushTrigger must not be negative: " + trigger); - } - NativeFields.setInt(MH_SET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER, ptr(), trigger); - return this; - } - - /// Returns the configured average-per-operation scan flush trigger. - /// - /// @return average invisible entries per operation that trigger a flush, or `0` if disabled - public int getMemtableAvgOpScanFlushTrigger() { - return NativeFields.getInt(MH_GET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER, ptr()); - } + /// `Next()`) scans this many invisible entries (tombstones or hidden puts) from the active + /// memtable. Reduces the cost of scanning through a large number of dead entries in range-scan-heavy + /// workloads. Only forward scans are covered, and tailing iterators are not affected yet. + /// Consider enabling deletion-triggered compaction alongside this option, to compact away + /// tombstones once the memtable is flushed. `0` disables the trigger. Default: 0. + /// + /// @param trigger number of invisible entries per operation that triggers a flush, or `0` to disable + /// @return `this` for chaining + /// @throws IllegalArgumentException if `trigger` is negative + public Options setMemtableOpScanFlushTrigger(int trigger) { + if (trigger < 0) { + throw new IllegalArgumentException("memtableOpScanFlushTrigger must not be negative: " + trigger); + } + NativeFields.setInt(MH_SET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER, ptr(), trigger); + return this; + } + + /// Returns the configured per-operation scan flush trigger. + /// + /// @return invisible entries per operation that trigger a flush, or `0` if disabled + public int getMemtableOpScanFlushTrigger() { + return NativeFields.getInt(MH_GET_MEMTABLE_OP_SCAN_FLUSH_TRIGGER, ptr()); + } + + /// Like [#setMemtableOpScanFlushTrigger], but applied to the average number of invisible + /// entries scanned from the active memtable per `Next()` call between `Seek()`s (or until + /// the iterator is destroyed). Only takes effect once at least + /// [#setMemtableOpScanFlushTrigger] invisible entries have been scanned within the window, + /// so it is only effective when that option is also set. Should be set lower than + /// [#setMemtableOpScanFlushTrigger]. `0` disables the trigger. Default: 0. + /// + /// @param trigger average invisible entries per operation that triggers a flush, or `0` to disable + /// @return `this` for chaining + /// @throws IllegalArgumentException if `trigger` is negative + public Options setMemtableAvgOpScanFlushTrigger(int trigger) { + if (trigger < 0) { + throw new IllegalArgumentException("memtableAvgOpScanFlushTrigger must not be negative: " + trigger); + } + NativeFields.setInt(MH_SET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER, ptr(), trigger); + return this; + } + + /// Returns the configured average-per-operation scan flush trigger. + /// + /// @return average invisible entries per operation that trigger a flush, or `0` if disabled + public int getMemtableAvgOpScanFlushTrigger() { + return NativeFields.getInt(MH_GET_MEMTABLE_AVG_OP_SCAN_FLUSH_TRIGGER, ptr()); + } // ----------------------------------------------------------------------- // Memtable factory diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/PerfContext.java b/core/src/main/java/io/github/dfa1/rocksdbffm/PerfContext.java index f9c90806..fa3f416f 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/PerfContext.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/PerfContext.java @@ -46,41 +46,35 @@ public final class PerfContext extends NativeObject { /// `void rocksdb_set_perf_level(int);` - private static final MethodHandle MH_SET_PERF_LEVEL; + private static final MethodHandle MH_SET_PERF_LEVEL = NativeLibrary.downcall( + "rocksdb_set_perf_level", FunctionDescriptor.ofVoid(ValueLayout.JAVA_INT) + ); /// `rocksdb_perfcontext_t* rocksdb_perfcontext_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_perfcontext_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_perfcontext_reset(rocksdb_perfcontext_t* context);` - private static final MethodHandle MH_RESET; + private static final MethodHandle MH_RESET = NativeLibrary.downcall( + "rocksdb_perfcontext_reset", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `char* rocksdb_perfcontext_report(rocksdb_perfcontext_t* context, unsigned char exclude_zero_counters);` - private static final MethodHandle MH_REPORT; + private static final MethodHandle MH_REPORT = NativeLibrary.downcall( + "rocksdb_perfcontext_report", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // context + ValueLayout.JAVA_BYTE) // exclude_zero_counters + ); /// `uint64_t rocksdb_perfcontext_metric(rocksdb_perfcontext_t* context, int metric);` - private static final MethodHandle MH_METRIC; + private static final MethodHandle MH_METRIC = NativeLibrary.downcall( + "rocksdb_perfcontext_metric", + FunctionDescriptor.of(ValueLayout.JAVA_LONG, + ValueLayout.ADDRESS, // context + ValueLayout.JAVA_INT) // metric + ); /// `void rocksdb_perfcontext_destroy(rocksdb_perfcontext_t* context);` - private static final MethodHandle MH_DESTROY; - - static { - MH_SET_PERF_LEVEL = NativeLibrary.downcall("rocksdb_set_perf_level", - FunctionDescriptor.ofVoid(ValueLayout.JAVA_INT)); - - MH_CREATE = NativeLibrary.downcall("rocksdb_perfcontext_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_RESET = NativeLibrary.downcall("rocksdb_perfcontext_reset", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_REPORT = NativeLibrary.downcall("rocksdb_perfcontext_report", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // context - ValueLayout.JAVA_BYTE)); // exclude_zero_counters - - MH_METRIC = NativeLibrary.downcall("rocksdb_perfcontext_metric", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, - ValueLayout.ADDRESS, // context - ValueLayout.JAVA_INT)); // metric - - MH_DESTROY = NativeLibrary.downcall("rocksdb_perfcontext_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_perfcontext_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// The thread whose perf context this wraps; the native object is a view of that thread's `thread_local`. private final Thread owner = Thread.currentThread(); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableHandle.java b/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableHandle.java index 9378f9d9..09ded0ab 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableHandle.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableHandle.java @@ -21,22 +21,16 @@ /// owns every way a pinned value gets consumed. final class PinnableHandle extends NativeObject { + // get_value/destroy are pure in-memory pointer arithmetic — safe and worth + // marking critical(false) (no heap-array access) to skip transition overhead. /// `const char* rocksdb_pinnable_handle_get_value(const rocksdb_pinnable_handle_t* handle, size_t* vallen);` - private static final MethodHandle MH_GET_VALUE; + private static final MethodHandle MH_GET_VALUE = NativeLibrary.downcall( + "rocksdb_pinnable_handle_get_value", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS), Linker.Option.critical(false) + ); /// `void rocksdb_pinnable_handle_destroy(rocksdb_pinnable_handle_t* handle);` - private static final MethodHandle MH_DESTROY; - - static { - // get_value/destroy are pure in-memory pointer arithmetic — safe and worth - // marking critical(false) (no heap-array access) to skip transition overhead. - MH_GET_VALUE = NativeLibrary.downcall("rocksdb_pinnable_handle_get_value", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS), - Linker.Option.critical(false)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_pinnable_handle_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS), - Linker.Option.critical(false)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_pinnable_handle_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS), Linker.Option.critical(false) + ); private PinnableHandle(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableSlice.java b/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableSlice.java index 1be98539..0a93170a 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableSlice.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/PinnableSlice.java @@ -27,17 +27,13 @@ final class PinnableSlice extends NativeObject { /// `const char* rocksdb_pinnableslice_value(const rocksdb_pinnableslice_t* t, size_t* vlen);` - private static final MethodHandle MH_VALUE; + private static final MethodHandle MH_VALUE = NativeLibrary.downcall( + "rocksdb_pinnableslice_value", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_pinnableslice_destroy(rocksdb_pinnableslice_t* v);` - private static final MethodHandle MH_DESTROY; - - static { - MH_VALUE = NativeLibrary.downcall("rocksdb_pinnableslice_value", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_pinnableslice_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_pinnableslice_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private PinnableSlice(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RateLimiter.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RateLimiter.java index 608a0919..f6f30689 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RateLimiter.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RateLimiter.java @@ -41,38 +41,21 @@ public enum Mode { } /// `rocksdb_ratelimiter_t* rocksdb_ratelimiter_create(int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_ratelimiter_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT) + ); /// `rocksdb_ratelimiter_t* rocksdb_ratelimiter_create_auto_tuned(int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness);` - private static final MethodHandle MH_CREATE_AUTO_TUNED; + private static final MethodHandle MH_CREATE_AUTO_TUNED = NativeLibrary.downcall( + "rocksdb_ratelimiter_create_auto_tuned", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT) + ); /// `rocksdb_ratelimiter_t* rocksdb_ratelimiter_create_with_mode(int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness, int mode, bool auto_tuned);` - private static final MethodHandle MH_CREATE_WITH_MODE; + private static final MethodHandle MH_CREATE_WITH_MODE = NativeLibrary.downcall( + "rocksdb_ratelimiter_create_with_mode", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.JAVA_LONG, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_ratelimiter_destroy(rocksdb_ratelimiter_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_ratelimiter_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_INT)); - - MH_CREATE_AUTO_TUNED = NativeLibrary.downcall("rocksdb_ratelimiter_create_auto_tuned", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_INT)); - - MH_CREATE_WITH_MODE = NativeLibrary.downcall("rocksdb_ratelimiter_create_with_mode", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_LONG, - ValueLayout.JAVA_INT, - ValueLayout.JAVA_INT, - ValueLayout.JAVA_BYTE)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_ratelimiter_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_ratelimiter_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private RateLimiter(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/ReadBatch.java b/core/src/main/java/io/github/dfa1/rocksdbffm/ReadBatch.java index c9cbe368..ef9e68cb 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/ReadBatch.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/ReadBatch.java @@ -38,16 +38,9 @@ public final class ReadBatch implements AutoCloseable { /// `void rocksdb_batched_multi_get_cf(rocksdb_t* db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, size_t num_keys, const char* const* keys_list, const size_t* keys_list_sizes, rocksdb_pinnableslice_t** values, char** errs, const bool sorted_input);` - private static final MethodHandle MH_BATCHED_MULTI_GET_CF; - - static { - MH_BATCHED_MULTI_GET_CF = NativeLibrary.downcall("rocksdb_batched_multi_get_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_BOOLEAN)); - } + private static final MethodHandle MH_BATCHED_MULTI_GET_CF = NativeLibrary.downcall( + "rocksdb_batched_multi_get_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_BOOLEAN) + ); private final Arena arena; private final RocksDBReadOperations db; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/ReadOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/ReadOptions.java index e847e333..94a129c3 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/ReadOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/ReadOptions.java @@ -14,127 +14,101 @@ public final class ReadOptions extends NativeObjectWithChildren { /// `rocksdb_readoptions_t* rocksdb_readoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_readoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_destroy(rocksdb_readoptions_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_readoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_snapshot(rocksdb_readoptions_t*, const rocksdb_snapshot_t*);` - private static final MethodHandle MH_SET_SNAPSHOT; + private static final MethodHandle MH_SET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_readoptions_set_snapshot", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_verify_checksums(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_VERIFY_CHECKSUMS; + private static final MethodHandle MH_SET_VERIFY_CHECKSUMS = NativeLibrary.downcall( + "rocksdb_readoptions_set_verify_checksums", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_verify_checksums(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_VERIFY_CHECKSUMS; + private static final MethodHandle MH_GET_VERIFY_CHECKSUMS = NativeLibrary.downcall( + "rocksdb_readoptions_get_verify_checksums", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_fill_cache(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_FILL_CACHE; + private static final MethodHandle MH_SET_FILL_CACHE = NativeLibrary.downcall( + "rocksdb_readoptions_set_fill_cache", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_fill_cache(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_FILL_CACHE; + private static final MethodHandle MH_GET_FILL_CACHE = NativeLibrary.downcall( + "rocksdb_readoptions_get_fill_cache", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_pin_data(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_PIN_DATA; + private static final MethodHandle MH_SET_PIN_DATA = NativeLibrary.downcall( + "rocksdb_readoptions_set_pin_data", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_pin_data(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_PIN_DATA; + private static final MethodHandle MH_GET_PIN_DATA = NativeLibrary.downcall( + "rocksdb_readoptions_get_pin_data", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_tailing(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_TAILING; + private static final MethodHandle MH_SET_TAILING = NativeLibrary.downcall( + "rocksdb_readoptions_set_tailing", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_tailing(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_TAILING; + private static final MethodHandle MH_GET_TAILING = NativeLibrary.downcall( + "rocksdb_readoptions_get_tailing", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_total_order_seek(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_TOTAL_ORDER_SEEK; + private static final MethodHandle MH_SET_TOTAL_ORDER_SEEK = NativeLibrary.downcall( + "rocksdb_readoptions_set_total_order_seek", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_total_order_seek(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_TOTAL_ORDER_SEEK; + private static final MethodHandle MH_GET_TOTAL_ORDER_SEEK = NativeLibrary.downcall( + "rocksdb_readoptions_get_total_order_seek", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_auto_prefix_mode(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_AUTO_PREFIX_MODE; + private static final MethodHandle MH_SET_AUTO_PREFIX_MODE = NativeLibrary.downcall( + "rocksdb_readoptions_set_auto_prefix_mode", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_auto_prefix_mode(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_AUTO_PREFIX_MODE; + private static final MethodHandle MH_GET_AUTO_PREFIX_MODE = NativeLibrary.downcall( + "rocksdb_readoptions_get_auto_prefix_mode", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_prefix_same_as_start(rocksdb_readoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_PREFIX_SAME_AS_START; + private static final MethodHandle MH_SET_PREFIX_SAME_AS_START = NativeLibrary.downcall( + "rocksdb_readoptions_set_prefix_same_as_start", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_readoptions_get_prefix_same_as_start(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_PREFIX_SAME_AS_START; + private static final MethodHandle MH_GET_PREFIX_SAME_AS_START = NativeLibrary.downcall( + "rocksdb_readoptions_get_prefix_same_as_start", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_readahead_size(rocksdb_readoptions_t* opt, size_t v);` - private static final MethodHandle MH_SET_READAHEAD_SIZE; + private static final MethodHandle MH_SET_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_readoptions_set_readahead_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_readoptions_get_readahead_size(rocksdb_readoptions_t* opt);` - private static final MethodHandle MH_GET_READAHEAD_SIZE; + private static final MethodHandle MH_GET_READAHEAD_SIZE = NativeLibrary.downcall( + "rocksdb_readoptions_get_readahead_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_readoptions_set_iterate_lower_bound(rocksdb_readoptions_t*, const char* key, size_t keylen);` - private static final MethodHandle MH_SET_ITERATE_LOWER_BOUND; + private static final MethodHandle MH_SET_ITERATE_LOWER_BOUND = NativeLibrary.downcall( + "rocksdb_readoptions_set_iterate_lower_bound", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_readoptions_set_iterate_upper_bound(rocksdb_readoptions_t*, const char* key, size_t keylen);` - private static final MethodHandle MH_SET_ITERATE_UPPER_BOUND; + private static final MethodHandle MH_SET_ITERATE_UPPER_BOUND = NativeLibrary.downcall( + "rocksdb_readoptions_set_iterate_upper_bound", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_readoptions_set_request_id(rocksdb_readoptions_t*, const char* request_id, size_t request_id_len);` - private static final MethodHandle MH_SET_REQUEST_ID; + private static final MethodHandle MH_SET_REQUEST_ID = NativeLibrary.downcall( + "rocksdb_readoptions_set_request_id", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_readoptions_clear_request_id(rocksdb_readoptions_t*);` - private static final MethodHandle MH_CLEAR_REQUEST_ID; + private static final MethodHandle MH_CLEAR_REQUEST_ID = NativeLibrary.downcall( + "rocksdb_readoptions_clear_request_id", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `const char* rocksdb_readoptions_get_request_id(rocksdb_readoptions_t*, size_t* request_id_len);` - private static final MethodHandle MH_GET_REQUEST_ID; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_readoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_readoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SNAPSHOT = NativeLibrary.downcall("rocksdb_readoptions_set_snapshot", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_SET_VERIFY_CHECKSUMS = NativeLibrary.downcall("rocksdb_readoptions_set_verify_checksums", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_VERIFY_CHECKSUMS = NativeLibrary.downcall("rocksdb_readoptions_get_verify_checksums", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_FILL_CACHE = NativeLibrary.downcall("rocksdb_readoptions_set_fill_cache", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_FILL_CACHE = NativeLibrary.downcall("rocksdb_readoptions_get_fill_cache", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_PIN_DATA = NativeLibrary.downcall("rocksdb_readoptions_set_pin_data", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_PIN_DATA = NativeLibrary.downcall("rocksdb_readoptions_get_pin_data", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TAILING = NativeLibrary.downcall("rocksdb_readoptions_set_tailing", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_TAILING = NativeLibrary.downcall("rocksdb_readoptions_get_tailing", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TOTAL_ORDER_SEEK = NativeLibrary.downcall("rocksdb_readoptions_set_total_order_seek", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_TOTAL_ORDER_SEEK = NativeLibrary.downcall("rocksdb_readoptions_get_total_order_seek", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_AUTO_PREFIX_MODE = NativeLibrary.downcall("rocksdb_readoptions_set_auto_prefix_mode", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_AUTO_PREFIX_MODE = NativeLibrary.downcall("rocksdb_readoptions_get_auto_prefix_mode", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_PREFIX_SAME_AS_START = NativeLibrary.downcall("rocksdb_readoptions_set_prefix_same_as_start", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_PREFIX_SAME_AS_START = NativeLibrary.downcall("rocksdb_readoptions_get_prefix_same_as_start", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_READAHEAD_SIZE = NativeLibrary.downcall("rocksdb_readoptions_set_readahead_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_READAHEAD_SIZE = NativeLibrary.downcall("rocksdb_readoptions_get_readahead_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_ITERATE_LOWER_BOUND = NativeLibrary.downcall("rocksdb_readoptions_set_iterate_lower_bound", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_ITERATE_UPPER_BOUND = NativeLibrary.downcall("rocksdb_readoptions_set_iterate_upper_bound", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_REQUEST_ID = NativeLibrary.downcall("rocksdb_readoptions_set_request_id", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_CLEAR_REQUEST_ID = NativeLibrary.downcall("rocksdb_readoptions_clear_request_id", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_GET_REQUEST_ID = NativeLibrary.downcall("rocksdb_readoptions_get_request_id", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_REQUEST_ID = NativeLibrary.downcall( + "rocksdb_readoptions_get_request_id", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// RocksDB-default ReadOptions for the get/put overloads that take none; a native read/write call only reads /// the struct, so one instance serves every open DB. Immortal per [NativeObject#makeImmortal()]: diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/ReplayOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/ReplayOptions.java index 304b249e..a1781b18 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/ReplayOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/ReplayOptions.java @@ -20,37 +20,29 @@ public final class ReplayOptions extends NativeObject { /// `rocksdb_replay_options_t* rocksdb_replay_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_replay_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_replay_options_destroy(rocksdb_replay_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_replay_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_replay_options_set_num_threads(rocksdb_replay_options_t*, uint32_t);` - private static final MethodHandle MH_SET_NUM_THREADS; + private static final MethodHandle MH_SET_NUM_THREADS = NativeLibrary.downcall( + "rocksdb_replay_options_set_num_threads", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_replay_options_get_num_threads(rocksdb_replay_options_t*);` - private static final MethodHandle MH_GET_NUM_THREADS; + private static final MethodHandle MH_GET_NUM_THREADS = NativeLibrary.downcall( + "rocksdb_replay_options_get_num_threads", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_replay_options_set_fast_forward(rocksdb_replay_options_t*, double);` - private static final MethodHandle MH_SET_FAST_FORWARD; + private static final MethodHandle MH_SET_FAST_FORWARD = NativeLibrary.downcall( + "rocksdb_replay_options_set_fast_forward", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_replay_options_get_fast_forward(rocksdb_replay_options_t*);` - private static final MethodHandle MH_GET_FAST_FORWARD; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_replay_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_replay_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_NUM_THREADS = NativeLibrary.downcall("rocksdb_replay_options_set_num_threads", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_NUM_THREADS = NativeLibrary.downcall("rocksdb_replay_options_get_num_threads", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_FAST_FORWARD = NativeLibrary.downcall("rocksdb_replay_options_set_fast_forward", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_FAST_FORWARD = NativeLibrary.downcall("rocksdb_replay_options_get_fast_forward", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_FAST_FORWARD = NativeLibrary.downcall( + "rocksdb_replay_options_get_fast_forward", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); private ReplayOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Replayer.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Replayer.java index f4148149..7c2baae3 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Replayer.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Replayer.java @@ -29,39 +29,33 @@ public final class Replayer extends NativeObject { /// `rocksdb_replayer_t* rocksdb_new_default_replayer(rocksdb_t* db, rocksdb_column_family_handle_t** column_families, size_t num_column_families, rocksdb_env_t* env, const rocksdb_envoptions_t* env_options, const char* trace_path, char** errptr);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_new_default_replayer", + FunctionDescriptor.of(ValueLayout.ADDRESS, + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // column_families + NativeCalls.SIZE_T, // num_column_families + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS, // env_options + ValueLayout.ADDRESS, // trace_path + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_replayer_prepare(rocksdb_replayer_t*, char** errptr);` - private static final MethodHandle MH_PREPARE; + private static final MethodHandle MH_PREPARE = NativeLibrary.downcall( + "rocksdb_replayer_prepare", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_replayer_get_header_timestamp(const rocksdb_replayer_t*);` - private static final MethodHandle MH_GET_HEADER_TIMESTAMP; + private static final MethodHandle MH_GET_HEADER_TIMESTAMP = NativeLibrary.downcall( + "rocksdb_replayer_get_header_timestamp", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_replayer_replay(rocksdb_replayer_t*, const rocksdb_replay_options_t*, char** errptr);` - private static final MethodHandle MH_REPLAY; + private static final MethodHandle MH_REPLAY = NativeLibrary.downcall( + "rocksdb_replayer_replay", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_replayer_destroy(rocksdb_replayer_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_new_default_replayer", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // column_families - NativeCalls.SIZE_T, // num_column_families - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS, // env_options - ValueLayout.ADDRESS, // trace_path - ValueLayout.ADDRESS)); // errptr - - MH_PREPARE = NativeLibrary.downcall("rocksdb_replayer_prepare", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_GET_HEADER_TIMESTAMP = NativeLibrary.downcall("rocksdb_replayer_get_header_timestamp", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_REPLAY = NativeLibrary.downcall("rocksdb_replayer_replay", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_replayer_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_replayer_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// The column families this replayer replays into. The native replayer keeps raw pointers to their handles, which /// [NativeDB#forget(ColumnFamilyHandle)] frees when one is dropped. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RestoreOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RestoreOptions.java index 1447fe7d..94787422 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RestoreOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RestoreOptions.java @@ -18,22 +18,17 @@ public final class RestoreOptions extends NativeObject { /// `rocksdb_restore_options_t* rocksdb_restore_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_restore_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_restore_options_destroy(rocksdb_restore_options_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_restore_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_restore_options_set_keep_log_files(rocksdb_restore_options_t* opt, int v);` - private static final MethodHandle MH_SET_KEEP_LOG_FILES; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_restore_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_restore_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_KEEP_LOG_FILES = NativeLibrary.downcall("rocksdb_restore_options_set_keep_log_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - } + private static final MethodHandle MH_SET_KEEP_LOG_FILES = NativeLibrary.downcall( + "rocksdb_restore_options_set_keep_log_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); private RestoreOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDB.java index 1f7d51f8..0ae6557e 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDB.java @@ -42,142 +42,82 @@ public final class RocksDB { // ----------------------------------------------------------------------- /// `rocksdb_t* rocksdb_open(const rocksdb_options_t* options, const char* name, char** errptr);` - private static final MethodHandle MH_OPEN; + private static final MethodHandle MH_OPEN = NativeLibrary.downcall( + "rocksdb_open", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_open_with_ttl(const rocksdb_options_t* options, const char* name, int ttl, char** errptr);` - private static final MethodHandle MH_OPEN_WITH_TTL; + private static final MethodHandle MH_OPEN_WITH_TTL = NativeLibrary.downcall( + "rocksdb_open_with_ttl", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_open_for_read_only(const rocksdb_options_t* options, const char* name, unsigned char error_if_wal_file_exists, char** errptr);` - private static final MethodHandle MH_OPEN_FOR_READ_ONLY; + private static final MethodHandle MH_OPEN_FOR_READ_ONLY = NativeLibrary.downcall( + "rocksdb_open_for_read_only", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_open_as_secondary(const rocksdb_options_t* options, const char* name, const char* secondary_path, char** errptr);` - private static final MethodHandle MH_OPEN_SECONDARY; + private static final MethodHandle MH_OPEN_SECONDARY = NativeLibrary.downcall( + "rocksdb_open_as_secondary", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_transactiondb_t* rocksdb_transactiondb_open(const rocksdb_options_t* options, const rocksdb_transactiondb_options_t* txn_db_options, const char* name, char** errptr);` - private static final MethodHandle MH_OPEN_TRANSACTION; + private static final MethodHandle MH_OPEN_TRANSACTION = NativeLibrary.downcall( + "rocksdb_transactiondb_open", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_optimistictransactiondb_t* rocksdb_optimistictransactiondb_open(const rocksdb_options_t* options, const char* name, char** errptr);` - private static final MethodHandle MH_OPEN_OPTIMISTIC; + private static final MethodHandle MH_OPEN_OPTIMISTIC = NativeLibrary.downcall( + "rocksdb_optimistictransactiondb_open", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_optimistictransactiondb_get_base_db(rocksdb_optimistictransactiondb_t* otxn_db);` - private static final MethodHandle MH_OPTIMISTIC_GET_BASE_DB; + private static final MethodHandle MH_OPTIMISTIC_GET_BASE_DB = NativeLibrary.downcall( + "rocksdb_optimistictransactiondb_get_base_db", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); // ----------------------------------------------------------------------- // Column-family open/list method handles — used only inside factory methods // ----------------------------------------------------------------------- /// `rocksdb_t* rocksdb_open_column_families(const rocksdb_options_t* options, const char* name, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, char** errptr);` - private static final MethodHandle MH_OPEN_CF; + private static final MethodHandle MH_OPEN_CF = NativeLibrary.downcall( + "rocksdb_open_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `char** rocksdb_list_column_families(const rocksdb_options_t* options, const char* name, size_t* lencf, char** errptr);` - private static final MethodHandle MH_LIST_CF; + private static final MethodHandle MH_LIST_CF = NativeLibrary.downcall( + "rocksdb_list_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_list_column_families_destroy(char** list, size_t len);` - private static final MethodHandle MH_LIST_CF_DESTROY; + private static final MethodHandle MH_LIST_CF_DESTROY = NativeLibrary.downcall( + "rocksdb_list_column_families_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_load_latest_options(const char* db_path, rocksdb_env_t* env, bool ignore_unknown_options, rocksdb_cache_t* cache, rocksdb_options_t** db_options, size_t* num_column_families, char*** column_family_names, rocksdb_options_t*** column_family_options, char** errptr);` - private static final MethodHandle MH_LOAD_LATEST_OPTIONS; + private static final MethodHandle MH_LOAD_LATEST_OPTIONS = NativeLibrary.downcall( + "rocksdb_load_latest_options", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_BOOLEAN, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_load_latest_options_destroy(rocksdb_options_t* db_options, char** list_column_family_names, rocksdb_options_t** list_column_family_options, size_t len);` - private static final MethodHandle MH_LOAD_LATEST_OPTIONS_DESTROY; + private static final MethodHandle MH_LOAD_LATEST_OPTIONS_DESTROY = NativeLibrary.downcall( + "rocksdb_load_latest_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `rocksdb_t* rocksdb_open_for_read_only_column_families(const rocksdb_options_t* options, const char* name, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, unsigned char error_if_wal_file_exists, char** errptr);` - private static final MethodHandle MH_OPEN_FOR_READ_ONLY_CF; + private static final MethodHandle MH_OPEN_FOR_READ_ONLY_CF = NativeLibrary.downcall( + "rocksdb_open_for_read_only_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_open_as_secondary_column_families(const rocksdb_options_t* options, const char* name, const char* secondary_path, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, char** errptr);` - private static final MethodHandle MH_OPEN_SECONDARY_CF; + private static final MethodHandle MH_OPEN_SECONDARY_CF = NativeLibrary.downcall( + "rocksdb_open_as_secondary_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_open_column_families_with_ttl(const rocksdb_options_t* options, const char* name, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, const int* ttls, char** errptr);` - private static final MethodHandle MH_OPEN_CF_WITH_TTL; + private static final MethodHandle MH_OPEN_CF_WITH_TTL = NativeLibrary.downcall( + "rocksdb_open_column_families_with_ttl", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_transactiondb_t* rocksdb_transactiondb_open_column_families(const rocksdb_options_t* options, const rocksdb_transactiondb_options_t* txn_db_options, const char* name, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, char** errptr);` - private static final MethodHandle MH_OPEN_TRANSACTION_CF; + private static final MethodHandle MH_OPEN_TRANSACTION_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_open_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_optimistictransactiondb_t* rocksdb_optimistictransactiondb_open_column_families(const rocksdb_options_t* options, const char* name, int num_column_families, const char* const* column_family_names, const rocksdb_options_t* const* column_family_options, rocksdb_column_family_handle_t** column_family_handles, char** errptr);` - private static final MethodHandle MH_OPEN_OPTIMISTIC_CF; + private static final MethodHandle MH_OPEN_OPTIMISTIC_CF = NativeLibrary.downcall( + "rocksdb_optimistictransactiondb_open_column_families", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_t* rocksdb_transactiondb_get_base_db(rocksdb_transactiondb_t* txn_db);` - private static final MethodHandle MH_TRANSACTION_GET_BASE_DB; - - static { - MH_OPEN = NativeLibrary.downcall("rocksdb_open", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_WITH_TTL = NativeLibrary.downcall("rocksdb_open_with_ttl", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_OPEN_FOR_READ_ONLY = NativeLibrary.downcall("rocksdb_open_for_read_only", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_OPEN_SECONDARY = NativeLibrary.downcall("rocksdb_open_as_secondary", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_TRANSACTION = NativeLibrary.downcall("rocksdb_transactiondb_open", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_OPTIMISTIC = NativeLibrary.downcall("rocksdb_optimistictransactiondb_open", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPTIMISTIC_GET_BASE_DB = NativeLibrary.downcall("rocksdb_optimistictransactiondb_get_base_db", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_CF = NativeLibrary.downcall("rocksdb_open_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_LIST_CF = NativeLibrary.downcall("rocksdb_list_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_LIST_CF_DESTROY = NativeLibrary.downcall("rocksdb_list_column_families_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_LOAD_LATEST_OPTIONS = NativeLibrary.downcall("rocksdb_load_latest_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_BOOLEAN, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_LOAD_LATEST_OPTIONS_DESTROY = NativeLibrary.downcall("rocksdb_load_latest_options_destroy", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_OPEN_FOR_READ_ONLY_CF = NativeLibrary.downcall("rocksdb_open_for_read_only_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_OPEN_SECONDARY_CF = NativeLibrary.downcall("rocksdb_open_as_secondary_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_CF_WITH_TTL = NativeLibrary.downcall("rocksdb_open_column_families_with_ttl", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_TRANSACTION_CF = NativeLibrary.downcall("rocksdb_transactiondb_open_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_OPEN_OPTIMISTIC_CF = NativeLibrary.downcall("rocksdb_optimistictransactiondb_open_column_families", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_TRANSACTION_GET_BASE_DB = NativeLibrary.downcall("rocksdb_transactiondb_get_base_db", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_TRANSACTION_GET_BASE_DB = NativeLibrary.downcall( + "rocksdb_transactiondb_get_base_db", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDB() { // no instances diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBCompactionOperationsBindings.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBCompactionOperationsBindings.java index 97fbf121..40ada81f 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBCompactionOperationsBindings.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBCompactionOperationsBindings.java @@ -13,65 +13,41 @@ final class RocksDBCompactionOperationsBindings { /// `void rocksdb_compact_range(rocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len);` - private static final MethodHandle MH_COMPACT_RANGE; + private static final MethodHandle MH_COMPACT_RANGE = NativeLibrary.downcall( + "rocksdb_compact_range", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_compact_range_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len);` - private static final MethodHandle MH_COMPACT_RANGE_CF; + private static final MethodHandle MH_COMPACT_RANGE_CF = NativeLibrary.downcall( + "rocksdb_compact_range_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_compact_range_opt(rocksdb_t* db, rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len);` - private static final MethodHandle MH_COMPACT_RANGE_OPT; + private static final MethodHandle MH_COMPACT_RANGE_OPT = NativeLibrary.downcall( + "rocksdb_compact_range_opt", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_suggest_compact_range(rocksdb_t* db, const char* start_key, size_t start_key_len, const char* limit_key, size_t limit_key_len, char** errptr);` - private static final MethodHandle MH_SUGGEST_COMPACT_RANGE; + private static final MethodHandle MH_SUGGEST_COMPACT_RANGE = NativeLibrary.downcall( + "rocksdb_suggest_compact_range", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_disable_file_deletions(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_DISABLE_FILE_DELETIONS; + private static final MethodHandle MH_DISABLE_FILE_DELETIONS = NativeLibrary.downcall( + "rocksdb_disable_file_deletions", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_enable_file_deletions(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_ENABLE_FILE_DELETIONS; + private static final MethodHandle MH_ENABLE_FILE_DELETIONS = NativeLibrary.downcall( + "rocksdb_enable_file_deletions", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_disable_manual_compaction(rocksdb_t* db);` - private static final MethodHandle MH_DISABLE_MANUAL_COMPACTION; + private static final MethodHandle MH_DISABLE_MANUAL_COMPACTION = NativeLibrary.downcall( + "rocksdb_disable_manual_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_enable_manual_compaction(rocksdb_t* db);` - private static final MethodHandle MH_ENABLE_MANUAL_COMPACTION; + private static final MethodHandle MH_ENABLE_MANUAL_COMPACTION = NativeLibrary.downcall( + "rocksdb_enable_manual_compaction", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact(rocksdb_t* db, rocksdb_wait_for_compact_options_t* options, char** errptr);` - private static final MethodHandle MH_WAIT_FOR_COMPACT; - - static { - MH_COMPACT_RANGE = NativeLibrary.downcall("rocksdb_compact_range", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_COMPACT_RANGE_CF = NativeLibrary.downcall("rocksdb_compact_range_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_COMPACT_RANGE_OPT = NativeLibrary.downcall("rocksdb_compact_range_opt", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SUGGEST_COMPACT_RANGE = NativeLibrary.downcall("rocksdb_suggest_compact_range", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DISABLE_FILE_DELETIONS = NativeLibrary.downcall("rocksdb_disable_file_deletions", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_ENABLE_FILE_DELETIONS = NativeLibrary.downcall("rocksdb_enable_file_deletions", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DISABLE_MANUAL_COMPACTION = NativeLibrary.downcall("rocksdb_disable_manual_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_ENABLE_MANUAL_COMPACTION = NativeLibrary.downcall("rocksdb_enable_manual_compaction", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_WAIT_FOR_COMPACT = NativeLibrary.downcall("rocksdb_wait_for_compact", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_WAIT_FOR_COMPACT = NativeLibrary.downcall( + "rocksdb_wait_for_compact", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDBCompactionOperationsBindings() { } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBMonitoringOperationsBindings.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBMonitoringOperationsBindings.java index a3871796..a62bf48a 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBMonitoringOperationsBindings.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBMonitoringOperationsBindings.java @@ -15,92 +15,80 @@ final class RocksDBMonitoringOperationsBindings { /// `void rocksdb_approximate_sizes(rocksdb_t* db, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes, char** errptr);` - private static final MethodHandle MH_APPROXIMATE_SIZES; + private static final MethodHandle MH_APPROXIMATE_SIZES = NativeLibrary.downcall( + "rocksdb_approximate_sizes", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.JAVA_INT, // num_ranges + ValueLayout.ADDRESS, // range_start_key + ValueLayout.ADDRESS, // range_start_key_len + ValueLayout.ADDRESS, // range_limit_key + ValueLayout.ADDRESS, // range_limit_key_len + ValueLayout.ADDRESS, // sizes + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_approximate_sizes_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes, char** errptr);` - private static final MethodHandle MH_APPROXIMATE_SIZES_CF; + private static final MethodHandle MH_APPROXIMATE_SIZES_CF = NativeLibrary.downcall( + "rocksdb_approximate_sizes_cf", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // column_family + ValueLayout.JAVA_INT, // num_ranges + ValueLayout.ADDRESS, // range_start_key + ValueLayout.ADDRESS, // range_start_key_len + ValueLayout.ADDRESS, // range_limit_key + ValueLayout.ADDRESS, // range_limit_key_len + ValueLayout.ADDRESS, // sizes + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_approximate_sizes_with_options(rocksdb_t* db, const rocksdb_size_approximation_options_t* options, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes, char** errptr);` - private static final MethodHandle MH_APPROXIMATE_SIZES_WITH_OPTIONS; + private static final MethodHandle MH_APPROXIMATE_SIZES_WITH_OPTIONS = NativeLibrary.downcall( + "rocksdb_approximate_sizes_with_options", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // options + ValueLayout.JAVA_INT, // num_ranges + ValueLayout.ADDRESS, // range_start_key + ValueLayout.ADDRESS, // range_start_key_len + ValueLayout.ADDRESS, // range_limit_key + ValueLayout.ADDRESS, // range_limit_key_len + ValueLayout.ADDRESS, // sizes + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_approximate_sizes_cf_with_options(rocksdb_t* db, rocksdb_column_family_handle_t* column_family, const rocksdb_size_approximation_options_t* options, int num_ranges, const char* const* range_start_key, const size_t* range_start_key_len, const char* const* range_limit_key, const size_t* range_limit_key_len, uint64_t* sizes, char** errptr);` - private static final MethodHandle MH_APPROXIMATE_SIZES_CF_WITH_OPTIONS; - /// `void rocksdb_verify_checksum(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_VERIFY_CHECKSUM; - - /// `void rocksdb_verify_checksum_with_options(rocksdb_t* db, const rocksdb_readoptions_t* options, char** errptr);` - private static final MethodHandle MH_VERIFY_CHECKSUM_WITH_OPTIONS; - - /// `void rocksdb_verify_file_checksums(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_VERIFY_FILE_CHECKSUMS; - - /// `void rocksdb_verify_file_checksums_with_options(rocksdb_t* db, const rocksdb_readoptions_t* options, char** errptr);` - private static final MethodHandle MH_VERIFY_FILE_CHECKSUMS_WITH_OPTIONS; - - static { - MH_APPROXIMATE_SIZES = NativeLibrary.downcall("rocksdb_approximate_sizes", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.JAVA_INT, // num_ranges - ValueLayout.ADDRESS, // range_start_key - ValueLayout.ADDRESS, // range_start_key_len - ValueLayout.ADDRESS, // range_limit_key - ValueLayout.ADDRESS, // range_limit_key_len - ValueLayout.ADDRESS, // sizes - ValueLayout.ADDRESS)); // errptr - - MH_APPROXIMATE_SIZES_CF = NativeLibrary.downcall("rocksdb_approximate_sizes_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // column_family - ValueLayout.JAVA_INT, // num_ranges - ValueLayout.ADDRESS, // range_start_key - ValueLayout.ADDRESS, // range_start_key_len - ValueLayout.ADDRESS, // range_limit_key - ValueLayout.ADDRESS, // range_limit_key_len - ValueLayout.ADDRESS, // sizes - ValueLayout.ADDRESS)); // errptr - - MH_APPROXIMATE_SIZES_WITH_OPTIONS = NativeLibrary.downcall("rocksdb_approximate_sizes_with_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // options - ValueLayout.JAVA_INT, // num_ranges - ValueLayout.ADDRESS, // range_start_key - ValueLayout.ADDRESS, // range_start_key_len - ValueLayout.ADDRESS, // range_limit_key - ValueLayout.ADDRESS, // range_limit_key_len - ValueLayout.ADDRESS, // sizes - ValueLayout.ADDRESS)); // errptr - - MH_APPROXIMATE_SIZES_CF_WITH_OPTIONS = NativeLibrary.downcall("rocksdb_approximate_sizes_cf_with_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // column_family - ValueLayout.ADDRESS, // options - ValueLayout.JAVA_INT, // num_ranges - ValueLayout.ADDRESS, // range_start_key - ValueLayout.ADDRESS, // range_start_key_len - ValueLayout.ADDRESS, // range_limit_key - ValueLayout.ADDRESS, // range_limit_key_len - ValueLayout.ADDRESS, // sizes - ValueLayout.ADDRESS)); // errptr - - MH_VERIFY_CHECKSUM = NativeLibrary.downcall( - "rocksdb_verify_checksum", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_VERIFY_CHECKSUM_WITH_OPTIONS = NativeLibrary.downcall( - "rocksdb_verify_checksum_with_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_VERIFY_FILE_CHECKSUMS = NativeLibrary.downcall( - "rocksdb_verify_file_checksums", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_VERIFY_FILE_CHECKSUMS_WITH_OPTIONS = NativeLibrary.downcall( - "rocksdb_verify_file_checksums_with_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_APPROXIMATE_SIZES_CF_WITH_OPTIONS = NativeLibrary.downcall( + "rocksdb_approximate_sizes_cf_with_options", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // column_family + ValueLayout.ADDRESS, // options + ValueLayout.JAVA_INT, // num_ranges + ValueLayout.ADDRESS, // range_start_key + ValueLayout.ADDRESS, // range_start_key_len + ValueLayout.ADDRESS, // range_limit_key + ValueLayout.ADDRESS, // range_limit_key_len + ValueLayout.ADDRESS, // sizes + ValueLayout.ADDRESS) // errptr + ); + /// `void rocksdb_verify_checksum(rocksdb_t* db, char** errptr);` + private static final MethodHandle MH_VERIFY_CHECKSUM = NativeLibrary.downcall( + "rocksdb_verify_checksum", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); + + /// `void rocksdb_verify_checksum_with_options(rocksdb_t* db, const rocksdb_readoptions_t* options, char** errptr);` + private static final MethodHandle MH_VERIFY_CHECKSUM_WITH_OPTIONS = NativeLibrary.downcall( + "rocksdb_verify_checksum_with_options", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); + + /// `void rocksdb_verify_file_checksums(rocksdb_t* db, char** errptr);` + private static final MethodHandle MH_VERIFY_FILE_CHECKSUMS = NativeLibrary.downcall( + "rocksdb_verify_file_checksums", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); + + /// `void rocksdb_verify_file_checksums_with_options(rocksdb_t* db, const rocksdb_readoptions_t* options, char** errptr);` + private static final MethodHandle MH_VERIFY_FILE_CHECKSUMS_WITH_OPTIONS = NativeLibrary.downcall( + "rocksdb_verify_file_checksums_with_options", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDBMonitoringOperationsBindings() { } @@ -184,43 +172,43 @@ static long[] approximateSizesCfWithOptions(MemorySegment db, ColumnFamilyHandle throw NativeCalls.wrapInvokeFailure("getApproximateSizes failed", t); } } - static void verifyChecksum(MemorySegment db) { - try (Arena arena = Arena.ofConfined()) { - MemorySegment err = NativeCalls.errHolder(arena); - MH_VERIFY_CHECKSUM.invokeExact(db, err); - NativeCalls.checkError(err); - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("verifyChecksum failed", t); - } - } - - static void verifyChecksum(MemorySegment db, ReadOptions options) { - try (Arena arena = Arena.ofConfined()) { - MemorySegment err = NativeCalls.errHolder(arena); - MH_VERIFY_CHECKSUM_WITH_OPTIONS.invokeExact(db, options.readPtr(), err); - NativeCalls.checkError(err); - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("verifyChecksum failed", t); - } - } - - static void verifyFileChecksums(MemorySegment db) { - try (Arena arena = Arena.ofConfined()) { - MemorySegment err = NativeCalls.errHolder(arena); - MH_VERIFY_FILE_CHECKSUMS.invokeExact(db, err); - NativeCalls.checkError(err); - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("verifyFileChecksums failed", t); - } - } - - static void verifyFileChecksums(MemorySegment db, ReadOptions options) { - try (Arena arena = Arena.ofConfined()) { - MemorySegment err = NativeCalls.errHolder(arena); - MH_VERIFY_FILE_CHECKSUMS_WITH_OPTIONS.invokeExact(db, options.readPtr(), err); - NativeCalls.checkError(err); - } catch (Throwable t) { - throw NativeCalls.wrapInvokeFailure("verifyFileChecksums failed", t); - } - } + static void verifyChecksum(MemorySegment db) { + try (Arena arena = Arena.ofConfined()) { + MemorySegment err = NativeCalls.errHolder(arena); + MH_VERIFY_CHECKSUM.invokeExact(db, err); + NativeCalls.checkError(err); + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("verifyChecksum failed", t); + } + } + + static void verifyChecksum(MemorySegment db, ReadOptions options) { + try (Arena arena = Arena.ofConfined()) { + MemorySegment err = NativeCalls.errHolder(arena); + MH_VERIFY_CHECKSUM_WITH_OPTIONS.invokeExact(db, options.readPtr(), err); + NativeCalls.checkError(err); + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("verifyChecksum failed", t); + } + } + + static void verifyFileChecksums(MemorySegment db) { + try (Arena arena = Arena.ofConfined()) { + MemorySegment err = NativeCalls.errHolder(arena); + MH_VERIFY_FILE_CHECKSUMS.invokeExact(db, err); + NativeCalls.checkError(err); + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("verifyFileChecksums failed", t); + } + } + + static void verifyFileChecksums(MemorySegment db, ReadOptions options) { + try (Arena arena = Arena.ofConfined()) { + MemorySegment err = NativeCalls.errHolder(arena); + MH_VERIFY_FILE_CHECKSUMS_WITH_OPTIONS.invokeExact(db, options.readPtr(), err); + NativeCalls.checkError(err); + } catch (Throwable t) { + throw NativeCalls.wrapInvokeFailure("verifyFileChecksums failed", t); + } + } } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBReadOperationsBindings.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBReadOperationsBindings.java index 7d4f849c..5f836768 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBReadOperationsBindings.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBReadOperationsBindings.java @@ -17,101 +17,56 @@ /// [#131](https://github.com/dfa1/rocksdb-ffm/issues/131). final class RocksDBReadOperationsBindings { + // get_pinned_*_v2 can block on disk I/O (a Get), so it must NOT be marked + // critical: a critical downcall stalls GC for its entire duration. /// `rocksdb_pinnable_handle_t* rocksdb_get_pinned_v2(rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_GET_PINNED_V2; + private static final MethodHandle MH_GET_PINNED_V2 = NativeLibrary.downcall( + "rocksdb_get_pinned_v2", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnable_handle_t* rocksdb_get_pinned_cf_v2(rocksdb_t* db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_GET_PINNED_CF_V2; + private static final MethodHandle MH_GET_PINNED_CF_V2 = NativeLibrary.downcall( + "rocksdb_get_pinned_cf_v2", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_get_into_buffer(rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, size_t keylen, char* buffer, size_t buffer_size, size_t* vallen, unsigned char* found, char** errptr);` - private static final MethodHandle MH_GET_INTO_BUFFER; + private static final MethodHandle MH_GET_INTO_BUFFER = NativeLibrary.downcall( + "rocksdb_get_into_buffer", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_get_into_buffer_cf(rocksdb_t* db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, char* buffer, size_t buffer_size, size_t* vallen, unsigned char* found, char** errptr);` - private static final MethodHandle MH_GET_INTO_BUFFER_CF; + private static final MethodHandle MH_GET_INTO_BUFFER_CF = NativeLibrary.downcall( + "rocksdb_get_into_buffer_cf", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_key_may_exist(rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, size_t key_len, char** value, size_t* val_len, const char* timestamp, size_t timestamp_len, unsigned char* value_found);` - private static final MethodHandle MH_KEY_MAY_EXIST; + private static final MethodHandle MH_KEY_MAY_EXIST = NativeLibrary.downcall( + "rocksdb_key_may_exist", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_key_may_exist_cf(rocksdb_t* db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t key_len, char** value, size_t* val_len, const char* timestamp, size_t timestamp_len, unsigned char* value_found);` - private static final MethodHandle MH_KEY_MAY_EXIST_CF; + private static final MethodHandle MH_KEY_MAY_EXIST_CF = NativeLibrary.downcall( + "rocksdb_key_may_exist_cf", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_iterator_t* rocksdb_create_iterator_cf(rocksdb_t* db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family);` - private static final MethodHandle MH_CREATE_ITERATOR_CF; + private static final MethodHandle MH_CREATE_ITERATOR_CF = NativeLibrary.downcall( + "rocksdb_create_iterator_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const rocksdb_snapshot_t* rocksdb_create_snapshot(rocksdb_t* db);` - private static final MethodHandle MH_CREATE_SNAPSHOT; + private static final MethodHandle MH_CREATE_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_create_snapshot", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `char* rocksdb_property_value(rocksdb_t* db, const char* propname);` - private static final MethodHandle MH_PROPERTY_VALUE; + private static final MethodHandle MH_PROPERTY_VALUE = NativeLibrary.downcall( + "rocksdb_property_value", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `int rocksdb_property_int(rocksdb_t* db, const char* propname, uint64_t* out_val);` - private static final MethodHandle MH_PROPERTY_INT; + private static final MethodHandle MH_PROPERTY_INT = NativeLibrary.downcall( + "rocksdb_property_int", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `char* rocksdb_property_value_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family, const char* propname);` - private static final MethodHandle MH_PROPERTY_VALUE_CF; + private static final MethodHandle MH_PROPERTY_VALUE_CF = NativeLibrary.downcall( + "rocksdb_property_value_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `int rocksdb_property_int_cf(rocksdb_t* db, rocksdb_column_family_handle_t* column_family, const char* propname, uint64_t* out_val);` - private static final MethodHandle MH_PROPERTY_INT_CF; - - static { - // get_pinned_*_v2 can block on disk I/O (a Get), so it must NOT be marked - // critical: a critical downcall stalls GC for its entire duration. - MH_GET_PINNED_V2 =NativeLibrary.downcall("rocksdb_get_pinned_v2", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED_CF_V2 = NativeLibrary.downcall("rocksdb_get_pinned_cf_v2", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_INTO_BUFFER = NativeLibrary.downcall("rocksdb_get_into_buffer", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS)); - - MH_GET_INTO_BUFFER_CF = NativeLibrary.downcall("rocksdb_get_into_buffer_cf", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS)); - - MH_KEY_MAY_EXIST = NativeLibrary.downcall("rocksdb_key_may_exist", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_KEY_MAY_EXIST_CF = NativeLibrary.downcall("rocksdb_key_may_exist_cf", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_CREATE_ITERATOR_CF = NativeLibrary.downcall("rocksdb_create_iterator_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_CREATE_SNAPSHOT = NativeLibrary.downcall("rocksdb_create_snapshot", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PROPERTY_VALUE = NativeLibrary.downcall("rocksdb_property_value", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PROPERTY_INT = NativeLibrary.downcall("rocksdb_property_int", - FunctionDescriptor.of(ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PROPERTY_VALUE_CF = NativeLibrary.downcall("rocksdb_property_value_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PROPERTY_INT_CF = NativeLibrary.downcall("rocksdb_property_int_cf", - FunctionDescriptor.of(ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_PROPERTY_INT_CF = NativeLibrary.downcall( + "rocksdb_property_int_cf", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDBReadOperationsBindings() { } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBTracingOperationsBindings.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBTracingOperationsBindings.java index 59507031..d85fe247 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBTracingOperationsBindings.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBTracingOperationsBindings.java @@ -17,68 +17,62 @@ final class RocksDBTracingOperationsBindings { /// `void rocksdb_start_trace(rocksdb_t* db, rocksdb_env_t* env, const rocksdb_envoptions_t* env_options, const rocksdb_trace_options_t* options, const char* trace_path, char** errptr);` - private static final MethodHandle MH_START_TRACE; + private static final MethodHandle MH_START_TRACE = NativeLibrary.downcall( + "rocksdb_start_trace", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS, // env_options + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // trace_path + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_end_trace(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_END_TRACE; + private static final MethodHandle MH_END_TRACE = NativeLibrary.downcall( + "rocksdb_end_trace", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_start_io_trace(rocksdb_t* db, rocksdb_env_t* env, const rocksdb_envoptions_t* env_options, const rocksdb_trace_options_t* options, const char* trace_path, char** errptr);` - private static final MethodHandle MH_START_IO_TRACE; + private static final MethodHandle MH_START_IO_TRACE = NativeLibrary.downcall( + "rocksdb_start_io_trace", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS, // env_options + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // trace_path + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_end_io_trace(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_END_IO_TRACE; + private static final MethodHandle MH_END_IO_TRACE = NativeLibrary.downcall( + "rocksdb_end_io_trace", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_start_block_cache_trace(rocksdb_t* db, rocksdb_env_t* env, const rocksdb_envoptions_t* env_options, const rocksdb_trace_options_t* options, const char* trace_path, char** errptr);` - private static final MethodHandle MH_START_BLOCK_CACHE_TRACE; + private static final MethodHandle MH_START_BLOCK_CACHE_TRACE = NativeLibrary.downcall( + "rocksdb_start_block_cache_trace", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS, // env_options + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // trace_path + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_start_block_cache_trace_with_options(rocksdb_t* db, rocksdb_env_t* env, const rocksdb_envoptions_t* env_options, const rocksdb_block_cache_trace_options_t* options, const rocksdb_block_cache_trace_writer_options_t* writer_options, const char* trace_path, char** errptr);` - private static final MethodHandle MH_START_BLOCK_CACHE_TRACE_WITH_OPTIONS; + private static final MethodHandle MH_START_BLOCK_CACHE_TRACE_WITH_OPTIONS = NativeLibrary.downcall( + "rocksdb_start_block_cache_trace_with_options", + FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, // db + ValueLayout.ADDRESS, // env + ValueLayout.ADDRESS, // env_options + ValueLayout.ADDRESS, // options + ValueLayout.ADDRESS, // writer_options + ValueLayout.ADDRESS, // trace_path + ValueLayout.ADDRESS) // errptr + ); /// `void rocksdb_end_block_cache_trace(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_END_BLOCK_CACHE_TRACE; - - static { - MH_START_TRACE = NativeLibrary.downcall("rocksdb_start_trace", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS, // env_options - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // trace_path - ValueLayout.ADDRESS)); // errptr - - MH_END_TRACE = NativeLibrary.downcall("rocksdb_end_trace", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_START_IO_TRACE = NativeLibrary.downcall("rocksdb_start_io_trace", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS, // env_options - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // trace_path - ValueLayout.ADDRESS)); // errptr - - MH_END_IO_TRACE = NativeLibrary.downcall("rocksdb_end_io_trace", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_START_BLOCK_CACHE_TRACE = NativeLibrary.downcall("rocksdb_start_block_cache_trace", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS, // env_options - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // trace_path - ValueLayout.ADDRESS)); // errptr - - MH_START_BLOCK_CACHE_TRACE_WITH_OPTIONS = NativeLibrary.downcall( - "rocksdb_start_block_cache_trace_with_options", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, // db - ValueLayout.ADDRESS, // env - ValueLayout.ADDRESS, // env_options - ValueLayout.ADDRESS, // options - ValueLayout.ADDRESS, // writer_options - ValueLayout.ADDRESS, // trace_path - ValueLayout.ADDRESS)); // errptr - - MH_END_BLOCK_CACHE_TRACE = NativeLibrary.downcall("rocksdb_end_block_cache_trace", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_END_BLOCK_CACHE_TRACE = NativeLibrary.downcall( + "rocksdb_end_block_cache_trace", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDBTracingOperationsBindings() { } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBWriteOperationsBindings.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBWriteOperationsBindings.java index c874817d..0634d318 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBWriteOperationsBindings.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksDBWriteOperationsBindings.java @@ -15,126 +15,73 @@ final class RocksDBWriteOperationsBindings { /// `void rocksdb_put(rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_PUT; + private static final MethodHandle MH_PUT = NativeLibrary.downcall( + "rocksdb_put", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_put_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_PUT_CF; + private static final MethodHandle MH_PUT_CF = NativeLibrary.downcall( + "rocksdb_put_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_merge(rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_MERGE; + private static final MethodHandle MH_MERGE = NativeLibrary.downcall( + "rocksdb_merge", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_merge_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_MERGE_CF; + private static final MethodHandle MH_MERGE_CF = NativeLibrary.downcall( + "rocksdb_merge_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_delete(rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_DELETE; + private static final MethodHandle MH_DELETE = NativeLibrary.downcall( + "rocksdb_delete", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_delete_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_DELETE_CF; + private static final MethodHandle MH_DELETE_CF = NativeLibrary.downcall( + "rocksdb_delete_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_delete_range_cf(rocksdb_t* db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* end_key, size_t end_key_len, char** errptr);` - private static final MethodHandle MH_DELETE_RANGE_CF; + private static final MethodHandle MH_DELETE_RANGE_CF = NativeLibrary.downcall( + "rocksdb_delete_range_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_write(rocksdb_t* db, const rocksdb_writeoptions_t* options, rocksdb_writebatch_t* batch, char** errptr);` - private static final MethodHandle MH_WRITE; + private static final MethodHandle MH_WRITE = NativeLibrary.downcall( + "rocksdb_write", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_flush(rocksdb_t* db, const rocksdb_flushoptions_t* options, char** errptr);` - private static final MethodHandle MH_FLUSH; + private static final MethodHandle MH_FLUSH = NativeLibrary.downcall( + "rocksdb_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_flush_cf(rocksdb_t* db, const rocksdb_flushoptions_t* options, rocksdb_column_family_handle_t* column_family, char** errptr);` - private static final MethodHandle MH_FLUSH_CF; + private static final MethodHandle MH_FLUSH_CF = NativeLibrary.downcall( + "rocksdb_flush_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_flush_wal(rocksdb_t* db, unsigned char sync, char** errptr);` - private static final MethodHandle MH_FLUSH_WAL; + private static final MethodHandle MH_FLUSH_WAL = NativeLibrary.downcall( + "rocksdb_flush_wal", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_cancel_all_background_work(rocksdb_t* db, unsigned char wait);` - private static final MethodHandle MH_CANCEL_ALL_BACKGROUND_WORK; + private static final MethodHandle MH_CANCEL_ALL_BACKGROUND_WORK = NativeLibrary.downcall( + "rocksdb_cancel_all_background_work", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `uint64_t rocksdb_get_latest_sequence_number(rocksdb_t* db);` - private static final MethodHandle MH_GET_LATEST_SEQUENCE_NUMBER; + private static final MethodHandle MH_GET_LATEST_SEQUENCE_NUMBER = NativeLibrary.downcall( + "rocksdb_get_latest_sequence_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `rocksdb_wal_iterator_t* rocksdb_get_updates_since(rocksdb_t* db, uint64_t seq_number, const rocksdb_wal_readoptions_t* options, char** errptr);` - private static final MethodHandle MH_GET_UPDATES_SINCE; + private static final MethodHandle MH_GET_UPDATES_SINCE = NativeLibrary.downcall( + "rocksdb_get_updates_since", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_ingest_external_file(rocksdb_t* db, const char* const* file_list, const size_t list_len, const rocksdb_ingestexternalfileoptions_t* opt, char** errptr);` - private static final MethodHandle MH_INGEST_EXTERNAL_FILE; + private static final MethodHandle MH_INGEST_EXTERNAL_FILE = NativeLibrary.downcall( + "rocksdb_ingest_external_file", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_column_family_handle_t* rocksdb_create_column_family(rocksdb_t* db, const rocksdb_options_t* column_family_options, const char* column_family_name, char** errptr);` - private static final MethodHandle MH_CREATE_CF; + private static final MethodHandle MH_CREATE_CF = NativeLibrary.downcall( + "rocksdb_create_column_family", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_drop_column_family(rocksdb_t* db, rocksdb_column_family_handle_t* handle, char** errptr);` - private static final MethodHandle MH_DROP_CF; - - static { - MH_PUT = NativeLibrary.downcall("rocksdb_put", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_PUT_CF = NativeLibrary.downcall("rocksdb_put_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE = NativeLibrary.downcall("rocksdb_merge", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE_CF = NativeLibrary.downcall("rocksdb_merge_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE = NativeLibrary.downcall("rocksdb_delete", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE_CF = NativeLibrary.downcall("rocksdb_delete_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE_RANGE_CF = NativeLibrary.downcall("rocksdb_delete_range_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_WRITE = NativeLibrary.downcall("rocksdb_write", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH = NativeLibrary.downcall("rocksdb_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH_CF = NativeLibrary.downcall("rocksdb_flush_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH_WAL = NativeLibrary.downcall("rocksdb_flush_wal", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_CANCEL_ALL_BACKGROUND_WORK = NativeLibrary.downcall("rocksdb_cancel_all_background_work", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_LATEST_SEQUENCE_NUMBER = NativeLibrary.downcall("rocksdb_get_latest_sequence_number", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_GET_UPDATES_SINCE = NativeLibrary.downcall("rocksdb_get_updates_since", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.JAVA_LONG, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_INGEST_EXTERNAL_FILE = NativeLibrary.downcall("rocksdb_ingest_external_file", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_CREATE_CF = NativeLibrary.downcall("rocksdb_create_column_family", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DROP_CF = NativeLibrary.downcall("rocksdb_drop_column_family", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DROP_CF = NativeLibrary.downcall( + "rocksdb_drop_column_family", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private RocksDBWriteOperationsBindings() { } diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksIterator.java b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksIterator.java index 8d0ff386..043fd429 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/RocksIterator.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/RocksIterator.java @@ -33,81 +33,59 @@ public final class RocksIterator extends NativeObject { /// `rocksdb_iterator_t* rocksdb_create_iterator(rocksdb_t* db, const rocksdb_readoptions_t* options);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_create_iterator", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_destroy(rocksdb_iterator_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_iter_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_iter_valid(const rocksdb_iterator_t*);` - private static final MethodHandle MH_VALID; + private static final MethodHandle MH_VALID = NativeLibrary.downcall( + "rocksdb_iter_valid", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_seek_to_first(rocksdb_iterator_t*);` - private static final MethodHandle MH_SEEK_TO_FIRST; + private static final MethodHandle MH_SEEK_TO_FIRST = NativeLibrary.downcall( + "rocksdb_iter_seek_to_first", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_seek_to_last(rocksdb_iterator_t*);` - private static final MethodHandle MH_SEEK_TO_LAST; + private static final MethodHandle MH_SEEK_TO_LAST = NativeLibrary.downcall( + "rocksdb_iter_seek_to_last", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_seek(rocksdb_iterator_t*, const char* k, size_t klen);` - private static final MethodHandle MH_SEEK; + private static final MethodHandle MH_SEEK = NativeLibrary.downcall( + "rocksdb_iter_seek", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_iter_seek_for_prev(rocksdb_iterator_t*, const char* k, size_t klen);` - private static final MethodHandle MH_SEEK_FOR_PREV; + private static final MethodHandle MH_SEEK_FOR_PREV = NativeLibrary.downcall( + "rocksdb_iter_seek_for_prev", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_iter_next(rocksdb_iterator_t*);` - private static final MethodHandle MH_NEXT; + private static final MethodHandle MH_NEXT = NativeLibrary.downcall( + "rocksdb_iter_next", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_prev(rocksdb_iterator_t*);` - private static final MethodHandle MH_PREV; + private static final MethodHandle MH_PREV = NativeLibrary.downcall( + "rocksdb_iter_prev", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); + // key/value only read the current entry's Slice (db/c.cc), so they are critical, with heap access for the + // on-heap lenSegment. /// `const char* rocksdb_iter_key(const rocksdb_iterator_t*, size_t* klen);` - private static final MethodHandle MH_KEY; + private static final MethodHandle MH_KEY = NativeLibrary.downcall( + "rocksdb_iter_key", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS), Linker.Option.critical(true) + ); /// `const char* rocksdb_iter_value(const rocksdb_iterator_t*, size_t* vlen);` - private static final MethodHandle MH_VALUE; + private static final MethodHandle MH_VALUE = NativeLibrary.downcall( + "rocksdb_iter_value", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS), Linker.Option.critical(true) + ); /// `void rocksdb_iter_get_error(const rocksdb_iterator_t*, char** errptr);` - private static final MethodHandle MH_GET_ERROR; + private static final MethodHandle MH_GET_ERROR = NativeLibrary.downcall( + "rocksdb_iter_get_error", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_iter_refresh(const rocksdb_iterator_t* iter, char** errptr);` - private static final MethodHandle MH_REFRESH; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_create_iterator", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_iter_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_VALID = NativeLibrary.downcall("rocksdb_iter_valid", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SEEK_TO_FIRST = NativeLibrary.downcall("rocksdb_iter_seek_to_first", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SEEK_TO_LAST = NativeLibrary.downcall("rocksdb_iter_seek_to_last", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SEEK = NativeLibrary.downcall("rocksdb_iter_seek", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SEEK_FOR_PREV = NativeLibrary.downcall("rocksdb_iter_seek_for_prev", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_NEXT = NativeLibrary.downcall("rocksdb_iter_next", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_PREV = NativeLibrary.downcall("rocksdb_iter_prev", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - // key/value only read the current entry's Slice (db/c.cc), so they are critical, with heap access for the - // on-heap lenSegment. - MH_KEY = NativeLibrary.downcall("rocksdb_iter_key", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS), - Linker.Option.critical(true)); - - MH_VALUE = NativeLibrary.downcall("rocksdb_iter_value", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS), - Linker.Option.critical(true)); - - MH_GET_ERROR = NativeLibrary.downcall("rocksdb_iter_get_error", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_REFRESH = NativeLibrary.downcall("rocksdb_iter_refresh", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_REFRESH = NativeLibrary.downcall( + "rocksdb_iter_refresh", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); // The key/value length out-param, reused across calls. On the heap (a long[] is size_t-aligned), so there is no // native memory to free, from whichever thread a parent's close releases this iterator. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SecondaryDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SecondaryDB.java index 29bba3d1..09db3b0c 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SecondaryDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SecondaryDB.java @@ -34,12 +34,9 @@ public final class SecondaryDB extends NativeDB // ----------------------------------------------------------------------- /// `void rocksdb_try_catch_up_with_primary(rocksdb_t* db, char** errptr);` - private static final MethodHandle MH_CATCH_UP; - - static { - MH_CATCH_UP = NativeLibrary.downcall("rocksdb_try_catch_up_with_primary", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CATCH_UP = NativeLibrary.downcall( + "rocksdb_try_catch_up_with_primary", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); SecondaryDB(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SizeApproximationOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SizeApproximationOptions.java index d0b9fb69..847a2350 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SizeApproximationOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SizeApproximationOptions.java @@ -18,59 +18,45 @@ public final class SizeApproximationOptions extends NativeObject { /// `rocksdb_size_approximation_options_t* rocksdb_size_approximation_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_size_approximation_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_size_approximation_options_destroy(rocksdb_size_approximation_options_t* options);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_size_approximation_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_size_approximation_options_set_include_memtables(rocksdb_size_approximation_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_INCLUDE_MEMTABLES; + private static final MethodHandle MH_SET_INCLUDE_MEMTABLES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_set_include_memtables", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_size_approximation_options_get_include_memtables(rocksdb_size_approximation_options_t* opt);` - private static final MethodHandle MH_GET_INCLUDE_MEMTABLES; + private static final MethodHandle MH_GET_INCLUDE_MEMTABLES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_get_include_memtables", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_size_approximation_options_set_include_files(rocksdb_size_approximation_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_INCLUDE_FILES; + private static final MethodHandle MH_SET_INCLUDE_FILES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_set_include_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_size_approximation_options_get_include_files(rocksdb_size_approximation_options_t* opt);` - private static final MethodHandle MH_GET_INCLUDE_FILES; + private static final MethodHandle MH_GET_INCLUDE_FILES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_get_include_files", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_size_approximation_options_set_include_blob_files(rocksdb_size_approximation_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_INCLUDE_BLOB_FILES; + private static final MethodHandle MH_SET_INCLUDE_BLOB_FILES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_set_include_blob_files", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_size_approximation_options_get_include_blob_files(rocksdb_size_approximation_options_t* opt);` - private static final MethodHandle MH_GET_INCLUDE_BLOB_FILES; + private static final MethodHandle MH_GET_INCLUDE_BLOB_FILES = NativeLibrary.downcall( + "rocksdb_size_approximation_options_get_include_blob_files", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_size_approximation_options_set_files_size_error_margin(rocksdb_size_approximation_options_t* opt, double v);` - private static final MethodHandle MH_SET_FILES_SIZE_ERROR_MARGIN; + private static final MethodHandle MH_SET_FILES_SIZE_ERROR_MARGIN = NativeLibrary.downcall( + "rocksdb_size_approximation_options_set_files_size_error_margin", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `double rocksdb_size_approximation_options_get_files_size_error_margin(rocksdb_size_approximation_options_t* opt);` - private static final MethodHandle MH_GET_FILES_SIZE_ERROR_MARGIN; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_size_approximation_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_size_approximation_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_INCLUDE_MEMTABLES = NativeLibrary.downcall("rocksdb_size_approximation_options_set_include_memtables", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_INCLUDE_MEMTABLES = NativeLibrary.downcall("rocksdb_size_approximation_options_get_include_memtables", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_INCLUDE_FILES = NativeLibrary.downcall("rocksdb_size_approximation_options_set_include_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_INCLUDE_FILES = NativeLibrary.downcall("rocksdb_size_approximation_options_get_include_files", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_INCLUDE_BLOB_FILES = NativeLibrary.downcall("rocksdb_size_approximation_options_set_include_blob_files", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_INCLUDE_BLOB_FILES = NativeLibrary.downcall("rocksdb_size_approximation_options_get_include_blob_files", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_FILES_SIZE_ERROR_MARGIN = NativeLibrary.downcall( - "rocksdb_size_approximation_options_set_files_size_error_margin", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_FILES_SIZE_ERROR_MARGIN = NativeLibrary.downcall( - "rocksdb_size_approximation_options_get_files_size_error_margin", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_FILES_SIZE_ERROR_MARGIN = NativeLibrary.downcall( + "rocksdb_size_approximation_options_get_files_size_error_margin", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); private SizeApproximationOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SliceTransform.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SliceTransform.java index 03bfcea7..83a28020 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SliceTransform.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SliceTransform.java @@ -21,17 +21,13 @@ public final class SliceTransform extends NativeObject { /// `rocksdb_slicetransform_t* rocksdb_slicetransform_create_fixed_prefix(size_t);` - private static final MethodHandle MH_CREATE_FIXED_PREFIX; + private static final MethodHandle MH_CREATE_FIXED_PREFIX = NativeLibrary.downcall( + "rocksdb_slicetransform_create_fixed_prefix", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_slicetransform_destroy(rocksdb_slicetransform_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE_FIXED_PREFIX = NativeLibrary.downcall("rocksdb_slicetransform_create_fixed_prefix", - FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_slicetransform_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_slicetransform_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private SliceTransform(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Snapshot.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Snapshot.java index b5a441fd..07eca5cd 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Snapshot.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Snapshot.java @@ -31,19 +31,15 @@ public final class Snapshot extends NativeObject { /// `uint64_t rocksdb_snapshot_get_sequence_number(const rocksdb_snapshot_t* snapshot);` - private static final MethodHandle MH_SEQUENCE_NUMBER; + private static final MethodHandle MH_SEQUENCE_NUMBER = NativeLibrary.downcall( + "rocksdb_snapshot_get_sequence_number", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_release_snapshot(rocksdb_t* db, const rocksdb_snapshot_t* snapshot);` - private static final MethodHandle MH_RELEASE; + private static final MethodHandle MH_RELEASE = NativeLibrary.downcall( + "rocksdb_release_snapshot", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); // rocksdb_free(ptr*) — for Transaction snapshots - static { - MH_SEQUENCE_NUMBER = NativeLibrary.downcall("rocksdb_snapshot_get_sequence_number", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_RELEASE = NativeLibrary.downcall("rocksdb_release_snapshot", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } - /// DB pointer used to release the snapshot; NULL signals that `rocksdb_free` /// should be used instead (transaction snapshot ownership model). private final MemorySegment dbPtr; diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileManager.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileManager.java index 19a3fc2a..5fba32c2 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileManager.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileManager.java @@ -31,76 +31,53 @@ public final class SstFileManager extends NativeObject { /// `rocksdb_sst_file_manager_t* rocksdb_sst_file_manager_create(rocksdb_env_t* env);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_sst_file_manager_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_sst_file_manager_destroy(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_sst_file_manager_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_sst_file_manager_set_max_allowed_space_usage(rocksdb_sst_file_manager_t* sfm, uint64_t max_allowed_space);` - private static final MethodHandle MH_SET_MAX_ALLOWED_SPACE_USAGE; + private static final MethodHandle MH_SET_MAX_ALLOWED_SPACE_USAGE = NativeLibrary.downcall( + "rocksdb_sst_file_manager_set_max_allowed_space_usage", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `void rocksdb_sst_file_manager_set_compaction_buffer_size(rocksdb_sst_file_manager_t* sfm, uint64_t compaction_buffer_size);` - private static final MethodHandle MH_SET_COMPACTION_BUFFER_SIZE; + private static final MethodHandle MH_SET_COMPACTION_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_sst_file_manager_set_compaction_buffer_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `bool rocksdb_sst_file_manager_is_max_allowed_space_reached(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_IS_MAX_ALLOWED_SPACE_REACHED; + private static final MethodHandle MH_IS_MAX_ALLOWED_SPACE_REACHED = NativeLibrary.downcall( + "rocksdb_sst_file_manager_is_max_allowed_space_reached", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `bool rocksdb_sst_file_manager_is_max_allowed_space_reached_including_compactions(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_IS_MAX_ALLOWED_SPACE_REACHED_INCLUDING_COMPACTIONS; + private static final MethodHandle MH_IS_MAX_ALLOWED_SPACE_REACHED_INCLUDING_COMPACTIONS = NativeLibrary.downcall( + "rocksdb_sst_file_manager_is_max_allowed_space_reached_including_compactions", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_sst_file_manager_get_total_size(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_GET_TOTAL_SIZE; + private static final MethodHandle MH_GET_TOTAL_SIZE = NativeLibrary.downcall( + "rocksdb_sst_file_manager_get_total_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `int64_t rocksdb_sst_file_manager_get_delete_rate_bytes_per_second(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_GET_DELETE_RATE_BYTES_PER_SECOND; + private static final MethodHandle MH_GET_DELETE_RATE_BYTES_PER_SECOND = NativeLibrary.downcall( + "rocksdb_sst_file_manager_get_delete_rate_bytes_per_second", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_sst_file_manager_set_delete_rate_bytes_per_second(rocksdb_sst_file_manager_t* sfm, int64_t delete_rate);` - private static final MethodHandle MH_SET_DELETE_RATE_BYTES_PER_SECOND; + private static final MethodHandle MH_SET_DELETE_RATE_BYTES_PER_SECOND = NativeLibrary.downcall( + "rocksdb_sst_file_manager_set_delete_rate_bytes_per_second", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `double rocksdb_sst_file_manager_get_max_trash_db_ratio(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_GET_MAX_TRASH_DB_RATIO; + private static final MethodHandle MH_GET_MAX_TRASH_DB_RATIO = NativeLibrary.downcall( + "rocksdb_sst_file_manager_get_max_trash_db_ratio", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `void rocksdb_sst_file_manager_set_max_trash_db_ratio(rocksdb_sst_file_manager_t* sfm, double ratio);` - private static final MethodHandle MH_SET_MAX_TRASH_DB_RATIO; + private static final MethodHandle MH_SET_MAX_TRASH_DB_RATIO = NativeLibrary.downcall( + "rocksdb_sst_file_manager_set_max_trash_db_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE) + ); /// `uint64_t rocksdb_sst_file_manager_get_total_trash_size(rocksdb_sst_file_manager_t* sfm);` - private static final MethodHandle MH_GET_TOTAL_TRASH_SIZE; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_sst_file_manager_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_sst_file_manager_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_MAX_ALLOWED_SPACE_USAGE = NativeLibrary.downcall( - "rocksdb_sst_file_manager_set_max_allowed_space_usage", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_SET_COMPACTION_BUFFER_SIZE = NativeLibrary.downcall( - "rocksdb_sst_file_manager_set_compaction_buffer_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_IS_MAX_ALLOWED_SPACE_REACHED = NativeLibrary.downcall( - "rocksdb_sst_file_manager_is_max_allowed_space_reached", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_IS_MAX_ALLOWED_SPACE_REACHED_INCLUDING_COMPACTIONS = NativeLibrary.downcall( - "rocksdb_sst_file_manager_is_max_allowed_space_reached_including_compactions", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_GET_TOTAL_SIZE = NativeLibrary.downcall("rocksdb_sst_file_manager_get_total_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_GET_DELETE_RATE_BYTES_PER_SECOND = NativeLibrary.downcall( - "rocksdb_sst_file_manager_get_delete_rate_bytes_per_second", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_DELETE_RATE_BYTES_PER_SECOND = NativeLibrary.downcall( - "rocksdb_sst_file_manager_set_delete_rate_bytes_per_second", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_TRASH_DB_RATIO = NativeLibrary.downcall( - "rocksdb_sst_file_manager_get_max_trash_db_ratio", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - - MH_SET_MAX_TRASH_DB_RATIO = NativeLibrary.downcall( - "rocksdb_sst_file_manager_set_max_trash_db_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_DOUBLE)); - - MH_GET_TOTAL_TRASH_SIZE = NativeLibrary.downcall( - "rocksdb_sst_file_manager_get_total_trash_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_TOTAL_TRASH_SIZE = NativeLibrary.downcall( + "rocksdb_sst_file_manager_get_total_trash_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); private SstFileManager(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileWriter.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileWriter.java index 111f2d22..70456923 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileWriter.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SstFileWriter.java @@ -29,60 +29,37 @@ public final class SstFileWriter extends NativeObject { /// `rocksdb_sstfilewriter_t* rocksdb_sstfilewriter_create(const rocksdb_envoptions_t* env, const rocksdb_options_t* io_options);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_sstfilewriter_create", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_destroy(rocksdb_sstfilewriter_t* writer);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_sstfilewriter_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_open(rocksdb_sstfilewriter_t* writer, const char* name, char** errptr);` - private static final MethodHandle MH_OPEN; + private static final MethodHandle MH_OPEN = NativeLibrary.downcall( + "rocksdb_sstfilewriter_open", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_put(rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_PUT; + private static final MethodHandle MH_PUT = NativeLibrary.downcall( + "rocksdb_sstfilewriter_put", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_delete(rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_DELETE; + private static final MethodHandle MH_DELETE = NativeLibrary.downcall( + "rocksdb_sstfilewriter_delete", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_delete_range(rocksdb_sstfilewriter_t* writer, const char* begin_key, size_t begin_keylen, const char* end_key, size_t end_keylen, char** errptr);` - private static final MethodHandle MH_DELETE_RANGE; + private static final MethodHandle MH_DELETE_RANGE = NativeLibrary.downcall( + "rocksdb_sstfilewriter_delete_range", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_finish(rocksdb_sstfilewriter_t* writer, char** errptr);` - private static final MethodHandle MH_FINISH; + private static final MethodHandle MH_FINISH = NativeLibrary.downcall( + "rocksdb_sstfilewriter_finish", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_sstfilewriter_file_size(rocksdb_sstfilewriter_t* writer, uint64_t* file_size);` - private static final MethodHandle MH_FILE_SIZE; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_sstfilewriter_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_sstfilewriter_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_OPEN = NativeLibrary.downcall("rocksdb_sstfilewriter_open", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PUT = NativeLibrary.downcall("rocksdb_sstfilewriter_put", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE = NativeLibrary.downcall("rocksdb_sstfilewriter_delete", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE_RANGE = NativeLibrary.downcall("rocksdb_sstfilewriter_delete_range", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_FINISH = NativeLibrary.downcall("rocksdb_sstfilewriter_finish", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FILE_SIZE = NativeLibrary.downcall("rocksdb_sstfilewriter_file_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_sstfilewriter_file_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private SstFileWriter(EnvOptions envOptions, MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/SstPartitionerFactory.java b/core/src/main/java/io/github/dfa1/rocksdbffm/SstPartitionerFactory.java index 0257e5aa..acbbc279 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/SstPartitionerFactory.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/SstPartitionerFactory.java @@ -26,17 +26,13 @@ public final class SstPartitionerFactory extends NativeObject { /// `rocksdb_sst_partitioner_factory_t* rocksdb_sst_partitioner_fixed_prefix_factory_create(size_t prefix_len);` - private static final MethodHandle MH_CREATE_FIXED_PREFIX; + private static final MethodHandle MH_CREATE_FIXED_PREFIX = NativeLibrary.downcall( + "rocksdb_sst_partitioner_fixed_prefix_factory_create", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_sst_partitioner_factory_destroy(rocksdb_sst_partitioner_factory_t*);` - private static final MethodHandle MH_DESTROY; - - static { - MH_CREATE_FIXED_PREFIX = NativeLibrary.downcall("rocksdb_sst_partitioner_fixed_prefix_factory_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_sst_partitioner_factory_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_sst_partitioner_factory_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); private SstPartitionerFactory(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/StatisticsHistogramData.java b/core/src/main/java/io/github/dfa1/rocksdbffm/StatisticsHistogramData.java index e041bbd8..5a6e0310 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/StatisticsHistogramData.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/StatisticsHistogramData.java @@ -9,52 +9,49 @@ public final class StatisticsHistogramData extends NativeObject { /// `rocksdb_statistics_histogram_data_t* rocksdb_statistics_histogram_data_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_statistics_histogram_data_destroy(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_median(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_MEDIAN; + private static final MethodHandle MH_GET_MEDIAN = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_median", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_p95(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_P95; + private static final MethodHandle MH_GET_P95 = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_p95", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_p99(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_P99; + private static final MethodHandle MH_GET_P99 = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_p99", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_average(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_AVERAGE; + private static final MethodHandle MH_GET_AVERAGE = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_average", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_std_dev(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_STD_DEV; + private static final MethodHandle MH_GET_STD_DEV = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_std_dev", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_max(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_MAX; + private static final MethodHandle MH_GET_MAX = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_max", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_statistics_histogram_data_get_count(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_COUNT; + private static final MethodHandle MH_GET_COUNT = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_count", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `uint64_t rocksdb_statistics_histogram_data_get_sum(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_SUM; + private static final MethodHandle MH_GET_SUM = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_sum", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `double rocksdb_statistics_histogram_data_get_min(rocksdb_statistics_histogram_data_t* data);` - private static final MethodHandle MH_GET_MIN; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_statistics_histogram_data_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - MH_DESTROY = NativeLibrary.downcall("rocksdb_statistics_histogram_data_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - MH_GET_MEDIAN = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_median", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_P95 = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_p95", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_P99 = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_p99", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_AVERAGE = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_average", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_STD_DEV = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_std_dev", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_MAX = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_max", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - MH_GET_COUNT = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_count", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - MH_GET_SUM = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_sum", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - MH_GET_MIN = NativeLibrary.downcall("rocksdb_statistics_histogram_data_get_min", - FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_MIN = NativeLibrary.downcall( + "rocksdb_statistics_histogram_data_get_min", FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.ADDRESS) + ); private StatisticsHistogramData(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/TraceOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/TraceOptions.java index 11cb16a7..67253ab5 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/TraceOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/TraceOptions.java @@ -25,57 +25,45 @@ public final class TraceOptions extends NativeObject { /// `rocksdb_trace_options_t* rocksdb_trace_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_trace_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_trace_options_destroy(rocksdb_trace_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_trace_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_trace_options_set_max_trace_file_size(rocksdb_trace_options_t*, uint64_t);` - private static final MethodHandle MH_SET_MAX_TRACE_FILE_SIZE; + private static final MethodHandle MH_SET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_trace_options_set_max_trace_file_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_trace_options_get_max_trace_file_size(rocksdb_trace_options_t*);` - private static final MethodHandle MH_GET_MAX_TRACE_FILE_SIZE; + private static final MethodHandle MH_GET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall( + "rocksdb_trace_options_get_max_trace_file_size", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_trace_options_set_sampling_frequency(rocksdb_trace_options_t*, uint64_t);` - private static final MethodHandle MH_SET_SAMPLING_FREQUENCY; + private static final MethodHandle MH_SET_SAMPLING_FREQUENCY = NativeLibrary.downcall( + "rocksdb_trace_options_set_sampling_frequency", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_trace_options_get_sampling_frequency(rocksdb_trace_options_t*);` - private static final MethodHandle MH_GET_SAMPLING_FREQUENCY; + private static final MethodHandle MH_GET_SAMPLING_FREQUENCY = NativeLibrary.downcall( + "rocksdb_trace_options_get_sampling_frequency", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_trace_options_set_filter(rocksdb_trace_options_t*, uint64_t);` - private static final MethodHandle MH_SET_FILTER; + private static final MethodHandle MH_SET_FILTER = NativeLibrary.downcall( + "rocksdb_trace_options_set_filter", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_trace_options_get_filter(rocksdb_trace_options_t*);` - private static final MethodHandle MH_GET_FILTER; + private static final MethodHandle MH_GET_FILTER = NativeLibrary.downcall( + "rocksdb_trace_options_get_filter", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_trace_options_set_preserve_write_order(rocksdb_trace_options_t*, unsigned char);` - private static final MethodHandle MH_SET_PRESERVE_WRITE_ORDER; + private static final MethodHandle MH_SET_PRESERVE_WRITE_ORDER = NativeLibrary.downcall( + "rocksdb_trace_options_set_preserve_write_order", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_trace_options_get_preserve_write_order(rocksdb_trace_options_t*);` - private static final MethodHandle MH_GET_PRESERVE_WRITE_ORDER; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_trace_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_trace_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall("rocksdb_trace_options_set_max_trace_file_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_TRACE_FILE_SIZE = NativeLibrary.downcall("rocksdb_trace_options_get_max_trace_file_size", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_SAMPLING_FREQUENCY = NativeLibrary.downcall("rocksdb_trace_options_set_sampling_frequency", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_SAMPLING_FREQUENCY = NativeLibrary.downcall("rocksdb_trace_options_get_sampling_frequency", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_FILTER = NativeLibrary.downcall("rocksdb_trace_options_set_filter", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_FILTER = NativeLibrary.downcall("rocksdb_trace_options_get_filter", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_PRESERVE_WRITE_ORDER = NativeLibrary.downcall("rocksdb_trace_options_set_preserve_write_order", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_PRESERVE_WRITE_ORDER = NativeLibrary.downcall("rocksdb_trace_options_get_preserve_write_order", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_PRESERVE_WRITE_ORDER = NativeLibrary.downcall( + "rocksdb_trace_options_get_preserve_write_order", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); private TraceOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/Transaction.java b/core/src/main/java/io/github/dfa1/rocksdbffm/Transaction.java index 7006c5f8..73f32eb7 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/Transaction.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/Transaction.java @@ -28,129 +28,74 @@ public final class Transaction extends NativeObjectWithChildren { /// `rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_cf(rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_GET_PINNED_CF; + private static final MethodHandle MH_GET_PINNED_CF = NativeLibrary.downcall( + "rocksdb_transaction_get_pinned_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_for_update_cf(rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, unsigned char exclusive, char** errptr);` - private static final MethodHandle MH_GET_PINNED_FOR_UPDATE_CF; + private static final MethodHandle MH_GET_PINNED_FOR_UPDATE_CF = NativeLibrary.downcall( + "rocksdb_transaction_get_pinned_for_update_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_put_cf(rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_PUT_CF; + private static final MethodHandle MH_PUT_CF = NativeLibrary.downcall( + "rocksdb_transaction_put_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_delete_cf(rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_DELETE_CF; + private static final MethodHandle MH_DELETE_CF = NativeLibrary.downcall( + "rocksdb_transaction_delete_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_merge_cf(rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_MERGE_CF; + private static final MethodHandle MH_MERGE_CF = NativeLibrary.downcall( + "rocksdb_transaction_merge_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_iterator_t* rocksdb_transaction_create_iterator_cf(rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family);` - private static final MethodHandle MH_CREATE_ITERATOR_CF; + private static final MethodHandle MH_CREATE_ITERATOR_CF = NativeLibrary.downcall( + "rocksdb_transaction_create_iterator_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_commit(rocksdb_transaction_t* txn, char** errptr);` - private static final MethodHandle MH_COMMIT; + private static final MethodHandle MH_COMMIT = NativeLibrary.downcall( + "rocksdb_transaction_commit", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_rollback(rocksdb_transaction_t* txn, char** errptr);` - private static final MethodHandle MH_ROLLBACK; + private static final MethodHandle MH_ROLLBACK = NativeLibrary.downcall( + "rocksdb_transaction_rollback", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_destroy(rocksdb_transaction_t* txn);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_transaction_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); + // Note: must be freed with rocksdb_free, not rocksdb_release_snapshot /// `const rocksdb_snapshot_t* rocksdb_transaction_get_snapshot(rocksdb_transaction_t* txn);` - private static final MethodHandle MH_GET_SNAPSHOT; + private static final MethodHandle MH_GET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_transaction_get_snapshot", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_set_savepoint(rocksdb_transaction_t* txn);` - private static final MethodHandle MH_SET_SAVEPOINT; + private static final MethodHandle MH_SET_SAVEPOINT = NativeLibrary.downcall( + "rocksdb_transaction_set_savepoint", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_rollback_to_savepoint(rocksdb_transaction_t* txn, char** errptr);` - private static final MethodHandle MH_ROLLBACK_TO_SAVEPOINT; + private static final MethodHandle MH_ROLLBACK_TO_SAVEPOINT = NativeLibrary.downcall( + "rocksdb_transaction_rollback_to_savepoint", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_put(rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_PUT; + private static final MethodHandle MH_PUT = NativeLibrary.downcall( + "rocksdb_transaction_put", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_delete(rocksdb_transaction_t* txn, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_DELETE; + private static final MethodHandle MH_DELETE = NativeLibrary.downcall( + "rocksdb_transaction_delete", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_merge(rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_MERGE; + private static final MethodHandle MH_MERGE = NativeLibrary.downcall( + "rocksdb_transaction_merge", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned(rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_GET_PINNED; + private static final MethodHandle MH_GET_PINNED = NativeLibrary.downcall( + "rocksdb_transaction_get_pinned", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnableslice_t* rocksdb_transaction_get_pinned_for_update(rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, const char* key, size_t klen, unsigned char exclusive, char** errptr);` - private static final MethodHandle MH_GET_PINNED_FOR_UPDATE; - - static { - MH_COMMIT = NativeLibrary.downcall("rocksdb_transaction_commit", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_ROLLBACK = NativeLibrary.downcall("rocksdb_transaction_rollback", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_transaction_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SAVEPOINT = NativeLibrary.downcall("rocksdb_transaction_set_savepoint", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_ROLLBACK_TO_SAVEPOINT = NativeLibrary.downcall("rocksdb_transaction_rollback_to_savepoint", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PUT = NativeLibrary.downcall("rocksdb_transaction_put", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE = NativeLibrary.downcall("rocksdb_transaction_delete", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE = NativeLibrary.downcall("rocksdb_transaction_merge", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED = NativeLibrary.downcall("rocksdb_transaction_get_pinned", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED_FOR_UPDATE = NativeLibrary.downcall("rocksdb_transaction_get_pinned_for_update", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - - MH_PUT_CF = NativeLibrary.downcall("rocksdb_transaction_put_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE_CF = NativeLibrary.downcall("rocksdb_transaction_delete_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE_CF = NativeLibrary.downcall("rocksdb_transaction_merge_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED_CF = NativeLibrary.downcall("rocksdb_transaction_get_pinned_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED_FOR_UPDATE_CF = NativeLibrary.downcall("rocksdb_transaction_get_pinned_for_update_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_CREATE_ITERATOR_CF = NativeLibrary.downcall("rocksdb_transaction_create_iterator_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - // Note: must be freed with rocksdb_free, not rocksdb_release_snapshot - MH_GET_SNAPSHOT = NativeLibrary.downcall("rocksdb_transaction_get_snapshot", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_PINNED_FOR_UPDATE = NativeLibrary.downcall( + "rocksdb_transaction_get_pinned_for_update", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// Whether this transaction was begun with `setSetSnapshot(true)`. RocksDB's C API /// returns a non-null wrapper from `rocksdb_transaction_get_snapshot` either way, but diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDB.java index f24c2501..70708bfe 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDB.java @@ -31,142 +31,85 @@ public final class TransactionDB extends NativeDBWithBaseDB // ----------------------------------------------------------------------- /// `void rocksdb_transactiondb_close(rocksdb_transactiondb_t* txn_db);` - private static final MethodHandle MH_CLOSE; + private static final MethodHandle MH_CLOSE = NativeLibrary.downcall( + "rocksdb_transactiondb_close", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_close_base_db(rocksdb_t* base_db);` - private static final MethodHandle MH_CLOSE_BASE_DB; + private static final MethodHandle MH_CLOSE_BASE_DB = NativeLibrary.downcall( + "rocksdb_transactiondb_close_base_db", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `rocksdb_transaction_t* rocksdb_transaction_begin(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* write_options, const rocksdb_transaction_options_t* txn_options, rocksdb_transaction_t* old_txn);` - private static final MethodHandle MH_BEGIN; + private static final MethodHandle MH_BEGIN = NativeLibrary.downcall( + "rocksdb_transaction_begin", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const rocksdb_snapshot_t* rocksdb_transactiondb_create_snapshot(rocksdb_transactiondb_t* txn_db);` - private static final MethodHandle MH_CREATE_SNAPSHOT; + private static final MethodHandle MH_CREATE_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_transactiondb_create_snapshot", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_flush(rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options, char** errptr);` - private static final MethodHandle MH_FLUSH; + private static final MethodHandle MH_FLUSH = NativeLibrary.downcall( + "rocksdb_transactiondb_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_flush_wal(rocksdb_transactiondb_t* txn_db, unsigned char sync, char** errptr);` - private static final MethodHandle MH_FLUSH_WAL; + private static final MethodHandle MH_FLUSH_WAL = NativeLibrary.downcall( + "rocksdb_transactiondb_flush_wal", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `char* rocksdb_transactiondb_property_value(rocksdb_transactiondb_t* db, const char* propname);` - private static final MethodHandle MH_PROPERTY_VALUE; + private static final MethodHandle MH_PROPERTY_VALUE = NativeLibrary.downcall( + "rocksdb_transactiondb_property_value", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `int rocksdb_transactiondb_property_int(rocksdb_transactiondb_t* db, const char* propname, uint64_t* out_val);` - private static final MethodHandle MH_PROPERTY_INT; + private static final MethodHandle MH_PROPERTY_INT = NativeLibrary.downcall( + "rocksdb_transactiondb_property_int", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_column_family_handle_t* rocksdb_transactiondb_create_column_family(rocksdb_transactiondb_t* txn_db, const rocksdb_options_t* column_family_options, const char* column_family_name, char** errptr);` - private static final MethodHandle MH_CREATE_CF; + private static final MethodHandle MH_CREATE_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_create_column_family", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); // Direct (non-transactional) operations on the TransactionDB /// `void rocksdb_transactiondb_put(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_PUT; + private static final MethodHandle MH_PUT = NativeLibrary.downcall( + "rocksdb_transactiondb_put", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_delete(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_DELETE; + private static final MethodHandle MH_DELETE = NativeLibrary.downcall( + "rocksdb_transactiondb_delete", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_merge(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_MERGE; + private static final MethodHandle MH_MERGE = NativeLibrary.downcall( + "rocksdb_transactiondb_merge", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnableslice_t* rocksdb_transactiondb_get_pinned(rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, const char* key, size_t klen, char** errptr);` - private static final MethodHandle MH_GET_PINNED; + private static final MethodHandle MH_GET_PINNED = NativeLibrary.downcall( + "rocksdb_transactiondb_get_pinned", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); // Column-family variants /// `void rocksdb_transactiondb_put_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, const char* val, size_t vallen, char** errptr);` - private static final MethodHandle MH_PUT_CF; + private static final MethodHandle MH_PUT_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_put_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_delete_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_DELETE_CF; + private static final MethodHandle MH_DELETE_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_delete_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_merge_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, const char* val, size_t vlen, char** errptr);` - private static final MethodHandle MH_MERGE_CF; + private static final MethodHandle MH_MERGE_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_merge_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_pinnableslice_t* rocksdb_transactiondb_get_pinned_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family, const char* key, size_t keylen, char** errptr);` - private static final MethodHandle MH_GET_PINNED_CF; + private static final MethodHandle MH_GET_PINNED_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_get_pinned_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `rocksdb_iterator_t* rocksdb_transactiondb_create_iterator_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, rocksdb_column_family_handle_t* column_family);` - private static final MethodHandle MH_CREATE_ITERATOR_CF; + private static final MethodHandle MH_CREATE_ITERATOR_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_create_iterator_cf", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_flush_cf(rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options, rocksdb_column_family_handle_t* column_family, char** errptr);` - private static final MethodHandle MH_FLUSH_CF; - - - static { - MH_CLOSE = NativeLibrary.downcall("rocksdb_transactiondb_close", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_CLOSE_BASE_DB = NativeLibrary.downcall("rocksdb_transactiondb_close_base_db", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_BEGIN = NativeLibrary.downcall("rocksdb_transaction_begin", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PUT = NativeLibrary.downcall("rocksdb_transactiondb_put", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE = NativeLibrary.downcall("rocksdb_transactiondb_delete", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE = NativeLibrary.downcall("rocksdb_transactiondb_merge", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED = NativeLibrary.downcall("rocksdb_transactiondb_get_pinned", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_PUT_CF = NativeLibrary.downcall("rocksdb_transactiondb_put_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_DELETE_CF = NativeLibrary.downcall("rocksdb_transactiondb_delete_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_MERGE_CF = NativeLibrary.downcall("rocksdb_transactiondb_merge_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_GET_PINNED_CF = NativeLibrary.downcall("rocksdb_transactiondb_get_pinned_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS)); - - MH_CREATE_ITERATOR_CF = NativeLibrary.downcall("rocksdb_transactiondb_create_iterator_cf", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH_CF = NativeLibrary.downcall("rocksdb_transactiondb_flush_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_CREATE_SNAPSHOT = NativeLibrary.downcall("rocksdb_transactiondb_create_snapshot", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_CREATE_CF = NativeLibrary.downcall("rocksdb_transactiondb_create_column_family", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH = NativeLibrary.downcall("rocksdb_transactiondb_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_FLUSH_WAL = NativeLibrary.downcall("rocksdb_transactiondb_flush_wal", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_PROPERTY_VALUE = NativeLibrary.downcall("rocksdb_transactiondb_property_value", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_PROPERTY_INT = NativeLibrary.downcall("rocksdb_transactiondb_property_int", - FunctionDescriptor.of(ValueLayout.JAVA_INT, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_FLUSH_CF = NativeLibrary.downcall( + "rocksdb_transactiondb_flush_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); // ----------------------------------------------------------------------- // Instance state diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDBOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDBOptions.java index 86ec3407..9c825f28 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDBOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionDBOptions.java @@ -12,153 +12,109 @@ public final class TransactionDBOptions extends NativeObject { /// `rocksdb_transactiondb_options_t* rocksdb_transactiondb_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_transactiondb_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_destroy(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_transactiondb_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_max_num_locks(rocksdb_transactiondb_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_MAX_NUM_LOCKS; + private static final MethodHandle MH_SET_MAX_NUM_LOCKS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_max_num_locks", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transactiondb_options_get_max_num_locks(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_MAX_NUM_LOCKS; + private static final MethodHandle MH_GET_MAX_NUM_LOCKS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_max_num_locks", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_max_num_deadlocks(rocksdb_transactiondb_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_MAX_NUM_DEADLOCKS; + private static final MethodHandle MH_SET_MAX_NUM_DEADLOCKS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_max_num_deadlocks", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_transactiondb_options_get_max_num_deadlocks(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_MAX_NUM_DEADLOCKS; + private static final MethodHandle MH_GET_MAX_NUM_DEADLOCKS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_max_num_deadlocks", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_num_stripes(rocksdb_transactiondb_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_NUM_STRIPES; + private static final MethodHandle MH_SET_NUM_STRIPES = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_num_stripes", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_transactiondb_options_get_num_stripes(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_NUM_STRIPES; + private static final MethodHandle MH_GET_NUM_STRIPES = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_num_stripes", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_transaction_lock_timeout(rocksdb_transactiondb_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_TRANSACTION_LOCK_TIMEOUT; + private static final MethodHandle MH_SET_TRANSACTION_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_transaction_lock_timeout", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transactiondb_options_get_transaction_lock_timeout(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_TRANSACTION_LOCK_TIMEOUT; + private static final MethodHandle MH_GET_TRANSACTION_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_transaction_lock_timeout", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_default_lock_timeout(rocksdb_transactiondb_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_DEFAULT_LOCK_TIMEOUT; + private static final MethodHandle MH_SET_DEFAULT_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_default_lock_timeout", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transactiondb_options_get_default_lock_timeout(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_DEFAULT_LOCK_TIMEOUT; + private static final MethodHandle MH_GET_DEFAULT_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_default_lock_timeout", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_write_policy(rocksdb_transactiondb_options_t* opt, int v);` - private static final MethodHandle MH_SET_WRITE_POLICY; + private static final MethodHandle MH_SET_WRITE_POLICY = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_write_policy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_transactiondb_options_get_write_policy(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_WRITE_POLICY; + private static final MethodHandle MH_GET_WRITE_POLICY = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_write_policy", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_rollback_merge_operands(rocksdb_transactiondb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ROLLBACK_MERGE_OPERANDS; + private static final MethodHandle MH_SET_ROLLBACK_MERGE_OPERANDS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_rollback_merge_operands", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transactiondb_options_get_rollback_merge_operands(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_ROLLBACK_MERGE_OPERANDS; + private static final MethodHandle MH_GET_ROLLBACK_MERGE_OPERANDS = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_rollback_merge_operands", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_use_per_key_point_lock_mgr(rocksdb_transactiondb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_PER_KEY_POINT_LOCK_MGR; + private static final MethodHandle MH_SET_USE_PER_KEY_POINT_LOCK_MGR = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_use_per_key_point_lock_mgr", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transactiondb_options_get_use_per_key_point_lock_mgr(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_USE_PER_KEY_POINT_LOCK_MGR; + private static final MethodHandle MH_GET_USE_PER_KEY_POINT_LOCK_MGR = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_use_per_key_point_lock_mgr", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_skip_concurrency_control(rocksdb_transactiondb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SKIP_CONCURRENCY_CONTROL; + private static final MethodHandle MH_SET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_skip_concurrency_control", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transactiondb_options_get_skip_concurrency_control(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_SKIP_CONCURRENCY_CONTROL; + private static final MethodHandle MH_GET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_skip_concurrency_control", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_default_write_batch_flush_threshold(rocksdb_transactiondb_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD; + private static final MethodHandle MH_SET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_default_write_batch_flush_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transactiondb_options_get_default_write_batch_flush_threshold(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD; + private static final MethodHandle MH_GET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_default_write_batch_flush_threshold", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_enable_udt_validation(rocksdb_transactiondb_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ENABLE_UDT_VALIDATION; + private static final MethodHandle MH_SET_ENABLE_UDT_VALIDATION = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_enable_udt_validation", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transactiondb_options_get_enable_udt_validation(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_ENABLE_UDT_VALIDATION; + private static final MethodHandle MH_GET_ENABLE_UDT_VALIDATION = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_enable_udt_validation", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transactiondb_options_set_txn_commit_bypass_memtable_threshold(rocksdb_transactiondb_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD; + private static final MethodHandle MH_SET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transactiondb_options_set_txn_commit_bypass_memtable_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_transactiondb_options_get_txn_commit_bypass_memtable_threshold(rocksdb_transactiondb_options_t* opt);` - private static final MethodHandle MH_GET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_transactiondb_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_transactiondb_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_MAX_NUM_LOCKS = NativeLibrary.downcall("rocksdb_transactiondb_options_set_max_num_locks", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_MAX_NUM_LOCKS = NativeLibrary.downcall("rocksdb_transactiondb_options_get_max_num_locks", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_NUM_DEADLOCKS = NativeLibrary.downcall("rocksdb_transactiondb_options_set_max_num_deadlocks", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_NUM_DEADLOCKS = NativeLibrary.downcall("rocksdb_transactiondb_options_get_max_num_deadlocks", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_NUM_STRIPES = NativeLibrary.downcall("rocksdb_transactiondb_options_set_num_stripes", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_NUM_STRIPES = NativeLibrary.downcall("rocksdb_transactiondb_options_get_num_stripes", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_TRANSACTION_LOCK_TIMEOUT = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_transaction_lock_timeout", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_TRANSACTION_LOCK_TIMEOUT = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_transaction_lock_timeout", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_DEFAULT_LOCK_TIMEOUT = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_default_lock_timeout", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_DEFAULT_LOCK_TIMEOUT = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_default_lock_timeout", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_WRITE_POLICY = NativeLibrary.downcall("rocksdb_transactiondb_options_set_write_policy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_WRITE_POLICY = NativeLibrary.downcall("rocksdb_transactiondb_options_get_write_policy", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_ROLLBACK_MERGE_OPERANDS = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_rollback_merge_operands", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ROLLBACK_MERGE_OPERANDS = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_rollback_merge_operands", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_PER_KEY_POINT_LOCK_MGR = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_use_per_key_point_lock_mgr", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_PER_KEY_POINT_LOCK_MGR = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_use_per_key_point_lock_mgr", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_skip_concurrency_control", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_skip_concurrency_control", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_default_write_batch_flush_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_DEFAULT_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_default_write_batch_flush_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_ENABLE_UDT_VALIDATION = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_enable_udt_validation", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ENABLE_UDT_VALIDATION = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_enable_udt_validation", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transactiondb_options_set_txn_commit_bypass_memtable_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transactiondb_options_get_txn_commit_bypass_memtable_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_TXN_COMMIT_BYPASS_MEMTABLE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transactiondb_options_get_txn_commit_bypass_memtable_threshold", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private TransactionDBOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionOptions.java index 18d6037a..753590ae 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/TransactionOptions.java @@ -13,181 +13,133 @@ public final class TransactionOptions extends NativeObject { /// `rocksdb_transaction_options_t* rocksdb_transaction_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_transaction_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_destroy(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_transaction_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_set_snapshot(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SET_SNAPSHOT; + private static final MethodHandle MH_SET_SET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_transaction_options_set_set_snapshot", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_set_snapshot(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_SET_SNAPSHOT; + private static final MethodHandle MH_GET_SET_SNAPSHOT = NativeLibrary.downcall( + "rocksdb_transaction_options_get_set_snapshot", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_deadlock_detect(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_DEADLOCK_DETECT; + private static final MethodHandle MH_SET_DEADLOCK_DETECT = NativeLibrary.downcall( + "rocksdb_transaction_options_set_deadlock_detect", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_deadlock_detect(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_DEADLOCK_DETECT; + private static final MethodHandle MH_GET_DEADLOCK_DETECT = NativeLibrary.downcall( + "rocksdb_transaction_options_get_deadlock_detect", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_use_only_the_last_commit_time_batch_for_recovery(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY; + private static final MethodHandle MH_SET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY = NativeLibrary.downcall( + "rocksdb_transaction_options_set_use_only_the_last_commit_time_batch_for_recovery", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_use_only_the_last_commit_time_batch_for_recovery(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY; + private static final MethodHandle MH_GET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY = NativeLibrary.downcall( + "rocksdb_transaction_options_get_use_only_the_last_commit_time_batch_for_recovery", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_lock_timeout(rocksdb_transaction_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_LOCK_TIMEOUT; + private static final MethodHandle MH_SET_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transaction_options_set_lock_timeout", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transaction_options_get_lock_timeout(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_LOCK_TIMEOUT; + private static final MethodHandle MH_GET_LOCK_TIMEOUT = NativeLibrary.downcall( + "rocksdb_transaction_options_get_lock_timeout", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_deadlock_timeout_us(rocksdb_transaction_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_DEADLOCK_TIMEOUT_US; + private static final MethodHandle MH_SET_DEADLOCK_TIMEOUT_US = NativeLibrary.downcall( + "rocksdb_transaction_options_set_deadlock_timeout_us", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transaction_options_get_deadlock_timeout_us(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_DEADLOCK_TIMEOUT_US; + private static final MethodHandle MH_GET_DEADLOCK_TIMEOUT_US = NativeLibrary.downcall( + "rocksdb_transaction_options_get_deadlock_timeout_us", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_expiration(rocksdb_transaction_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_EXPIRATION; + private static final MethodHandle MH_SET_EXPIRATION = NativeLibrary.downcall( + "rocksdb_transaction_options_set_expiration", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transaction_options_get_expiration(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_EXPIRATION; + private static final MethodHandle MH_GET_EXPIRATION = NativeLibrary.downcall( + "rocksdb_transaction_options_get_expiration", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_deadlock_detect_depth(rocksdb_transaction_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_DEADLOCK_DETECT_DEPTH; + private static final MethodHandle MH_SET_DEADLOCK_DETECT_DEPTH = NativeLibrary.downcall( + "rocksdb_transaction_options_set_deadlock_detect_depth", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transaction_options_get_deadlock_detect_depth(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_DEADLOCK_DETECT_DEPTH; + private static final MethodHandle MH_GET_DEADLOCK_DETECT_DEPTH = NativeLibrary.downcall( + "rocksdb_transaction_options_get_deadlock_detect_depth", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_max_write_batch_size(rocksdb_transaction_options_t* opt, size_t v);` - private static final MethodHandle MH_SET_MAX_WRITE_BATCH_SIZE; + private static final MethodHandle MH_SET_MAX_WRITE_BATCH_SIZE = NativeLibrary.downcall( + "rocksdb_transaction_options_set_max_write_batch_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `size_t rocksdb_transaction_options_get_max_write_batch_size(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_MAX_WRITE_BATCH_SIZE; + private static final MethodHandle MH_GET_MAX_WRITE_BATCH_SIZE = NativeLibrary.downcall( + "rocksdb_transaction_options_get_max_write_batch_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_skip_concurrency_control(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SKIP_CONCURRENCY_CONTROL; + private static final MethodHandle MH_SET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( + "rocksdb_transaction_options_set_skip_concurrency_control", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_skip_concurrency_control(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_SKIP_CONCURRENCY_CONTROL; + private static final MethodHandle MH_GET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( + "rocksdb_transaction_options_get_skip_concurrency_control", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_skip_prepare(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SKIP_PREPARE; + private static final MethodHandle MH_SET_SKIP_PREPARE = NativeLibrary.downcall( + "rocksdb_transaction_options_set_skip_prepare", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_skip_prepare(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_SKIP_PREPARE; + private static final MethodHandle MH_GET_SKIP_PREPARE = NativeLibrary.downcall( + "rocksdb_transaction_options_get_skip_prepare", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_write_batch_flush_threshold(rocksdb_transaction_options_t* opt, int64_t v);` - private static final MethodHandle MH_SET_WRITE_BATCH_FLUSH_THRESHOLD; + private static final MethodHandle MH_SET_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_set_write_batch_flush_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `int64_t rocksdb_transaction_options_get_write_batch_flush_threshold(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_WRITE_BATCH_FLUSH_THRESHOLD; + private static final MethodHandle MH_GET_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_get_write_batch_flush_threshold", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_write_batch_track_timestamp_size(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE; + private static final MethodHandle MH_SET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE = NativeLibrary.downcall( + "rocksdb_transaction_options_set_write_batch_track_timestamp_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_write_batch_track_timestamp_size(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE; + private static final MethodHandle MH_GET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE = NativeLibrary.downcall( + "rocksdb_transaction_options_get_write_batch_track_timestamp_size", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_commit_bypass_memtable(rocksdb_transaction_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_COMMIT_BYPASS_MEMTABLE; + private static final MethodHandle MH_SET_COMMIT_BYPASS_MEMTABLE = NativeLibrary.downcall( + "rocksdb_transaction_options_set_commit_bypass_memtable", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_transaction_options_get_commit_bypass_memtable(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_COMMIT_BYPASS_MEMTABLE; + private static final MethodHandle MH_GET_COMMIT_BYPASS_MEMTABLE = NativeLibrary.downcall( + "rocksdb_transaction_options_get_commit_bypass_memtable", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_large_txn_commit_optimize_threshold(rocksdb_transaction_options_t* opt, uint32_t v);` - private static final MethodHandle MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD; + private static final MethodHandle MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_set_large_txn_commit_optimize_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `uint32_t rocksdb_transaction_options_get_large_txn_commit_optimize_threshold(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD; + private static final MethodHandle MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_get_large_txn_commit_optimize_threshold", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_transaction_options_set_large_txn_commit_optimize_byte_threshold(rocksdb_transaction_options_t* opt, uint64_t v);` - private static final MethodHandle MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD; + private static final MethodHandle MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_set_large_txn_commit_optimize_byte_threshold", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_transaction_options_get_large_txn_commit_optimize_byte_threshold(rocksdb_transaction_options_t* opt);` - private static final MethodHandle MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_transaction_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_transaction_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SET_SNAPSHOT = NativeLibrary.downcall("rocksdb_transaction_options_set_set_snapshot", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SET_SNAPSHOT = NativeLibrary.downcall("rocksdb_transaction_options_get_set_snapshot", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_DEADLOCK_DETECT = NativeLibrary.downcall("rocksdb_transaction_options_set_deadlock_detect", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_DEADLOCK_DETECT = NativeLibrary.downcall("rocksdb_transaction_options_get_deadlock_detect", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY = NativeLibrary.downcall( - "rocksdb_transaction_options_set_use_only_the_last_commit_time_batch_for_recovery", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_USE_ONLY_THE_LAST_COMMIT_TIME_BATCH_FOR_RECOVERY = NativeLibrary.downcall( - "rocksdb_transaction_options_get_use_only_the_last_commit_time_batch_for_recovery", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_LOCK_TIMEOUT = NativeLibrary.downcall("rocksdb_transaction_options_set_lock_timeout", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_LOCK_TIMEOUT = NativeLibrary.downcall("rocksdb_transaction_options_get_lock_timeout", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_DEADLOCK_TIMEOUT_US = NativeLibrary.downcall("rocksdb_transaction_options_set_deadlock_timeout_us", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_DEADLOCK_TIMEOUT_US = NativeLibrary.downcall("rocksdb_transaction_options_get_deadlock_timeout_us", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_EXPIRATION = NativeLibrary.downcall("rocksdb_transaction_options_set_expiration", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_EXPIRATION = NativeLibrary.downcall("rocksdb_transaction_options_get_expiration", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_DEADLOCK_DETECT_DEPTH = NativeLibrary.downcall("rocksdb_transaction_options_set_deadlock_detect_depth", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_DEADLOCK_DETECT_DEPTH = NativeLibrary.downcall("rocksdb_transaction_options_get_deadlock_detect_depth", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_MAX_WRITE_BATCH_SIZE = NativeLibrary.downcall("rocksdb_transaction_options_set_max_write_batch_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_GET_MAX_WRITE_BATCH_SIZE = NativeLibrary.downcall("rocksdb_transaction_options_get_max_write_batch_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( - "rocksdb_transaction_options_set_skip_concurrency_control", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SKIP_CONCURRENCY_CONTROL = NativeLibrary.downcall( - "rocksdb_transaction_options_get_skip_concurrency_control", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_SKIP_PREPARE = NativeLibrary.downcall("rocksdb_transaction_options_set_skip_prepare", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SKIP_PREPARE = NativeLibrary.downcall("rocksdb_transaction_options_get_skip_prepare", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_set_write_batch_flush_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_WRITE_BATCH_FLUSH_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_get_write_batch_flush_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - - MH_SET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE = NativeLibrary.downcall( - "rocksdb_transaction_options_set_write_batch_track_timestamp_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_WRITE_BATCH_TRACK_TIMESTAMP_SIZE = NativeLibrary.downcall( - "rocksdb_transaction_options_get_write_batch_track_timestamp_size", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_COMMIT_BYPASS_MEMTABLE = NativeLibrary.downcall( - "rocksdb_transaction_options_set_commit_bypass_memtable", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_COMMIT_BYPASS_MEMTABLE = NativeLibrary.downcall( - "rocksdb_transaction_options_get_commit_bypass_memtable", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_set_large_txn_commit_optimize_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_get_large_txn_commit_optimize_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_set_large_txn_commit_optimize_byte_threshold", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD = NativeLibrary.downcall( - "rocksdb_transaction_options_get_large_txn_commit_optimize_byte_threshold", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_LARGE_TXN_COMMIT_OPTIMIZE_BYTE_THRESHOLD = NativeLibrary.downcall( + "rocksdb_transaction_options_get_large_txn_commit_optimize_byte_threshold", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); /// Default options for [TransactionDB#beginTransaction(WriteOptions)]; immortal per /// [NativeObject#makeImmortal()]: never closed, and `close()` on it is a no-op. diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/TtlDB.java b/core/src/main/java/io/github/dfa1/rocksdbffm/TtlDB.java index d4671a76..441654be 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/TtlDB.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/TtlDB.java @@ -26,14 +26,9 @@ public final class TtlDB extends NativeDB RocksDBTracingOperations { /// `rocksdb_column_family_handle_t* rocksdb_create_column_family_with_ttl(rocksdb_t* db, const rocksdb_options_t* column_family_options, const char* column_family_name, int ttl, char** errptr);` - private static final MethodHandle MH_CREATE_CF_WITH_TTL; - - static { - MH_CREATE_CF_WITH_TTL = NativeLibrary.downcall("rocksdb_create_column_family_with_ttl", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, - ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_CREATE_CF_WITH_TTL = NativeLibrary.downcall( + "rocksdb_create_column_family_with_ttl", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private final Duration ttl; // null for a per-column-family open diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/UniversalCompactionOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/UniversalCompactionOptions.java index 105a2ffa..95f42afc 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/UniversalCompactionOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/UniversalCompactionOptions.java @@ -51,81 +51,61 @@ static StopStyle fromValue(int value) { } /// `rocksdb_universal_compaction_options_t* rocksdb_universal_compaction_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_destroy(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_size_ratio(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_SIZE_RATIO; + private static final MethodHandle MH_SET_SIZE_RATIO = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_size_ratio", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_size_ratio(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_SIZE_RATIO; + private static final MethodHandle MH_GET_SIZE_RATIO = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_size_ratio", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_min_merge_width(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_MIN_MERGE_WIDTH; + private static final MethodHandle MH_SET_MIN_MERGE_WIDTH = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_min_merge_width", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_min_merge_width(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_MIN_MERGE_WIDTH; + private static final MethodHandle MH_GET_MIN_MERGE_WIDTH = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_min_merge_width", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_max_merge_width(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_MAX_MERGE_WIDTH; + private static final MethodHandle MH_SET_MAX_MERGE_WIDTH = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_max_merge_width", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_max_merge_width(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_MAX_MERGE_WIDTH; + private static final MethodHandle MH_GET_MAX_MERGE_WIDTH = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_max_merge_width", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_max_size_amplification_percent(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_MAX_SIZE_AMPLIFICATION_PERCENT; + private static final MethodHandle MH_SET_MAX_SIZE_AMPLIFICATION_PERCENT = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_max_size_amplification_percent", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_max_size_amplification_percent(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_MAX_SIZE_AMPLIFICATION_PERCENT; + private static final MethodHandle MH_GET_MAX_SIZE_AMPLIFICATION_PERCENT = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_max_size_amplification_percent", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_compression_size_percent(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_COMPRESSION_SIZE_PERCENT; + private static final MethodHandle MH_SET_COMPRESSION_SIZE_PERCENT = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_compression_size_percent", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_compression_size_percent(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_COMPRESSION_SIZE_PERCENT; + private static final MethodHandle MH_GET_COMPRESSION_SIZE_PERCENT = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_compression_size_percent", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_universal_compaction_options_set_stop_style(rocksdb_universal_compaction_options_t*, int);` - private static final MethodHandle MH_SET_STOP_STYLE; + private static final MethodHandle MH_SET_STOP_STYLE = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_set_stop_style", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_universal_compaction_options_get_stop_style(rocksdb_universal_compaction_options_t*);` - private static final MethodHandle MH_GET_STOP_STYLE; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_universal_compaction_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_universal_compaction_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SIZE_RATIO = NativeLibrary.downcall("rocksdb_universal_compaction_options_set_size_ratio", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_SIZE_RATIO = NativeLibrary.downcall("rocksdb_universal_compaction_options_get_size_ratio", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MIN_MERGE_WIDTH = NativeLibrary.downcall("rocksdb_universal_compaction_options_set_min_merge_width", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MIN_MERGE_WIDTH = NativeLibrary.downcall("rocksdb_universal_compaction_options_get_min_merge_width", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MAX_MERGE_WIDTH = NativeLibrary.downcall("rocksdb_universal_compaction_options_set_max_merge_width", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_MERGE_WIDTH = NativeLibrary.downcall("rocksdb_universal_compaction_options_get_max_merge_width", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_MAX_SIZE_AMPLIFICATION_PERCENT = NativeLibrary.downcall( - "rocksdb_universal_compaction_options_set_max_size_amplification_percent", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_MAX_SIZE_AMPLIFICATION_PERCENT = NativeLibrary.downcall( - "rocksdb_universal_compaction_options_get_max_size_amplification_percent", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_COMPRESSION_SIZE_PERCENT = NativeLibrary.downcall( - "rocksdb_universal_compaction_options_set_compression_size_percent", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_COMPRESSION_SIZE_PERCENT = NativeLibrary.downcall( - "rocksdb_universal_compaction_options_get_compression_size_percent", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_STOP_STYLE = NativeLibrary.downcall("rocksdb_universal_compaction_options_set_stop_style", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_STOP_STYLE = NativeLibrary.downcall("rocksdb_universal_compaction_options_get_stop_style", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_STOP_STYLE = NativeLibrary.downcall( + "rocksdb_universal_compaction_options_get_stop_style", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private UniversalCompactionOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WaitForCompactOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WaitForCompactOptions.java index dd1bd121..20c321a7 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WaitForCompactOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WaitForCompactOptions.java @@ -18,57 +18,45 @@ public final class WaitForCompactOptions extends NativeObject { /// `rocksdb_wait_for_compact_options_t* rocksdb_wait_for_compact_options_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact_options_destroy(rocksdb_wait_for_compact_options_t* opt);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact_options_set_abort_on_pause(rocksdb_wait_for_compact_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_ABORT_ON_PAUSE; + private static final MethodHandle MH_SET_ABORT_ON_PAUSE = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_set_abort_on_pause", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_wait_for_compact_options_get_abort_on_pause(rocksdb_wait_for_compact_options_t* opt);` - private static final MethodHandle MH_GET_ABORT_ON_PAUSE; + private static final MethodHandle MH_GET_ABORT_ON_PAUSE = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_get_abort_on_pause", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact_options_set_flush(rocksdb_wait_for_compact_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_FLUSH; + private static final MethodHandle MH_SET_FLUSH = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_set_flush", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_wait_for_compact_options_get_flush(rocksdb_wait_for_compact_options_t* opt);` - private static final MethodHandle MH_GET_FLUSH; + private static final MethodHandle MH_GET_FLUSH = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_get_flush", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact_options_set_close_db(rocksdb_wait_for_compact_options_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_CLOSE_DB; + private static final MethodHandle MH_SET_CLOSE_DB = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_set_close_db", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_wait_for_compact_options_get_close_db(rocksdb_wait_for_compact_options_t* opt);` - private static final MethodHandle MH_GET_CLOSE_DB; + private static final MethodHandle MH_GET_CLOSE_DB = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_get_close_db", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_wait_for_compact_options_set_timeout(rocksdb_wait_for_compact_options_t* opt, uint64_t microseconds);` - private static final MethodHandle MH_SET_TIMEOUT; + private static final MethodHandle MH_SET_TIMEOUT = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_set_timeout", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG) + ); /// `uint64_t rocksdb_wait_for_compact_options_get_timeout(rocksdb_wait_for_compact_options_t* opt);` - private static final MethodHandle MH_GET_TIMEOUT; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_wait_for_compact_options_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_wait_for_compact_options_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_ABORT_ON_PAUSE = NativeLibrary.downcall("rocksdb_wait_for_compact_options_set_abort_on_pause", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_ABORT_ON_PAUSE = NativeLibrary.downcall("rocksdb_wait_for_compact_options_get_abort_on_pause", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_FLUSH = NativeLibrary.downcall("rocksdb_wait_for_compact_options_set_flush", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_FLUSH = NativeLibrary.downcall("rocksdb_wait_for_compact_options_get_flush", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_CLOSE_DB = NativeLibrary.downcall("rocksdb_wait_for_compact_options_set_close_db", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_CLOSE_DB = NativeLibrary.downcall("rocksdb_wait_for_compact_options_get_close_db", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_TIMEOUT = NativeLibrary.downcall("rocksdb_wait_for_compact_options_set_timeout", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_LONG)); - - MH_GET_TIMEOUT = NativeLibrary.downcall("rocksdb_wait_for_compact_options_get_timeout", - FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_TIMEOUT = NativeLibrary.downcall( + "rocksdb_wait_for_compact_options_get_timeout", FunctionDescriptor.of(ValueLayout.JAVA_LONG, ValueLayout.ADDRESS) + ); private WaitForCompactOptions(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WalIterator.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WalIterator.java index e7533a18..8f085d56 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WalIterator.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WalIterator.java @@ -29,33 +29,25 @@ public final class WalIterator extends NativeObject { /// `void rocksdb_wal_iter_next(rocksdb_wal_iterator_t* iter);` - private static final MethodHandle MH_NEXT; + private static final MethodHandle MH_NEXT = NativeLibrary.downcall( + "rocksdb_wal_iter_next", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `unsigned char rocksdb_wal_iter_valid(const rocksdb_wal_iterator_t*);` - private static final MethodHandle MH_VALID; + private static final MethodHandle MH_VALID = NativeLibrary.downcall( + "rocksdb_wal_iter_valid", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_wal_iter_status(const rocksdb_wal_iterator_t* iter, char** errptr);` - private static final MethodHandle MH_STATUS; + private static final MethodHandle MH_STATUS = NativeLibrary.downcall( + "rocksdb_wal_iter_status", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `rocksdb_writebatch_t* rocksdb_wal_iter_get_batch(const rocksdb_wal_iterator_t* iter, uint64_t* seq);` - private static final MethodHandle MH_GET_BATCH; + private static final MethodHandle MH_GET_BATCH = NativeLibrary.downcall( + "rocksdb_wal_iter_get_batch", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `void rocksdb_wal_iter_destroy(const rocksdb_wal_iterator_t* iter);` - private static final MethodHandle MH_DESTROY; - - static { - MH_NEXT = NativeLibrary.downcall("rocksdb_wal_iter_next", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_VALID = NativeLibrary.downcall("rocksdb_wal_iter_valid", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_STATUS = NativeLibrary.downcall("rocksdb_wal_iter_status", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_GET_BATCH = NativeLibrary.downcall("rocksdb_wal_iter_get_batch", - FunctionDescriptor.of(ValueLayout.ADDRESS, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_wal_iter_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_wal_iter_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); // rocksdb_wal_iter_get_batch is only safe to call once per position: a second call before // next() moves the iterator on crashes inside RocksDB's own WriteBatch move-assignment diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBatch.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBatch.java index df679856..8ad57da8 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBatch.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBatch.java @@ -15,89 +15,53 @@ public final class WriteBatch extends NativeObject { /// `rocksdb_writebatch_t* rocksdb_writebatch_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_writebatch_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_writebatch_destroy(rocksdb_writebatch_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_writebatch_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_writebatch_put(rocksdb_writebatch_t*, const char* key, size_t klen, const char* val, size_t vlen);` - private static final MethodHandle MH_PUT; + private static final MethodHandle MH_PUT = NativeLibrary.downcall( + "rocksdb_writebatch_put", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_delete(rocksdb_writebatch_t*, const char* key, size_t klen);` - private static final MethodHandle MH_DELETE; + private static final MethodHandle MH_DELETE = NativeLibrary.downcall( + "rocksdb_writebatch_delete", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_merge(rocksdb_writebatch_t*, const char* key, size_t klen, const char* val, size_t vlen);` - private static final MethodHandle MH_MERGE; + private static final MethodHandle MH_MERGE = NativeLibrary.downcall( + "rocksdb_writebatch_merge", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_delete_range(rocksdb_writebatch_t* b, const char* start_key, size_t start_key_len, const char* end_key, size_t end_key_len);` - private static final MethodHandle MH_DELETE_RANGE; + private static final MethodHandle MH_DELETE_RANGE = NativeLibrary.downcall( + "rocksdb_writebatch_delete_range", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_put_cf(rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, const char* val, size_t vlen);` - private static final MethodHandle MH_PUT_CF; + private static final MethodHandle MH_PUT_CF = NativeLibrary.downcall( + "rocksdb_writebatch_put_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_delete_cf(rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen);` - private static final MethodHandle MH_DELETE_CF; + private static final MethodHandle MH_DELETE_CF = NativeLibrary.downcall( + "rocksdb_writebatch_delete_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_merge_cf(rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, const char* val, size_t vlen);` - private static final MethodHandle MH_MERGE_CF; + private static final MethodHandle MH_MERGE_CF = NativeLibrary.downcall( + "rocksdb_writebatch_merge_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_delete_range_cf(rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, const char* start_key, size_t start_key_len, const char* end_key, size_t end_key_len);` - private static final MethodHandle MH_DELETE_RANGE_CF; + private static final MethodHandle MH_DELETE_RANGE_CF = NativeLibrary.downcall( + "rocksdb_writebatch_delete_range_cf", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_writebatch_clear(rocksdb_writebatch_t*);` - private static final MethodHandle MH_CLEAR; + private static final MethodHandle MH_CLEAR = NativeLibrary.downcall( + "rocksdb_writebatch_clear", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `int rocksdb_writebatch_count(rocksdb_writebatch_t*);` - private static final MethodHandle MH_COUNT; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_writebatch_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_writebatch_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_PUT = NativeLibrary.downcall("rocksdb_writebatch_put", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DELETE = NativeLibrary.downcall("rocksdb_writebatch_delete", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_MERGE = NativeLibrary.downcall("rocksdb_writebatch_merge", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DELETE_RANGE = NativeLibrary.downcall("rocksdb_writebatch_delete_range", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_PUT_CF = NativeLibrary.downcall("rocksdb_writebatch_put_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DELETE_CF = NativeLibrary.downcall("rocksdb_writebatch_delete_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_MERGE_CF = NativeLibrary.downcall("rocksdb_writebatch_merge_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_DELETE_RANGE_CF = NativeLibrary.downcall("rocksdb_writebatch_delete_range_cf", - FunctionDescriptor.ofVoid( - ValueLayout.ADDRESS, ValueLayout.ADDRESS, - ValueLayout.ADDRESS, NativeCalls.SIZE_T, - ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_CLEAR = NativeLibrary.downcall("rocksdb_writebatch_clear", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_COUNT = NativeLibrary.downcall("rocksdb_writebatch_count", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_COUNT = NativeLibrary.downcall( + "rocksdb_writebatch_count", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); private WriteBatch(MemorySegment ptr) { super(ptr); diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBufferManager.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBufferManager.java index 2416af3f..55ffae5f 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBufferManager.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteBufferManager.java @@ -27,94 +27,65 @@ public final class WriteBufferManager extends NativeObject { /// `rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create(size_t buffer_size, bool allow_stall);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_create", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.JAVA_BYTE) + ); /// `rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create_with_cache(size_t buffer_size, const rocksdb_cache_t* cache, bool allow_stall);` - private static final MethodHandle MH_CREATE_WITH_CACHE; + private static final MethodHandle MH_CREATE_WITH_CACHE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_create_with_cache", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `void rocksdb_write_buffer_manager_destroy(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `bool rocksdb_write_buffer_manager_enabled(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_ENABLED; + private static final MethodHandle MH_ENABLED = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_enabled", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `bool rocksdb_write_buffer_manager_cost_to_cache(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_COST_TO_CACHE; + private static final MethodHandle MH_COST_TO_CACHE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_cost_to_cache", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_write_buffer_manager_memory_usage(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_MEMORY_USAGE; + private static final MethodHandle MH_MEMORY_USAGE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_memory_usage", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_write_buffer_manager_mutable_memtable_memory_usage(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_MUTABLE_MEMTABLE_MEMORY_USAGE; + private static final MethodHandle MH_MUTABLE_MEMTABLE_MEMORY_USAGE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_mutable_memtable_memory_usage", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_write_buffer_manager_dummy_entries_in_cache_usage(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_DUMMY_ENTRIES_IN_CACHE_USAGE; + private static final MethodHandle MH_DUMMY_ENTRIES_IN_CACHE_USAGE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_dummy_entries_in_cache_usage", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `size_t rocksdb_write_buffer_manager_buffer_size(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_BUFFER_SIZE; + private static final MethodHandle MH_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_buffer_size", FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS) + ); /// `void rocksdb_write_buffer_manager_set_buffer_size(rocksdb_write_buffer_manager_t* wbm, size_t new_size);` - private static final MethodHandle MH_SET_BUFFER_SIZE; + private static final MethodHandle MH_SET_BUFFER_SIZE = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_set_buffer_size", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T) + ); /// `void rocksdb_write_buffer_manager_set_allow_stall(rocksdb_write_buffer_manager_t* wbm, bool new_allow_stall);` - private static final MethodHandle MH_SET_ALLOW_STALL; + private static final MethodHandle MH_SET_ALLOW_STALL = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_set_allow_stall", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create_with_policy(size_t buffer_size, bool allow_stall, int flush_policy);` - private static final MethodHandle MH_CREATE_WITH_POLICY; + private static final MethodHandle MH_CREATE_WITH_POLICY = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_create_with_policy", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.JAVA_BYTE, ValueLayout.JAVA_INT) + ); /// `rocksdb_write_buffer_manager_t* rocksdb_write_buffer_manager_create_with_cache_and_policy(size_t buffer_size, const rocksdb_cache_t* cache, bool allow_stall, int flush_policy);` - private static final MethodHandle MH_CREATE_WITH_CACHE_AND_POLICY; + private static final MethodHandle MH_CREATE_WITH_CACHE_AND_POLICY = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_create_with_cache_and_policy", FunctionDescriptor.of(ValueLayout.ADDRESS, NativeCalls.SIZE_T, ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE, ValueLayout.JAVA_INT) + ); /// `int rocksdb_write_buffer_manager_flush_policy(rocksdb_write_buffer_manager_t* wbm);` - private static final MethodHandle MH_FLUSH_POLICY; + private static final MethodHandle MH_FLUSH_POLICY = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_flush_policy", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_write_buffer_manager_set_flush_policy(rocksdb_write_buffer_manager_t* wbm, int flush_policy);` - private static final MethodHandle MH_SET_FLUSH_POLICY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_write_buffer_manager_create", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - ValueLayout.JAVA_BYTE)); - - MH_CREATE_WITH_CACHE = NativeLibrary.downcall("rocksdb_write_buffer_manager_create_with_cache", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - ValueLayout.ADDRESS, - ValueLayout.JAVA_BYTE)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_write_buffer_manager_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_ENABLED = NativeLibrary.downcall("rocksdb_write_buffer_manager_enabled", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_COST_TO_CACHE = NativeLibrary.downcall("rocksdb_write_buffer_manager_cost_to_cache", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_MEMORY_USAGE = NativeLibrary.downcall("rocksdb_write_buffer_manager_memory_usage", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_MUTABLE_MEMTABLE_MEMORY_USAGE = NativeLibrary.downcall("rocksdb_write_buffer_manager_mutable_memtable_memory_usage", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_DUMMY_ENTRIES_IN_CACHE_USAGE = NativeLibrary.downcall("rocksdb_write_buffer_manager_dummy_entries_in_cache_usage", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_BUFFER_SIZE = NativeLibrary.downcall("rocksdb_write_buffer_manager_buffer_size", - FunctionDescriptor.of(NativeCalls.SIZE_T, ValueLayout.ADDRESS)); - - MH_SET_BUFFER_SIZE = NativeLibrary.downcall("rocksdb_write_buffer_manager_set_buffer_size", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, NativeCalls.SIZE_T)); - - MH_SET_ALLOW_STALL = NativeLibrary.downcall("rocksdb_write_buffer_manager_set_allow_stall", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_CREATE_WITH_POLICY = NativeLibrary.downcall("rocksdb_write_buffer_manager_create_with_policy", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - ValueLayout.JAVA_BYTE, - ValueLayout.JAVA_INT)); - - MH_CREATE_WITH_CACHE_AND_POLICY = NativeLibrary.downcall("rocksdb_write_buffer_manager_create_with_cache_and_policy", - FunctionDescriptor.of(ValueLayout.ADDRESS, - NativeCalls.SIZE_T, - ValueLayout.ADDRESS, - ValueLayout.JAVA_BYTE, - ValueLayout.JAVA_INT)); - - MH_FLUSH_POLICY = NativeLibrary.downcall("rocksdb_write_buffer_manager_flush_policy", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_FLUSH_POLICY = NativeLibrary.downcall("rocksdb_write_buffer_manager_set_flush_policy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - } + private static final MethodHandle MH_SET_FLUSH_POLICY = NativeLibrary.downcall( + "rocksdb_write_buffer_manager_set_flush_policy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// Policy choosing which memtable is flushed once the shared write-buffer budget is hit. public enum FlushPolicy { diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteOptions.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteOptions.java index 1f30d849..f6007fd6 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteOptions.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteOptions.java @@ -9,101 +9,77 @@ public final class WriteOptions extends NativeObject { /// `rocksdb_writeoptions_t* rocksdb_writeoptions_create(void);` - private static final MethodHandle MH_CREATE; + private static final MethodHandle MH_CREATE = NativeLibrary.downcall( + "rocksdb_writeoptions_create", FunctionDescriptor.of(ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_destroy(rocksdb_writeoptions_t*);` - private static final MethodHandle MH_DESTROY; + private static final MethodHandle MH_DESTROY = NativeLibrary.downcall( + "rocksdb_writeoptions_destroy", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_sync(rocksdb_writeoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_SYNC; + private static final MethodHandle MH_SET_SYNC = NativeLibrary.downcall( + "rocksdb_writeoptions_set_sync", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_writeoptions_get_sync(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_SYNC; + private static final MethodHandle MH_GET_SYNC = NativeLibrary.downcall( + "rocksdb_writeoptions_get_sync", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_disable_WAL(rocksdb_writeoptions_t* opt, int v);` - private static final MethodHandle MH_DISABLE_WAL; + private static final MethodHandle MH_DISABLE_WAL = NativeLibrary.downcall( + "rocksdb_writeoptions_disable_WAL", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `unsigned char rocksdb_writeoptions_get_disable_WAL(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_DISABLE_WAL; + private static final MethodHandle MH_GET_DISABLE_WAL = NativeLibrary.downcall( + "rocksdb_writeoptions_get_disable_WAL", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_ignore_missing_column_families(rocksdb_writeoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_IGNORE_MISSING_COLUMN_FAMILIES; + private static final MethodHandle MH_SET_IGNORE_MISSING_COLUMN_FAMILIES = NativeLibrary.downcall( + "rocksdb_writeoptions_set_ignore_missing_column_families", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_writeoptions_get_ignore_missing_column_families(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_IGNORE_MISSING_COLUMN_FAMILIES; + private static final MethodHandle MH_GET_IGNORE_MISSING_COLUMN_FAMILIES = NativeLibrary.downcall( + "rocksdb_writeoptions_get_ignore_missing_column_families", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_no_slowdown(rocksdb_writeoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_NO_SLOWDOWN; + private static final MethodHandle MH_SET_NO_SLOWDOWN = NativeLibrary.downcall( + "rocksdb_writeoptions_set_no_slowdown", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_writeoptions_get_no_slowdown(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_NO_SLOWDOWN; + private static final MethodHandle MH_GET_NO_SLOWDOWN = NativeLibrary.downcall( + "rocksdb_writeoptions_get_no_slowdown", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_low_pri(rocksdb_writeoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_LOW_PRI; + private static final MethodHandle MH_SET_LOW_PRI = NativeLibrary.downcall( + "rocksdb_writeoptions_set_low_pri", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_writeoptions_get_low_pri(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_LOW_PRI; + private static final MethodHandle MH_GET_LOW_PRI = NativeLibrary.downcall( + "rocksdb_writeoptions_get_low_pri", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_memtable_insert_hint_per_batch(rocksdb_writeoptions_t* opt, unsigned char v);` - private static final MethodHandle MH_SET_MEMTABLE_INSERT_HINT_PER_BATCH; + private static final MethodHandle MH_SET_MEMTABLE_INSERT_HINT_PER_BATCH = NativeLibrary.downcall( + "rocksdb_writeoptions_set_memtable_insert_hint_per_batch", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE) + ); /// `unsigned char rocksdb_writeoptions_get_memtable_insert_hint_per_batch(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_MEMTABLE_INSERT_HINT_PER_BATCH; + private static final MethodHandle MH_GET_MEMTABLE_INSERT_HINT_PER_BATCH = NativeLibrary.downcall( + "rocksdb_writeoptions_get_memtable_insert_hint_per_batch", FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_rate_limiter_priority(rocksdb_writeoptions_t* opt, int v);` - private static final MethodHandle MH_SET_RATE_LIMITER_PRIORITY; + private static final MethodHandle MH_SET_RATE_LIMITER_PRIORITY = NativeLibrary.downcall( + "rocksdb_writeoptions_set_rate_limiter_priority", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_writeoptions_get_rate_limiter_priority(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_RATE_LIMITER_PRIORITY; + private static final MethodHandle MH_GET_RATE_LIMITER_PRIORITY = NativeLibrary.downcall( + "rocksdb_writeoptions_get_rate_limiter_priority", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// `void rocksdb_writeoptions_set_io_activity(rocksdb_writeoptions_t* opt, int v);` - private static final MethodHandle MH_SET_IO_ACTIVITY; + private static final MethodHandle MH_SET_IO_ACTIVITY = NativeLibrary.downcall( + "rocksdb_writeoptions_set_io_activity", FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT) + ); /// `int rocksdb_writeoptions_get_io_activity(rocksdb_writeoptions_t* opt);` - private static final MethodHandle MH_GET_IO_ACTIVITY; - - static { - MH_CREATE = NativeLibrary.downcall("rocksdb_writeoptions_create", - FunctionDescriptor.of(ValueLayout.ADDRESS)); - - MH_DESTROY = NativeLibrary.downcall("rocksdb_writeoptions_destroy", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS)); - - MH_SET_SYNC = NativeLibrary.downcall("rocksdb_writeoptions_set_sync", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_SYNC = NativeLibrary.downcall("rocksdb_writeoptions_get_sync", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_DISABLE_WAL = NativeLibrary.downcall("rocksdb_writeoptions_disable_WAL", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_DISABLE_WAL = NativeLibrary.downcall("rocksdb_writeoptions_get_disable_WAL", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_IGNORE_MISSING_COLUMN_FAMILIES = NativeLibrary.downcall( - "rocksdb_writeoptions_set_ignore_missing_column_families", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_IGNORE_MISSING_COLUMN_FAMILIES = NativeLibrary.downcall( - "rocksdb_writeoptions_get_ignore_missing_column_families", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_NO_SLOWDOWN = NativeLibrary.downcall("rocksdb_writeoptions_set_no_slowdown", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_NO_SLOWDOWN = NativeLibrary.downcall("rocksdb_writeoptions_get_no_slowdown", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_LOW_PRI = NativeLibrary.downcall("rocksdb_writeoptions_set_low_pri", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_LOW_PRI = NativeLibrary.downcall("rocksdb_writeoptions_get_low_pri", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_MEMTABLE_INSERT_HINT_PER_BATCH = NativeLibrary.downcall( - "rocksdb_writeoptions_set_memtable_insert_hint_per_batch", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_BYTE)); - - MH_GET_MEMTABLE_INSERT_HINT_PER_BATCH = NativeLibrary.downcall( - "rocksdb_writeoptions_get_memtable_insert_hint_per_batch", - FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS)); - - MH_SET_RATE_LIMITER_PRIORITY = NativeLibrary.downcall("rocksdb_writeoptions_set_rate_limiter_priority", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_RATE_LIMITER_PRIORITY = NativeLibrary.downcall("rocksdb_writeoptions_get_rate_limiter_priority", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - - MH_SET_IO_ACTIVITY = NativeLibrary.downcall("rocksdb_writeoptions_set_io_activity", - FunctionDescriptor.ofVoid(ValueLayout.ADDRESS, ValueLayout.JAVA_INT)); - - MH_GET_IO_ACTIVITY = NativeLibrary.downcall("rocksdb_writeoptions_get_io_activity", - FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS)); - } + private static final MethodHandle MH_GET_IO_ACTIVITY = NativeLibrary.downcall( + "rocksdb_writeoptions_get_io_activity", FunctionDescriptor.of(ValueLayout.JAVA_INT, ValueLayout.ADDRESS) + ); /// RocksDB-default WriteOptions for the get/put overloads that take none; a native read/write call only reads /// the struct, so one instance serves every open DB. Immortal per [NativeObject#makeImmortal()]: diff --git a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteStallInfo.java b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteStallInfo.java index 6d16041b..6e559c5d 100644 --- a/core/src/main/java/io/github/dfa1/rocksdbffm/WriteStallInfo.java +++ b/core/src/main/java/io/github/dfa1/rocksdbffm/WriteStallInfo.java @@ -16,16 +16,18 @@ public final class WriteStallInfo { /// `const char* rocksdb_writestallinfo_cf_name(const rocksdb_writestallinfo_t*, size_t* size);` private static final MethodHandle MH_CF_NAME = NativeLibrary.downcall( - "rocksdb_writestallinfo_cf_name", - FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_writestallinfo_cf_name", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const rocksdb_writestallcondition_t* rocksdb_writestallinfo_cur(const rocksdb_writestallinfo_t*);` private static final MethodHandle MH_CUR = NativeLibrary.downcall( - "rocksdb_writestallinfo_cur", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_writestallinfo_cur", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); /// `const rocksdb_writestallcondition_t* rocksdb_writestallinfo_prev(const rocksdb_writestallinfo_t*);` private static final MethodHandle MH_PREV = NativeLibrary.downcall( - "rocksdb_writestallinfo_prev", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS)); + "rocksdb_writestallinfo_prev", FunctionDescriptor.of(ValueLayout.ADDRESS, ValueLayout.ADDRESS) + ); private final MemorySegment ptr; diff --git a/scripts/CheckPrototypes.java b/scripts/CheckPrototypes.java index c952877e..9db7aa05 100644 --- a/scripts/CheckPrototypes.java +++ b/scripts/CheckPrototypes.java @@ -23,6 +23,8 @@ /// fields are covered: the upcall descriptors (`MergeOperator`, `CompactionFilter`, `Logger`, ...) and the `size_t*` /// slots are not, and stay a review concern. /// +/// Every `MH_` field is also required to use the shape `= NativeLibrary.downcall(` / name and descriptor / `);`. +/// /// Run from the repository root: `java scripts/CheckPrototypes.java`. static final Path C_H = Path.of("rocksdb/include/rocksdb/c.h"); @@ -160,6 +162,11 @@ void main() throws Exception { continue; } String where = source + ":" + (i + 1); + if (!lines.get(i).matches("\\t+private static final MethodHandle MH_\\w+ = NativeLibrary\\.downcall\\(")) { + errors.add(where + ": MH_ field must be initialized inline: `= NativeLibrary.downcall(`, then the symbol name and descriptor, then `);` on its own line"); + } else if (lines.subList(i + 1, lines.size()).stream().dropWhile(l -> !l.matches("\\t+\\);") && !l.contains("MethodHandle MH_")).findFirst().filter(l -> l.matches("\\t+\\);")).isEmpty()) { + errors.add(where + ": the closing `);` of the MH_ initializer must be on its own line"); + } int docStart = i; while (docStart > 0 && lines.get(docStart - 1).strip().startsWith("///")) { docStart--;