@nxtedition/rocksdb 13.1.1 → 13.1.2

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
@@ -850,53 +850,57 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
850
850
  // TODO (perf): compression_opts.parallel_threads
851
851
  }
852
852
 
853
- std::optional<std::string> prefixExtractorOpt;
854
- NAPI_STATUS_RETURN(GetProperty(env, options, "prefixExtractor", prefixExtractorOpt));
855
- if (prefixExtractorOpt) {
853
+ std::string prefixExtractor;
854
+ NAPI_STATUS_RETURN(GetProperty(env, options, "prefixExtractor", prefixExtractor));
855
+ if (prefixExtractor == "") {
856
+ // Do nothing...
857
+ } else {
856
858
  ROCKS_STATUS_RETURN_NAPI(
857
- rocksdb::SliceTransform::CreateFromString(configOptions, *prefixExtractorOpt, &columnOptions.prefix_extractor));
859
+ rocksdb::SliceTransform::CreateFromString(configOptions, prefixExtractor, &columnOptions.prefix_extractor));
858
860
  }
859
861
 
860
- std::optional<std::string> comparatorOpt;
861
- NAPI_STATUS_RETURN(GetProperty(env, options, "comparator", comparatorOpt));
862
- if (comparatorOpt) {
862
+ std::string comparator;
863
+ NAPI_STATUS_RETURN(GetProperty(env, options, "comparator", comparator));
864
+ if (comparator == "") {
865
+ // Do nothing...
866
+ } else {
863
867
  ROCKS_STATUS_RETURN_NAPI(
864
- rocksdb::Comparator::CreateFromString(configOptions, *comparatorOpt, &columnOptions.comparator));
868
+ rocksdb::Comparator::CreateFromString(configOptions, comparator, &columnOptions.comparator));
865
869
  }
866
870
 
