From 35bc78b37a9d5fe18a2a3f3b269e5be35a687f6f Mon Sep 17 00:00:00 2001 From: mrambacher Date: Thu, 9 Nov 2023 05:42:34 -0500 Subject: [PATCH] Address comments --- HISTORY.md | 2 +- db/c.cc | 16 +++++++++++----- include/rocksdb/c.h | 8 ++++++-- java/rocksjni/options.cc | 14 ++++++-------- java/src/main/java/org/rocksdb/RocksDB.java | 2 -- .../src/main/java/org/rocksdb/SharedOptions.java | 6 +++--- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index bba4ef8ced..8d02469530 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ # Speedb Change Log ## Unreleased +* Enabled speedb features in C and Java (#722) ### New Features * Added ConfigOptions::compare_to. When set, this value causes only values that have been changed to be part of the serialized output (#648). @@ -25,7 +26,6 @@ Based on RocksDB 8.1.1 * Static Pinning: Report pinning policy name and parameters to the log (#691). * LOG Reporting: add reporting capabilities to the WriteController and the WriteBufferManager by saving the Loggers of the dbs which are using them internally and issuing WARN msgs to these Loggers whenever the state of the WC and WBM changes in regards to delaying (#556). * Enable speedb features: Use Scoped Pinning Policy in Enable speedb feature (#459). -* Enabled speedb features in C and Java (#722) * sst_dump: display metaindex_handle and the index_handle's offset and size in footer information (#404). * Static Pinning: Set the default for mid-percent capacity threshold in scoped pinning policy to 70 (#689). * db_bench: Add support for individual scoped pinning policy parameters (#687). diff --git a/db/c.cc b/db/c.cc index 0c30c2a682..4963a6e364 100644 --- a/db/c.cc +++ b/db/c.cc @@ -2796,8 +2796,8 @@ void rocksdb_options_optimize_universal_style_compaction( opt->rep.OptimizeUniversalStyleCompaction(memtable_memory_budget); } -void rocksdb_options_enable_speedb(rocksdb_options_t* opt, - rocksdb_shared_options_t* shared) { +void rocksdb_options_enable_speedb_features(rocksdb_options_t* opt, + rocksdb_shared_options_t* shared) { opt->rep.EnableSpeedbFeatures(shared->rep); } @@ -3897,9 +3897,10 @@ rocksdb_shared_options_t* rocksdb_shared_options_create( } rocksdb_shared_options_t* rocksdb_shared_options_create_from( size_t total_ram_size_bytes, size_t total_threads, - size_t delayed_write_rate, int use_merge) { - return new rocksdb_shared_options_t{SharedOptions( - total_ram_size_bytes, total_threads, delayed_write_rate, use_merge)}; + size_t delayed_write_rate, size_t bucket_size, int use_merge) { + return new rocksdb_shared_options_t{ + SharedOptions(total_ram_size_bytes, total_threads, delayed_write_rate, + bucket_size, use_merge)}; } void rocksdb_shared_options_destroy(rocksdb_shared_options_t* opt) { @@ -3929,6 +3930,11 @@ size_t rocksdb_shared_options_get_bucket_size(rocksdb_shared_options_t* opt) { return opt->rep.GetBucketSize(); } +unsigned char rocksdb_shared_options_is_merge_memtable_supported( + rocksdb_shared_options_t* opt) { + return opt->rep.IsMergeMemtableSupported(); +} + rocksdb_ratelimiter_t* rocksdb_ratelimiter_create(int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness) { diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index 6a583a4152..82fbc8c3d4 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -1103,7 +1103,7 @@ extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_for_point_lookup( rocksdb_options_t* opt, uint64_t block_cache_size_mb); extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_level_style_compaction( rocksdb_options_t* opt, uint64_t memtable_memory_budget); -extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_speedb( +extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_speedb_features( rocksdb_options_t* opt, rocksdb_shared_options_t* shared); extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_universal_style_compaction( @@ -1652,7 +1652,8 @@ rocksdb_shared_options_create(size_t total_ram_size_bytes, extern ROCKSDB_LIBRARY_API rocksdb_shared_options_t* rocksdb_shared_options_create_from(size_t total_ram_size_bytes, size_t total_threads, - size_t delayed_write_rate, int use_merge); + size_t delayed_write_rate, + size_t bucket_size, int use_merge); extern ROCKSDB_LIBRARY_API void rocksdb_shared_options_destroy( rocksdb_shared_options_t* options); extern ROCKSDB_LIBRARY_API size_t @@ -1666,6 +1667,9 @@ extern ROCKSDB_LIBRARY_API size_t rocksdb_shared_options_get_delayed_write_rate(rocksdb_shared_options_t* opt); extern ROCKSDB_LIBRARY_API size_t rocksdb_shared_options_get_bucket_size(rocksdb_shared_options_t* options); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_shared_options_is_merge_memtable_supported( + rocksdb_shared_options_t* options); /* RateLimiter */ extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t* rocksdb_ratelimiter_create( diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index a0275b8a7d..aecef6d5e2 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -1,5 +1,4 @@ // Copyright (C) 2023 Speedb Ltd. All rights reserved. - // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +13,6 @@ // limitations under the License. // // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. -// // This source code is licensed under both the GPLv2 (found in the // COPYING file in the root directory) and Apache 2.0 License // (found in the LICENSE.Apache file in the root directory). @@ -8758,20 +8756,20 @@ void Java_org_rocksdb_FlushOptions_disposeInternal(JNIEnv*, jobject, /* * Class: org_rocksdb_SharedOptions * Method: newSharedOptions - * Signature: (JJJ)J + * Signature: (JJJJZ)J */ -JNIEXPORT jlong JNICALL Java_org_rocksdb_SharedOptions_newSharedOptions__JJJZ( +JNIEXPORT jlong JNICALL Java_org_rocksdb_SharedOptions_newSharedOptions__JJJJZ( JNIEnv*, jclass, jlong capacity, jlong total_threads, - jlong delayed_write_rate, jboolean use_merge) { + jlong delayed_write_rate, jlong bucket_size, jboolean use_merge) { auto opts = new ROCKSDB_NAMESPACE::SharedOptions( - capacity, total_threads, delayed_write_rate, use_merge); + capacity, total_threads, delayed_write_rate, bucket_size, use_merge); return GET_CPLUSPLUS_POINTER(opts); } /* * Class: org_rocksdb_SharedOptions * Method: newSharedOptions - * Signature: (JJJ)J + * Signature: (JJ)J */ JNIEXPORT jlong JNICALL Java_org_rocksdb_SharedOptions_newSharedOptions__JJ( JNIEnv*, jclass, jlong capacity, jlong total_threads) { @@ -8846,7 +8844,7 @@ Java_org_rocksdb_SharedOptions_getMaxWriteBufferManagerSize(JNIEnv*, jclass, * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_org_rocksdb_SharedOptions_getBucketize(JNIEnv*, jclass, jlong jhandle) { +Java_org_rocksdb_SharedOptions_getBucketSize(JNIEnv*, jclass, jlong jhandle) { auto* opts = reinterpret_cast(jhandle); assert(opts != nullptr); return opts->GetBucketSize(); diff --git a/java/src/main/java/org/rocksdb/RocksDB.java b/java/src/main/java/org/rocksdb/RocksDB.java index 4dc1dd5a0d..7a5dc1d9f2 100644 --- a/java/src/main/java/org/rocksdb/RocksDB.java +++ b/java/src/main/java/org/rocksdb/RocksDB.java @@ -136,8 +136,6 @@ public static void loadLibrary(final List paths) { UnsatisfiedLinkError err = null; for (final String path : paths) { try { - System.err.println("**MJR: JNI file=[" + path + "/" - + Environment.getJniLibraryFileName("speedbjni") + "]"); System.load(path + "/" + Environment.getJniLibraryFileName("speedbjni")); success = true; break; diff --git a/java/src/main/java/org/rocksdb/SharedOptions.java b/java/src/main/java/org/rocksdb/SharedOptions.java index e1d4b9dedd..666c533bd6 100644 --- a/java/src/main/java/org/rocksdb/SharedOptions.java +++ b/java/src/main/java/org/rocksdb/SharedOptions.java @@ -22,8 +22,8 @@ public SharedOptions(final long capacity, final long total_threads) { } public SharedOptions(final long capacity, final long total_threads, final long delayed_write_rate, - final boolean use_merge) { - super(newSharedOptions(capacity, total_threads, delayed_write_rate, use_merge)); + final long bucket_size, final boolean use_merge) { + super(newSharedOptions(capacity, total_threads, delayed_write_rate, bucket_size, use_merge)); } public long getTotalThreads() { @@ -57,7 +57,7 @@ public long isMergeMemtableSupported() { } private native static long newSharedOptions(final long capacity, final long total_threads, - final long delayed_write_rate, final boolean use_merge); + final long delayed_write_rate, final long bucket_size, final boolean use_merge); private native static long newSharedOptions(final long capacity, final long total_threads); @Override protected final native void disposeInternal(final long handle); private native static long getTotalThreads(final long handle);