@nxtedition/rocksdb 13.3.1 → 13.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.cc CHANGED
@@ -904,18 +904,20 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
904
904
  NAPI_STATUS_RETURN(GetProperty(env, options, "optimizeFiltersForHits", columnOptions.optimize_filters_for_hits));
905
905
  NAPI_STATUS_RETURN(GetProperty(env, options, "periodicCompactionSeconds", columnOptions.periodic_compaction_seconds));
906
906
 
907
+ // Compat
907
908
  NAPI_STATUS_RETURN(GetProperty(env, options, "enableBlobFiles", columnOptions.enable_blob_files));
908
909
  NAPI_STATUS_RETURN(GetProperty(env, options, "minBlobSize", columnOptions.min_blob_size));
909
- NAPI_STATUS_RETURN(GetProperty(env, options, "blobFileSize", columnOptions.blob_file_size));
910
910
  NAPI_STATUS_RETURN(GetProperty(env, options, "enableBlobGarbageCollection", columnOptions.enable_blob_garbage_collection));
911
+
912
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobFiles", columnOptions.enable_blob_files));
913
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobMinSize", columnOptions.min_blob_size));
914
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobGarbageCollection", columnOptions.enable_blob_garbage_collection));
915
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobFileSize", columnOptions.blob_file_size));
911
916
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobGarbageCollectionAgeCutoff", columnOptions.blob_garbage_collection_age_cutoff));
912
917
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobGarbageCollectionForceThreshold", columnOptions.blob_garbage_collection_force_threshold));
913
918
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobCompactionReadaheadSize", columnOptions.blob_compaction_readahead_size));
914
919
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobFileStartingLevel", columnOptions.blob_file_starting_level));
915
-
916
- bool blobCompression = true;
917
- NAPI_STATUS_RETURN(GetProperty(env, options, "blobCompression", blobCompression));
918
- columnOptions.blob_compression_type = blobCompression ? rocksdb::kZSTD : rocksdb::kNoCompression;
920
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobCompression", columnOptions.blob_compression_type));
919
921
 
920
922
  rocksdb::BlockBasedTableOptions tableOptions;
921
923
  tableOptions.decouple_partitioned_filters = true;
@@ -923,10 +925,15 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
923
925
  {
924
926
  uint32_t cacheSize = 8 << 20;
925
927
  double compressedRatio = 0.0;
928
+
929
+ // Compat
926
930
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheSize", cacheSize));
927
931
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheCompressedRatio", compressedRatio));
932
+ NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlockCache", tableOptions.prepopulate_block_cache));
933
+
928
934
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockCacheSize", cacheSize));
929
935
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockCacheCompressedRatio", compressedRatio));
936
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blockCachePrepopulate", tableOptions.prepopulate_block_cache));
930
937
 
931
938
  if (cacheSize == 0) {
932
939
  tableOptions.no_block_cache = true;
@@ -939,19 +946,18 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
939
946
  } else {
940
947
  tableOptions.block_cache = rocksdb::HyperClockCacheOptions(cacheSize, 0).MakeSharedCache();
941
948
  }
942
-
943
- bool prepopulateBlockCache = false;
944
- NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlockCache", prepopulateBlockCache));
945
- tableOptions.prepopulate_block_cache = prepopulateBlockCache
946
- ? rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kFlushOnly
947
- : rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kDisable;
948
949
  }
949
950
 
950
951
  {
951
952
  uint32_t cacheSize = -1;
952
953
  double compressedRatio = 0.0;
954
+
955
+ // Compat
956
+ NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlobCache", columnOptions.prepopulate_blob_cache));
957
+
953
958
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobCacheSize", cacheSize));
954
959
  NAPI_STATUS_RETURN(GetProperty(env, options, "blobCacheCompressedRatio", compressedRatio));
960
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blobCachePrepopulate", columnOptions.prepopulate_blob_cache));
955
961
 
956
962
  if (cacheSize == -1) {
957
963
  columnOptions.blob_cache = tableOptions.block_cache;
@@ -966,10 +972,6 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
966
972
  } else {
967
973
  columnOptions.blob_cache = rocksdb::HyperClockCacheOptions(cacheSize, 0).MakeSharedCache();
968
974
  }
969
-
970
- bool prepopulateBlobCache = false;
971
- NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlobCache", prepopulateBlobCache));
972
- columnOptions.prepopulate_blob_cache = prepopulateBlobCache ? rocksdb::PrepopulateBlobCache::kFlushOnly : rocksdb::PrepopulateBlobCache::kDisable;
973
975
  }