867
- std::optional<std::string> mergeOperatorOpt;
868
- NAPI_STATUS_RETURN(GetProperty(env, options, "mergeOperator", mergeOperatorOpt));
869
- if (mergeOperatorOpt) {
870
- if (*mergeOperatorOpt == "maxRev") {
871
- columnOptions.merge_operator = std::make_shared<MaxRevOperator>();
872
- } else {
873
- ROCKS_STATUS_RETURN_NAPI(
874
- rocksdb::MergeOperator::CreateFromString(configOptions, *mergeOperatorOpt, &columnOptions.merge_operator));
875
- }
871
+ std::string mergeOperator;
872
+ NAPI_STATUS_RETURN(GetProperty(env, options, "mergeOperator", mergeOperator));
873
+ if (mergeOperator == "") {
874
+ // Do nothing...
875
+ } else if (mergeOperator == "maxRev") {
876
+ columnOptions.merge_operator = std::make_shared<MaxRevOperator>();
877
+ } else {
878
+ ROCKS_STATUS_RETURN_NAPI(
879
+ rocksdb::MergeOperator::CreateFromString(configOptions, mergeOperator, &columnOptions.merge_operator));
876
880
  }
877
881
 
878
- std::optional<std::string> compactionPriority;
882
+ std::string compactionPriority;
879
883
  NAPI_STATUS_RETURN(GetProperty(env, options, "compactionPriority", compactionPriority));
880
- if (compactionPriority) {
881
- if (compactionPriority == "byCompensatedSize") {
882
- columnOptions.compaction_pri = rocksdb::kByCompensatedSize;
883
- } else if (compactionPriority == "oldestLargestSeqFirst") {
884
- columnOptions.compaction_pri = rocksdb::kOldestLargestSeqFirst;
885
- } else if (compactionPriority == "smallestSeqFirst") {
886
- columnOptions.compaction_pri = rocksdb::kOldestSmallestSeqFirst;
887
- } else if (compactionPriority == "overlappingRatio") {
888
- columnOptions.compaction_pri = rocksdb::kMinOverlappingRatio;
889
- } else if (compactionPriority == "roundRobin") {
890
- columnOptions.compaction_pri = rocksdb::kRoundRobin;
891
- } else {
892
- // Throw?
893
- }
884
+ if (compactionPriority == "") {
885
+ // Do nothing...
886
+ } else if (compactionPriority == "byCompensatedSize") {
887
+ columnOptions.compaction_pri = rocksdb::kByCompensatedSize;
888
+ } else if (compactionPriority == "oldestLargestSeqFirst") {
889
+ columnOptions.compaction_pri = rocksdb::kOldestLargestSeqFirst;
890
+ } else if (compactionPriority == "smallestSeqFirst") {
891
+ columnOptions.compaction_pri = rocksdb::kOldestSmallestSeqFirst;
892
+ } else if (compactionPriority == "overlappingRatio") {
893
+ columnOptions.compaction_pri = rocksdb::kMinOverlappingRatio;
894
+ } else if (compactionPriority == "roundRobin") {
895
+ columnOptions.compaction_pri = rocksdb::kRoundRobin;
896
+ } else {
897
+ return napi_invalid_arg;
894
898
  }
895
899
 
896
- columnOptions.optimize_filters_for_hits = false;
897
900
  NAPI_STATUS_RETURN(GetProperty(env, options, "optimizeFiltersForHits", columnOptions.optimize_filters_for_hits));
898
901
 
899
902
  rocksdb::BlockBasedTableOptions tableOptions;
903
+ tableOptions.decouple_partitioned_filters = true;
900
904
 
901
905
  {
902
906
  uint32_t cacheSize = 8 << 20;
@@ -912,7 +916,9 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
912
916
  std::string optimize = "";
913
917
  NAPI_STATUS_RETURN(GetProperty(env, options, "optimize", optimize));
914
918
 
915
- if (optimize == "point-lookup") {
919
+ if (optimize == "") {
920
+ tableOptions.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10));
921
+ } else if (optimize == "point-lookup") {
916
922
  tableOptions.data_block_index_type = rocksdb::BlockBasedTableOptions::kDataBlockBinaryAndHash;
917
923
  tableOptions.data_block_hash_table_util_ratio = 0.75;
918
924
  tableOptions.filter_policy.reset(rocksdb::NewRibbonFilterPolicy(10, 2));
@@ -922,7 +928,35 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
922
928
  } else if (optimize == "range-lookup") {
923
929
  // TODO?
924
930
  } else {
925
- tableOptions.filter_policy.reset(rocksdb::NewBloomFilterPolicy(10));
931
+ return napi_invalid_arg;
932
+ }
933
+
934
+ std::string indexType;
935
+ NAPI_STATUS_RETURN(GetProperty(env, options, "indexType", indexType));
936
+ if (indexType == "") {
937
+ // Do nothing...
938
+ } else if (indexType == "binarySearch") {
939
+ tableOptions.index_type = rocksdb::BlockBasedTableOptions::kBinarySearch;
940
+ } else if (indexType == "hashSearch") {
941
+ tableOptions.index_type = rocksdb::BlockBasedTableOptions::kHashSearch;
942
+ } else if (indexType == "twoLevelIndexSearch") {
943
+ tableOptions.index_type = rocksdb::BlockBasedTableOptions::kTwoLevelIndexSearch;
944
+ } else if (indexType == "binarySearchWithFirstKey") {
945
+ tableOptions.index_type = rocksdb::BlockBasedTableOptions::kBinarySearchWithFirstKey;
946
+ } else {
947
+ return napi_invalid_arg;
948
+ }
949
+
950
+ std::string dataBlockIndexType;
951
+ NAPI_STATUS_RETURN(GetProperty(env, options, "dataBlockIndexType", dataBlockIndexType));
952
+ if (dataBlockIndexType == "") {
953
+ // Do nothing...
954
+ } else if (dataBlockIndexType == "dataBlockBinarySearch") {
955
+ tableOptions.data_block_index_type = rocksdb::BlockBasedTableOptions::kDataBlockBinarySearch;
956
+ } else if (dataBlockIndexType == "dataBlockBinaryAndHash") {
957
+ tableOptions.data_block_index_type = rocksdb::BlockBasedTableOptions::kDataBlockBinaryAndHash;
958
+ } else {
959
+ return napi_invalid_arg;
926
960
  }
927
961
 
928
962
  std::string filterPolicy;
@@ -932,31 +966,42 @@ napi_status InitOptions(napi_env env, T& columnOptions, const U& options) {
932
966
  rocksdb::FilterPolicy::CreateFromString(configOptions, filterPolicy, &tableOptions.filter_policy));
933
967
  }
934
968
 
935
- tableOptions.block_size = 4 * 1024;
936
- NAPI_STATUS_RETURN(GetProperty(env, options, "blockSize", tableOptions.block_size));
969
+ std::string indexShortening;
970
+ NAPI_STATUS_RETURN(GetProperty(env, options, "indexShortening", indexShortening));
971
+ if (indexShortening == "") {
972
+ // Do nothing..
973
+ } else if (indexShortening == "noShortening") {
974
+ tableOptions.index_shortening = rocksdb::BlockBasedTableOptions::IndexShorteningMode::kNoShortening;
975
+ } else if (indexShortening == "shortenSeparators") {
976
+ tableOptions.index_shortening = rocksdb::BlockBasedTableOptions::IndexShorteningMode::kShortenSeparators;
977
+ } else if (indexShortening == "shortenSeparatorsAndSuccessor") {
978
+ tableOptions.index_shortening = rocksdb::BlockBasedTableOptions::IndexShorteningMode::kShortenSeparatorsAndSuccessor;
979
+ } else {
980
+ return napi_invalid_arg;
981
+ }
937
982
 
938
- tableOptions.block_restart_interval = 16;
939
- NAPI_STATUS_RETURN(GetProperty(env, options, "blockRestartInterval", tableOptions.block_restart_interval));
983
+ std::string prepopulateBlockCache;
984
+ NAPI_STATUS_RETURN(GetProperty(env, options, "prepopulateBlockCache", prepopulateBlockCache));
985
+ if (prepopulateBlockCache == "") {
986
+ // Do nothing...
987
+ } else if (prepopulateBlockCache == "disable") {
988
+ tableOptions.prepopulate_block_cache = rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kDisable;
989
+ } else if (prepopulateBlockCache == "flushOnly") {
990
+ tableOptions.prepopulate_block_cache = rocksdb::BlockBasedTableOptions::PrepopulateBlockCache::kFlushOnly;
991
+ } else {
992
+ return napi_invalid_arg;
993
+ }
940
994
 
941
- tableOptions.block_align = false;
995
+ NAPI_STATUS_RETURN(GetProperty(env, options, "dataBlockHashTableUtilRatio", tableOptions.data_block_hash_table_util_ratio));
996
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blockSize", tableOptions.block_size));
997
+ NAPI_STATUS_RETURN(GetProperty(env, options, "blockRestartInterval", tableOptions.block_restart_interval));
942
998
  NAPI_STATUS_RETURN(GetProperty(env, options, "blockAlign", tableOptions.block_align));
943
-
944
- tableOptions.cache_index_and_filter_blocks = false;
945
999
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheIndexAndFilterBlocks", tableOptions.cache_index_and_filter_blocks));
946
-
947
- tableOptions.cache_index_and_filter_blocks_with_high_priority = true;
948
1000
  NAPI_STATUS_RETURN(GetProperty(env, options, "cacheIndexAndFilterBlocksWithHighPriority", tableOptions.cache_index_and_filter_blocks_with_high_priority));
949
-
950
- tableOptions.decouple_partitioned_filters = true;
951
1001
  NAPI_STATUS_RETURN(GetProperty(env, options, "decouplePartitionedFilters", tableOptions.block_restart_interval));
952
-
953
- tableOptions.optimize_filters_for_memory = true;
954
1002
  NAPI_STATUS_RETURN(GetProperty(env, options, "optimizeFiltersForMemory", tableOptions.optimize_filters_for_memory));
955
-
956
- tableOptions.max_auto_readahead_size = 256 * 1024;
957
1003
  NAPI_STATUS_RETURN(GetProperty(env, options, "maxAutoReadaheadSize", tableOptions.max_auto_readahead_size));
958
-
959
- tableOptions.num_file_reads_for_auto_readahead = 2;
1004
+ NAPI_STATUS_RETURN(GetProperty(env, options, "initialAutoReadaheadSize", tableOptions.initial_auto_readahead_size));
960
1005
  NAPI_STATUS_RETURN(GetProperty(env, options, "numFileReadsForAutoReadahead", tableOptions.num_file_reads_for_auto_readahead));
961
1006
 
962
1007
  columnOptions.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
@@ -93,8 +93,8 @@
93
93
  "USE_COROUTINES=1",
94
94
  "HAVE_UINT128_EXTENSION=1",
95
95
  "HAVE_ALIGNED_NEW=1",
96
- "ROCKSDB_JEMALLOC=1",
97
- "JEMALLOC_NO_DEMANGLE=1"
96
+ # "ROCKSDB_JEMALLOC=1",
97
+ # "JEMALLOC_NO_DEMANGLE=1"
98
98
  # "HAVE_FULLFSYNC=1",
99
99
  # "NUMA=1",
100
100
  ],
