@nxtedition/rocksdb 13.5.9 → 13.5.11

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.
Files changed (124) hide show
  1. package/deps/rocksdb/rocksdb/BUCK +2 -1
  2. package/deps/rocksdb/rocksdb/CMakeLists.txt +2 -1
  3. package/deps/rocksdb/rocksdb/Makefile +1 -1
  4. package/deps/rocksdb/rocksdb/cache/secondary_cache_adapter.cc +4 -5
  5. package/deps/rocksdb/rocksdb/db/c.cc +13 -0
  6. package/deps/rocksdb/rocksdb/db/c_test.c +0 -12
  7. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +8 -8
  8. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +2 -3
  9. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +5 -4
  10. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +2 -1
  11. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +10 -10
  12. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +11 -6
  13. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +10 -16
  14. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +2 -4
  15. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +12 -17
  16. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +164 -0
  17. package/deps/rocksdb/rocksdb/db/corruption_test.cc +74 -3
  18. package/deps/rocksdb/rocksdb/db/db_encryption_test.cc +39 -4
  19. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +2 -83
  20. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +0 -4
  21. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +11 -11
  22. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_follower.cc +0 -3
  23. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +0 -9
  24. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +16 -54
  25. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +0 -6
  26. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +186 -0
  27. package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +3 -40
  28. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +0 -54
  29. package/deps/rocksdb/rocksdb/db/db_test.cc +0 -292
  30. package/deps/rocksdb/rocksdb/db/db_test2.cc +0 -1235
  31. package/deps/rocksdb/rocksdb/db/db_test_util.h +8 -0
  32. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +11 -4
  33. package/deps/rocksdb/rocksdb/db/log_reader.cc +11 -11
  34. package/deps/rocksdb/rocksdb/db/merge_helper.h +1 -1
  35. package/deps/rocksdb/rocksdb/db/multi_scan.cc +70 -0
  36. package/deps/rocksdb/rocksdb/db/version_set.cc +15 -8
  37. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +4 -0
  38. package/deps/rocksdb/rocksdb/env/composite_env.cc +4 -0
  39. package/deps/rocksdb/rocksdb/env/env.cc +4 -0
  40. package/deps/rocksdb/rocksdb/env/env_encryption.cc +38 -3
  41. package/deps/rocksdb/rocksdb/env/env_test.cc +36 -1
  42. package/deps/rocksdb/rocksdb/env/fs_posix.cc +20 -4
  43. package/deps/rocksdb/rocksdb/env/io_posix.cc +16 -0
  44. package/deps/rocksdb/rocksdb/env/io_posix.h +3 -0
  45. package/deps/rocksdb/rocksdb/env/mock_env.cc +5 -0
  46. package/deps/rocksdb/rocksdb/file/readahead_raf.cc +4 -0
  47. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_compression.h +33 -6
  48. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +5 -0
  49. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +25 -1
  50. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +10 -0
  51. package/deps/rocksdb/rocksdb/include/rocksdb/env_encryption.h +9 -0
  52. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +12 -0
  53. package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +12 -8
  54. package/deps/rocksdb/rocksdb/include/rocksdb/multi_scan.h +29 -28
  55. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +26 -6
  56. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +9 -0
  57. package/deps/rocksdb/rocksdb/include/rocksdb/tool_hooks.h +3 -0
  58. package/deps/rocksdb/rocksdb/include/rocksdb/user_defined_index.h +142 -0
  59. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/db_ttl.h +2 -0
  60. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +2 -2
  61. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +2 -0
  62. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  63. package/deps/rocksdb/rocksdb/options/options_helper.h +3 -0
  64. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +2 -0
  65. package/deps/rocksdb/rocksdb/port/win/io_win.cc +20 -0
  66. package/deps/rocksdb/rocksdb/port/win/io_win.h +4 -0
  67. package/deps/rocksdb/rocksdb/src.mk +2 -1
  68. package/deps/rocksdb/rocksdb/table/block_based/block.cc +31 -34
  69. package/deps/rocksdb/rocksdb/table/block_based/block.h +2 -4
  70. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +43 -7
  71. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +6 -0
  72. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +367 -2
  73. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +69 -23
  74. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +54 -6
  75. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +27 -5
  76. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +167 -3
  77. package/deps/rocksdb/rocksdb/table/block_based/block_builder.cc +6 -2
  78. package/deps/rocksdb/rocksdb/table/block_based/block_cache.cc +6 -0
  79. package/deps/rocksdb/rocksdb/table/block_based/block_cache.h +12 -0
  80. package/deps/rocksdb/rocksdb/table/block_based/block_type.h +1 -0
  81. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +0 -3
  82. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +10 -7
  83. package/deps/rocksdb/rocksdb/table/block_based/user_defined_index_wrapper.h +244 -0
  84. package/deps/rocksdb/rocksdb/table/external_table.cc +1 -1
  85. package/deps/rocksdb/rocksdb/table/format.cc +51 -33
  86. package/deps/rocksdb/rocksdb/table/format.h +1 -1
  87. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +13 -8
  88. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +1 -3
  89. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +5 -1
  90. package/deps/rocksdb/rocksdb/table/table_test.cc +629 -1
  91. package/deps/rocksdb/rocksdb/test_util/testutil.cc +0 -1
  92. package/deps/rocksdb/rocksdb/test_util/testutil.h +5 -0
  93. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +183 -94
  94. package/deps/rocksdb/rocksdb/tools/sst_dump_test.cc +71 -0
  95. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +37 -22
  96. package/deps/rocksdb/rocksdb/util/auto_tune_compressor.cc +308 -0
  97. package/deps/rocksdb/rocksdb/util/auto_tune_compressor.h +189 -0
  98. package/deps/rocksdb/rocksdb/util/cast_util.h +22 -11
  99. package/deps/rocksdb/rocksdb/util/coding.h +4 -3
  100. package/deps/rocksdb/rocksdb/util/compression.cc +2 -0
  101. package/deps/rocksdb/rocksdb/util/compression.h +16 -6
  102. package/deps/rocksdb/rocksdb/util/compression_test.cc +1679 -15
  103. package/deps/rocksdb/rocksdb/util/stop_watch.h +17 -7
  104. package/deps/rocksdb/rocksdb/util/timer_queue_test.cc +17 -3
  105. package/deps/rocksdb/rocksdb/utilities/env_mirror.cc +10 -0
  106. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.cc +5 -0
  107. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.h +2 -0
  108. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +18 -2
  109. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +22 -3
  110. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager.cc +5 -0
  111. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +22 -2
  112. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +15 -4
  113. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +61 -0
  114. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +18 -0
  115. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.h +3 -0
  116. package/deps/rocksdb/rocksdb/utilities/ttl/ttl_test.cc +3 -0
  117. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +9 -3
  118. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +9 -0
  119. package/deps/rocksdb/rocksdb.gyp +15 -1
  120. package/package.json +1 -1
  121. package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
  122. package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
  123. package/deps/rocksdb/rocksdb/util/auto_skip_compressor.cc +0 -131
  124. package/deps/rocksdb/rocksdb/util/auto_skip_compressor.h +0 -90
