rocksdb/utilities/blob_db
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
..
blob_compaction_filter.cc Apply modernize-use-override (2nd iteration) 2019-02-14 14:41:36 -08:00
blob_compaction_filter.h Blob DB: Improve FIFO eviction 2018-03-06 11:57:42 -08:00
blob_db_impl_filesnapshot.cc Move some logging related files to logging/ (#5387) 2019-05-31 17:23:59 -07:00
blob_db_impl.cc New API to get all merge operands for a Key (#5604) 2019-08-06 14:26:44 -07:00
blob_db_impl.h BlobDB::Open() should put all existing trash files to delete scheduler (#5103) 2019-03-26 10:53:19 -07:00
blob_db_iterator.h Change and clarify the relationship between Valid(), status() and Seek*() for all iterators. Also fix some bugs 2018-05-17 02:56:56 -07:00
blob_db_listener.h Blob DB: Improve FIFO eviction 2018-03-06 11:57:42 -08:00
blob_db_test.cc Move some memory related files from util/ to memory/ (#5382) 2019-05-30 17:44:09 -07:00
blob_db.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
blob_db.h Introduce a new MultiGet batching implementation (#5011) 2019-04-11 14:28:26 -07:00
blob_dump_tool.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
blob_dump_tool.h Ensure delete[] and not delete is used on buffer_ (#4647) 2018-11-07 11:59:50 -08:00
blob_file.cc simplify include directive involving inttypes (#5402) 2019-06-06 13:56:07 -07:00
blob_file.h BlobDB: handle IO error on read (#4410) 2018-09-20 16:58:45 -07:00
blob_index.h Blob DB: Inline small values in base DB 2017-10-26 12:30:54 -07:00
blob_log_format.cc utilities: Fix build failure with -Werror=maybe-uninitialized (#5074) 2019-03-18 11:35:06 -07:00
blob_log_format.h BlobDB: use char array instead of string as buffer (#4662) 2018-11-13 12:49:29 -08:00
blob_log_reader.cc Remove some "using std::..." from header files. (#5113) 2019-03-27 10:28:21 -07:00
blob_log_reader.h BlobDB: use char array instead of string as buffer (#4662) 2018-11-13 12:49:29 -08:00
blob_log_writer.cc Remove some "using std::..." from header files. (#5113) 2019-03-27 10:28:21 -07:00
blob_log_writer.h BlobDB: refactor DB open logic 2017-12-11 12:12:38 -08:00