@@ -107,8 +107,8 @@
107
107
  "/usr/lib/x86_64-linux-gnu/libglog.a",
108
108
  "/usr/lib/x86_64-linux-gnu/libiberty.a",
109
109
  "/usr/lib/x86_64-linux-gnu/libunwind.a",
110
- "/usr/lib/x86_64-linux-gnu/libgflags.a",
111
- "/usr/lib/x86_64-linux-gnu/libjemalloc.a"
110
+ "/usr/lib/x86_64-linux-gnu/libgflags.a"
111
+ # "/usr/lib/x86_64-linux-gnu/libjemalloc.a"
112
112
  ],
113
113
  },
114
114
  "include_dirs": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "13.1.1",
3
+ "version": "13.1.2",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
package/util.h CHANGED
@@ -244,6 +244,12 @@ static napi_status GetValue(napi_env env, napi_value value, unsigned long long&
244
244
  return napi_ok;
245
245
  }
246
246
 
247
+ static napi_status GetValue(napi_env env, napi_value value, double& result) {
248
+ NAPI_STATUS_RETURN(napi_get_value_double(env, value, &result));
249
+ return napi_ok;
250
+ }
251
+
252
+
247
253
  static napi_status GetValue(napi_env env, napi_value value, std::string& result) {
248
254
  return GetString(env, value, result);
249
255
  }
package/prebuilds.zip DELETED
Binary file