rocksdb/table
Vijay Nadimpalli d150e01474 New API to get all merge operands for a Key (#5604)
Summary:
This is a new API added to db.h to allow for fetching all merge operands associated with a Key. The main motivation for this API is to support use cases where doing a full online merge is not necessary as it is performance sensitive. Example use-cases:
1. Update subset of columns and read subset of columns -
Imagine a SQL Table, a row is encoded as a K/V pair (as it is done in MyRocks). If there are many columns and users only updated one of them, we can use merge operator to reduce write amplification. While users only read one or two columns in the read query, this feature can avoid a full merging of the whole row, and save some CPU.
2. Updating very few attributes in a value which is a JSON-like document -
Updating one attribute can be done efficiently using merge operator, while reading back one attribute can be done more efficiently if we don't need to do a full merge.
----------------------------------------------------------------------------------------------------
API :
Status GetMergeOperands(
      const ReadOptions& options, ColumnFamilyHandle* column_family,
      const Slice& key, PinnableSlice* merge_operands,
      GetMergeOperandsOptions* get_merge_operands_options,
      int* number_of_operands)

Example usage :
int size = 100;
int number_of_operands = 0;
std::vector<PinnableSlice> values(size);
GetMergeOperandsOptions merge_operands_info;
db_->GetMergeOperands(ReadOptions(), db_->DefaultColumnFamily(), "k1", values.data(), merge_operands_info, &number_of_operands);

Description :
Returns all the merge operands corresponding to the key. If the number of merge operands in DB is greater than merge_operands_options.expected_max_number_of_operands no merge operands are returned and status is Incomplete. Merge operands returned are in the order of insertion.
merge_operands-> Points to an array of at-least merge_operands_options.expected_max_number_of_operands and the caller is responsible for allocating it. If the status returned is Incomplete then number_of_operands will contain the total number of merge operands found in DB for key.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5604

Test Plan:
Added unit test and perf test in db_bench that can be run using the command:
./db_bench -benchmarks=getmergeoperands --merge_operator=sortlist

Differential Revision: D16657366

Pulled By: vjnadimpalli

fbshipit-source-id: 0faadd752351745224ee12d4ae9ef3cb529951bf
2019-08-06 14:26:44 -07:00
..
adaptive Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
block_based New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
cuckoo New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
plain Add more callers for table reader. (#5454) 2019-06-20 14:31:48 -07:00
block_fetcher.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
block_fetcher.h Combine the read-ahead logic for user reads and compaction reads (#5431) 2019-06-19 14:10:46 -07:00
bloom_block.cc Change RocksDB License 2017-07-15 16:11:23 -07:00
bloom_block.h Disallow customized hash function in DynamicBloom (#4915) 2019-01-24 10:34:30 -08:00
cleanable_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
format.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
format.h MultiGet parallel IO (#5464) 2019-06-30 20:56:04 -07:00
full_filter_bits_builder.h Skip duplicate bloom keys when whole_key and prefix are mixed 2018-04-24 10:58:16 -07:00
get_context.cc New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
get_context.h New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
internal_iterator.h Reduce iterator key comparison for upper/lower bound check (2nd attempt) (#5468) 2019-07-02 11:48:46 -07:00
iter_heap.h Make InternalKeyComparator final and directly use it in merging iterator 2017-09-11 12:04:21 -07:00
iterator_wrapper.h Reduce iterator key comparison for upper/lower bound check (2nd attempt) (#5468) 2019-07-02 11:48:46 -07:00
iterator.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
merger_test.cc Move test related files under util/ to test_util/ (#5377) 2019-05-30 11:25:51 -07:00
merging_iterator.cc Reduce iterator key comparison for upper/lower bound check (2nd attempt) (#5468) 2019-07-02 11:48:46 -07:00
merging_iterator.h Index value delta encoding (#3983) 2018-08-09 16:58:40 -07:00
meta_blocks.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
meta_blocks.h Make the 'block read count' performance counters consistent (#5484) 2019-06-18 19:03:24 -07:00
mock_table.cc Add more callers for table reader. (#5454) 2019-06-20 14:31:48 -07:00
mock_table.h Add more callers for table reader. (#5454) 2019-06-20 14:31:48 -07:00
multiget_context.h multiget: fix memory issues due to vector auto resizing (#5279) 2019-05-03 15:58:43 -07:00
persistent_cache_helper.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
persistent_cache_helper.h Change RocksDB License 2017-07-15 16:11:23 -07:00
persistent_cache_options.h Change RocksDB License 2017-07-15 16:11:23 -07:00
scoped_arena_iterator.h Change RocksDB License 2017-07-15 16:11:23 -07:00
sst_file_reader_test.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
sst_file_reader.cc Add more callers for table reader. (#5454) 2019-06-20 14:31:48 -07:00
sst_file_writer_collectors.h Fix SstFileReader not able to open ingested file (#5097) 2019-03-26 10:25:18 -07:00
sst_file_writer.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
table_builder.h Integrate block cache tracer into db_impl (#5433) 2019-06-13 15:43:10 -07:00
table_properties_internal.h Index value delta encoding (#3983) 2018-08-09 16:58:40 -07:00
table_properties.cc Organizing rocksdb/table directory by format 2019-05-30 14:51:11 -07:00
table_reader_bench.cc New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
table_reader_caller.h Add more callers for table reader. (#5454) 2019-06-20 14:31:48 -07:00
table_reader.h Move the uncompression dictionary object out of the block cache (#5584) 2019-07-23 16:01:44 -07:00
table_test.cc New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
two_level_iterator.cc Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00
two_level_iterator.h Add an option to put first key of each sst block in the index (#5289) 2019-06-24 20:54:04 -07:00