rocksdb/file
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
..
delete_scheduler.cc Move some logging related files to logging/ (#5387) 2019-05-31 17:23:59 -07:00
delete_scheduler.h Move some file related files outside util/ (#5375) 2019-05-29 20:47:06 -07:00
delete_scheduler_test.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
file_util.cc Fix bugs in DBWALTest.kTolerateCorruptedTailRecords triggered by #5520 (#5550) 2019-07-09 11:18:32 -07:00
file_util.h Fix bugs in WAL trash file handling (#5520) 2019-07-06 21:07:32 -07:00
filename.cc New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
filename.h Fix duplicated file names in PurgeObsoleteFiles (#5603) 2019-08-01 15:50:05 -07:00
sst_file_manager_impl.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
sst_file_manager_impl.h Organizing rocksdb/db directory 2019-05-31 11:57:01 -07:00