974
976
 
975
977
  std::string optimize = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "13.3.1",
3
+ "version": "13.4.0",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
package/util.h CHANGED
@@ -283,6 +283,82 @@ static napi_status GetValue(napi_env env, napi_value value, Encoding& result) {
283
283
  return napi_ok;
284
284
  }
285
285
 
286
+ static napi_status GetValue(napi_env env, napi_value value, rocksdb::BlockBasedTableOptions::PrepopulateBlockCache& result) {
287
+ std::string str;
288
+
289
+ if (GetValue(env, value, str) == napi_ok) {
290
+ if (str == "flushOnly") {
291
+ result = rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kFlushOnly;
292
+ } else if (str == "disable") {
293
+ result = rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kDisable;
294
+ } else {
295
+ return napi_invalid_arg;
296
+ }
297
+ }
298
+
299
+ bool boolean;
300
+ if (GetValue(env, value, boolean) == napi_ok) {
301
+ result = boolean ? rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kFlushOnly
302
+ : rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kDisable;
303
+ }
304
+
305
+ return napi_invalid_arg;
306
+ }
307
+
308
+ static napi_status GetValue(napi_env env, napi_value value, rocksdb::PrepopulateBlobCache& result) {
309
+ std::string str;
310
+
311
+ if (GetValue(env, value, str) == napi_ok) {
312
+ if (str == "flushOnly") {
313
+ result = rocksdb::PrepopulateBlobCache::kFlushOnly;
314
+ } else if (str == "disable") {
315
+ result = rocksdb::PrepopulateBlobCache::kDisable;
316
+ } else {
317
+ return napi_invalid_arg;
318
+ }
319
+ }
320
+
321
+ bool boolean;
322
+ if (GetValue(env, value, boolean) == napi_ok) {
323
+ result = boolean ? rocksdb::PrepopulateBlobCache::kFlushOnly
324
+ : rocksdb::PrepopulateBlobCache::kDisable;
325
+ }
326
+
327
+ return napi_invalid_arg;
328
+ }
329
+
330
+ static napi_status GetValue(napi_env env, napi_value value, rocksdb::CompressionType& result) {
331
+ std::string str;
332
+
333
+ if (GetValue(env, value, str) == napi_ok) {
334
+ if (str == "no") {
335
+ result = rocksdb::CompressionType::kNoCompression;
336
+ } else if (str == "snappy") {
337
+ result = rocksdb::CompressionType::kSnappyCompression;
338
+ } else if (str == "zlib") {
339
+ result = rocksdb::CompressionType::kZlibCompression;
340
+ } else if (str == "bzip2") {
341
+ result = rocksdb::CompressionType::kBZip2Compression;
342
+ } else if (str == "lz4") {
343
+ result = rocksdb::CompressionType::kLZ4Compression;
344
+ } else if (str == "lz4hc") {
345
+ result = rocksdb::CompressionType::kLZ4HCCompression;
346
+ } else if (str == "xpress") {
347
+ result = rocksdb::CompressionType::kXpressCompression;
348
+ } else if (str == "zstd") {
349
+ result = rocksdb::CompressionType::kZSTD;
350
+ }
351
+ }
352
+
353
+ bool boolean;
354
+ if (GetValue(env, value, boolean) == napi_ok) {
355
+ result = boolean ? rocksdb::kZSTD
356
+ : rocksdb::kNoCompression;
357
+ }
358
+
359
+ return napi_invalid_arg;
360
+ }
361
+
286
362
  template <typename T>
287
363
  static napi_status GetValue(napi_env env, napi_value value, std::optional<T>& result) {
288
364
  result = T{};