@@ -1016,10 +1016,10 @@ bool IndexBlockIter::PrefixSeek(const Slice& target, uint32_t* index,
1016
1016
  }
1017
1017
 
1018
1018
  uint32_t Block::NumRestarts() const {
1019
- assert(size_ >= 2 * sizeof(uint32_t));
1020
- uint32_t block_footer = DecodeFixed32(data_ + size_ - sizeof(uint32_t));
1019
+ assert(size() >= 2 * sizeof(uint32_t));
1020
+ uint32_t block_footer = DecodeFixed32(data() + size() - sizeof(uint32_t));
1021
1021
  uint32_t num_restarts = block_footer;
1022
- if (size_ > kMaxBlockSizeSupportedByHashIndex) {
1022
+ if (size() > kMaxBlockSizeSupportedByHashIndex) {
1023
1023
  // In BlockBuilder, we have ensured a block with HashIndex is less than
1024
1024
  // kMaxBlockSizeSupportedByHashIndex (64KiB).
1025
1025
  //
@@ -1038,12 +1038,12 @@ uint32_t Block::NumRestarts() const {
1038
1038
  }
1039
1039
 
1040
1040
  BlockBasedTableOptions::DataBlockIndexType Block::IndexType() const {
1041
- assert(size_ >= 2 * sizeof(uint32_t));
1042
- if (size_ > kMaxBlockSizeSupportedByHashIndex) {
1041
+ assert(size() >= 2 * sizeof(uint32_t));
1042
+ if (size() > kMaxBlockSizeSupportedByHashIndex) {
1043
1043
  // The check is for the same reason as that in NumRestarts()
1044
1044
  return BlockBasedTableOptions::kDataBlockBinarySearch;
1045
1045
  }
1046
- uint32_t block_footer = DecodeFixed32(data_ + size_ - sizeof(uint32_t));
1046
+ uint32_t block_footer = DecodeFixed32(data() + size() - sizeof(uint32_t));
1047
1047
  uint32_t num_restarts = block_footer;
1048
1048
  BlockBasedTableOptions::DataBlockIndexType index_type;
1049
1049
  UnPackIndexTypeAndNumRestarts(block_footer, &index_type, &num_restarts);
@@ -1059,54 +1059,51 @@ Block::~Block() {
1059
1059
 
1060
1060
  Block::Block(BlockContents&& contents, size_t read_amp_bytes_per_bit,
1061
1061
  Statistics* statistics)
1062
- : contents_(std::move(contents)),
1063
- data_(contents_.data.data()),
1064
- size_(contents_.data.size()),
1065
- restart_offset_(0),
1066
- num_restarts_(0) {
1062
+ : contents_(std::move(contents)), restart_offset_(0), num_restarts_(0) {
1067
1063
  TEST_SYNC_POINT("Block::Block:0");
1068
- if (size_ < sizeof(uint32_t)) {
1069
- size_ = 0; // Error marker
1064
+ auto& size = contents_.data.size_;
1065
+ if (size < sizeof(uint32_t)) {
1066
+ size = 0; // Error marker
1070
1067
  } else {
1071
1068
  // Should only decode restart points for uncompressed blocks
1072
1069
  num_restarts_ = NumRestarts();
1073
1070
  switch (IndexType()) {
1074
1071
  case BlockBasedTableOptions::kDataBlockBinarySearch:
1075
- restart_offset_ = static_cast<uint32_t>(size_) -
1072
+ restart_offset_ = static_cast<uint32_t>(size) -
1076
1073
  (1 + num_restarts_) * sizeof(uint32_t);
1077
- if (restart_offset_ > size_ - sizeof(uint32_t)) {
1074
+ if (restart_offset_ > size - sizeof(uint32_t)) {
1078
1075
  // The size is too small for NumRestarts() and therefore
1079
1076
  // restart_offset_ wrapped around.
1080
- size_ = 0;
1077
+ size = 0;
1081
1078
  }
1082
1079
  break;
1083
1080
  case BlockBasedTableOptions::kDataBlockBinaryAndHash:
1084
- if (size_ < sizeof(uint32_t) /* block footer */ +
1085
- sizeof(uint16_t) /* NUM_BUCK */) {
1086
- size_ = 0;
1081
+ if (size < sizeof(uint32_t) /* block footer */ +
1082
+ sizeof(uint16_t) /* NUM_BUCK */) {
1083
+ size = 0;
1087
1084
  break;
1088
1085
  }
1089
1086
 
1090
1087
  uint16_t map_offset;
1091
1088
  data_block_hash_index_.Initialize(
1092
- data_, static_cast<uint16_t>(size_ - sizeof(uint32_t)), /*chop off
1093
- NUM_RESTARTS*/
1094
- &map_offset);
1089
+ contents_.data.data(),
1090
+ /* chop off NUM_RESTARTS */
1091
+ static_cast<uint16_t>(size - sizeof(uint32_t)), &map_offset);
1095
1092
 
1096
1093
  restart_offset_ = map_offset - num_restarts_ * sizeof(uint32_t);
1097
1094
 
1098
1095
  if (restart_offset_ > map_offset) {
1099
1096
  // map_offset is too small for NumRestarts() and
1100
1097
  // therefore restart_offset_ wrapped around.
1101
- size_ = 0;
1098
+ size = 0;
1102
1099
  break;
1103
1100
  }
1104
1101
  break;
1105
1102
  default:
1106
- size_ = 0; // Error marker
1103
+ size = 0; // Error marker
1107
1104
  }
1108
1105
  }
1109
- if (read_amp_bytes_per_bit != 0 && statistics && size_ != 0) {
1106
+ if (read_amp_bytes_per_bit != 0 && statistics && size != 0) {
1110
1107
  read_amp_bitmap_.reset(new BlockReadAmpBitmap(
1111
1108
  restart_offset_, read_amp_bytes_per_bit, statistics));
1112
1109
  }
@@ -1148,7 +1145,7 @@ void Block::InitializeDataBlockProtectionInfo(uint8_t protection_bytes_per_key,
1148
1145
  assert(!iter->status().ok() || i == num_keys * protection_bytes_per_key);
1149
1146
  }
1150
1147
  if (!iter->status().ok()) {
1151
- size_ = 0; // Error marker
1148
+ contents_.data.size_ = 0; // Error marker
1152
1149
  return;
1153
1150
  }
1154
1151
  protection_bytes_per_key_ = protection_bytes_per_key;
@@ -1197,7 +1194,7 @@ void Block::InitializeIndexBlockProtectionInfo(uint8_t protection_bytes_per_key,
1197
1194
  assert(!iter->status().ok() || i == num_keys * protection_bytes_per_key);
1198
1195
  }
1199
1196
  if (!iter->status().ok()) {
1200
- size_ = 0; // Error marker
1197
+ contents_.data.size_ = 0; // Error marker
1201
1198
  return;
1202
1199
  }
1203
1200
  protection_bytes_per_key_ = protection_bytes_per_key;
@@ -1231,7 +1228,7 @@ void Block::InitializeMetaIndexBlockProtectionInfo(
1231
1228
  assert(!iter->status().ok() || i == num_keys * protection_bytes_per_key);
1232
1229
  }
1233
1230
  if (!iter->status().ok()) {
1234
- size_ = 0; // Error marker
1231
+ contents_.data.size_ = 0; // Error marker
1235
1232
  return;
1236
1233
  }
1237
1234
  protection_bytes_per_key_ = protection_bytes_per_key;
@@ -1240,14 +1237,14 @@ void Block::InitializeMetaIndexBlockProtectionInfo(
1240
1237
 
1241
1238
  MetaBlockIter* Block::NewMetaIterator(bool block_contents_pinned) {
1242
1239
  MetaBlockIter* iter = new MetaBlockIter();
1243
- if (size_ < 2 * sizeof(uint32_t)) {
1240
+ if (size() < 2 * sizeof(uint32_t)) {
1244
1241
  iter->Invalidate(Status::Corruption("bad block contents"));
1245
1242
  return iter;
1246
1243
  } else if (num_restarts_ == 0) {
1247
1244
  // Empty block.
1248
1245
  iter->Invalidate(Status::OK());
1249
1246
  } else {
1250
- iter->Initialize(data_, restart_offset_, num_restarts_,
1247
+ iter->Initialize(data(), restart_offset_, num_restarts_,
1251
1248
  block_contents_pinned, protection_bytes_per_key_,
1252
1249
  kv_checksum_, block_restart_interval_);
1253
1250
  }
@@ -1265,7 +1262,7 @@ DataBlockIter* Block::NewDataIterator(const Comparator* raw_ucmp,
1265
1262
  } else {
1266
1263
  ret_iter = new DataBlockIter;
1267
1264
  }
1268
- if (size_ < 2 * sizeof(uint32_t)) {
1265
+ if (size() < 2 * sizeof(uint32_t)) {
1269
1266
  ret_iter->Invalidate(Status::Corruption("bad block contents"));
1270
1267
  return ret_iter;
1271
1268
  }
@@ -1275,7 +1272,7 @@ DataBlockIter* Block::NewDataIterator(const Comparator* raw_ucmp,
1275
1272
  return ret_iter;
1276
1273
  } else {
1277
1274
  ret_iter->Initialize(
1278
- raw_ucmp, data_, restart_offset_, num_restarts_, global_seqno,
1275
+ raw_ucmp, data(), restart_offset_, num_restarts_, global_seqno,
1279
1276
  read_amp_bitmap_.get(), block_contents_pinned,
1280
1277
  user_defined_timestamps_persisted,
1281
1278
  data_block_hash_index_.Valid() ? &data_block_hash_index_ : nullptr,
@@ -1303,7 +1300,7 @@ IndexBlockIter* Block::NewIndexIterator(
1303
1300
  } else {
1304
1301
  ret_iter = new IndexBlockIter;
1305
1302
  }
1306
- if (size_ < 2 * sizeof(uint32_t)) {
1303
+ if (size() < 2 * sizeof(uint32_t)) {
1307
1304
  ret_iter->Invalidate(Status::Corruption("bad block contents"));
1308
1305
  return ret_iter;
1309
1306
  }
@@ -1315,7 +1312,7 @@ IndexBlockIter* Block::NewIndexIterator(
1315
1312
  BlockPrefixIndex* prefix_index_ptr =
1316
1313
  total_order_seek ? nullptr : prefix_index;
1317
1314
  ret_iter->Initialize(
1318
- raw_ucmp, data_, restart_offset_, num_restarts_, global_seqno,
1315
+ raw_ucmp, data(), restart_offset_, num_restarts_, global_seqno,
1319
1316
  prefix_index_ptr, have_first_key, key_includes_seq, value_is_full,
1320
1317
  block_contents_pinned, user_defined_timestamps_persisted,
1321
1318
  protection_bytes_per_key_, kv_checksum_, block_restart_interval_);
@@ -163,8 +163,8 @@ class Block {
163
163
 
164
164
  ~Block();
165
165
 
166
- size_t size() const { return size_; }
167
- const char* data() const { return data_; }
166
+ size_t size() const { return contents_.data.size(); }
167
+ const char* data() const { return contents_.data.data(); }
168
168
  // The additional memory space taken by the block data.
169
169
  size_t usable_size() const { return contents_.usable_size(); }
170
170
  uint32_t NumRestarts() const;
@@ -277,8 +277,6 @@ class Block {
277
277
 
278
278
  private:
279
279
  BlockContents contents_;
280
- const char* data_; // contents_.data.data()
281
- size_t size_; // contents_.data.size()
282
280
  uint32_t restart_offset_; // Offset in data_ of restart array
283
281
  uint32_t num_restarts_;
284
282
  std::unique_ptr<BlockReadAmpBitmap> read_amp_bitmap_;
@@ -46,6 +46,7 @@
46
46
  #include "table/block_based/filter_policy_internal.h"
47
47
  #include "table/block_based/full_filter_block.h"
48
48
  #include "table/block_based/partitioned_filter_block.h"
49
+ #include "table/block_based/user_defined_index_wrapper.h"
49
50
  #include "table/format.h"
50
51
  #include "table/meta_blocks.h"
51
52
  #include "table/table_builder.h"
@@ -408,7 +409,15 @@ struct BlockBasedTableBuilder::ParallelCompressionRep {
408
409
  }
409
410
  }
410
411
 
411
- ~ParallelCompressionRep() { block_rep_pool.finish(); }
412
+ ~ParallelCompressionRep() {
413
+ block_rep_pool.finish();
414
+ #ifndef NDEBUG
415
+ // Silence ASSERT_STATUS_CHECKED warnings
416
+ for (auto& block_rep : block_rep_buf) {
417
+ assert(block_rep.status.ok());
418
+ }
419
+ #endif
420
+ }
412
421
 
413
422
  // Make a block prepared to be emitted to compression thread
414
423
  // Used in non-buffered mode
@@ -889,6 +898,27 @@ struct BlockBasedTableBuilder::Rep {
889
898
  &this->internal_prefix_transform, use_delta_encoding_for_index_values,
890
899
  table_options, ts_sz, persist_user_defined_timestamps));
891
900
  }
901
+
902
+ // If user_defined_index_factory is provided, wrap the index builder with
903
+ // UserDefinedIndexWrapper
904
+ if (table_options.user_defined_index_factory != nullptr) {
905
+ if (tbo.moptions.compression_opts.parallel_threads > 1 ||
906
+ tbo.moptions.bottommost_compression_opts.parallel_threads > 1) {
907
+ SetStatus(
908
+ Status::InvalidArgument("user_defined_index_factory not supported "
909
+ "with parallel compression"));
910
+ } else {
911
+ std::unique_ptr<UserDefinedIndexBuilder> user_defined_index_builder(
912
+ table_options.user_defined_index_factory->NewBuilder());
913
+ if (user_defined_index_builder != nullptr) {
914
+ index_builder.reset(new UserDefinedIndexBuilderWrapper(
915
+ std::string(table_options.user_defined_index_factory->Name()),
916
+ std::move(index_builder), std::move(user_defined_index_builder),
917
+ &internal_comparator, ts_sz, persist_user_defined_timestamps));
918
+ }
919
+ }
920
+ }
921
+
892
922
  if (ioptions.optimize_filters_for_hits && tbo.is_bottommost) {
893
923
  // Apply optimize_filters_for_hits setting here when applicable by
894
924
  // skipping filter generation
@@ -1192,7 +1222,7 @@ void BlockBasedTableBuilder::Add(const Slice& ikey, const Slice& value) {
1192
1222
  // `Finish()` once compression dictionary has been finalized.
1193
1223
  } else {
1194
1224
  if (!r->IsParallelCompressionEnabled()) {
1195
- r->index_builder->OnKeyAdded(ikey);
1225
+ r->index_builder->OnKeyAdded(ikey, value);
1196
1226
  }
1197
1227
  }
1198
1228
  // TODO offset passed in is not accurate for parallel compression case
@@ -1634,7 +1664,7 @@ void BlockBasedTableBuilder::BGWorkWriteMaybeCompressedBlock() {
1634
1664
  r->filter_builder->AddWithPrevKey(key_no_ts, prev_key_no_ts);
1635
1665
  prev_key_no_ts = key_no_ts;
1636
1666
  }
1637
- r->index_builder->OnKeyAdded(key);
1667
+ r->index_builder->OnKeyAdded(key, {});
1638
1668
  }
1639
1669
  if (r->filter_builder != nullptr) {
1640
1670
  prev_block_last_key_no_ts.assign(prev_key_no_ts.data(),
@@ -1808,7 +1838,13 @@ void BlockBasedTableBuilder::WriteIndexBlock(
1808
1838
  if (ok()) {
1809
1839
  for (const auto& item : index_blocks.meta_blocks) {
1810
1840
  BlockHandle block_handle;
1811
- WriteBlock(item.second, &block_handle, BlockType::kIndex);
1841
+ if (item.second.first == BlockType::kIndex) {
1842
+ WriteBlock(item.second.second, &block_handle, item.second.first);
1843
+ } else {
1844
+ assert(item.second.first == BlockType::kUserDefinedIndex);
1845
+ WriteMaybeCompressedBlock(item.second.second, kNoCompression,
1846
+ &block_handle, item.second.first);
1847
+ }
1812
1848
  if (!ok()) {
1813
1849
  break;
1814
1850
  }
@@ -1854,8 +1890,8 @@ void BlockBasedTableBuilder::WriteIndexBlock(
1854
1890
  }
1855
1891
  }
1856
1892
  // If success and need to record in metaindex rather than footer...
1857
- if (!FormatVersionUsesIndexHandleInFooter(
1858
- rep_->table_options.format_version)) {
1893
+ if (ok() && !FormatVersionUsesIndexHandleInFooter(
1894
+ rep_->table_options.format_version)) {
1859
1895
  meta_index_builder->Add(kIndexBlockName, *index_block_handle);
1860
1896
  }
1861
1897
  }
@@ -2184,7 +2220,7 @@ void BlockBasedTableBuilder::EnterUnbuffered() {
2184
2220
  r->filter_builder->Add(
2185
2221
  ExtractUserKeyAndStripTimestamp(key, r->ts_sz));
2186
2222
  }
2187
- r->index_builder->OnKeyAdded(key);
2223
+ r->index_builder->OnKeyAdded(key, iter->value());
2188
2224
  }
2189
2225
  WriteBlock(Slice(data_block), &r->pending_handle, BlockType::kData);
2190
2226
  if (ok() && i + 1 < r->data_block_buffers.size()) {
@@ -690,6 +690,12 @@ Status BlockBasedTableFactory::ValidateOptions(
690
690
  "data_block_hash_table_util_ratio should be greater than 0 when "
691
691
  "data_block_index_type is set to kDataBlockBinaryAndHash");
692
692
  }
693
+ if (table_options_.user_defined_index_factory &&
694
+ (cf_opts.compression_opts.parallel_threads > 1 ||
695
+ cf_opts.bottommost_compression_opts.parallel_threads > 1)) {
696
+ return Status::InvalidArgument(
697
+ "user_defined_index_factory not supported with parallel compression");
698
+ }
693
699
  if (db_opts.unordered_write && cf_opts.max_successive_merges > 0) {
694
700
  // TODO(myabandeh): support it
695
701
  return Status::InvalidArgument(