Add comments for MultiGetBlob() and checks for MultiRead() (#8972)

Summary:
Add comments for MultiGetBlob() that input argument `offsets` must be
sorted. In addition, add assertion for this condition in debug build.
Repeat the same for RandomAccessFileReader::MultiRead().

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8972

Test Plan: make check

Reviewed By: pdillinger

Differential Revision: D31253205

Pulled By: riversand963

fbshipit-source-id: 98758229b8052f3aeb319d5584026b4de2d220a2
main
Yanqin Jin 3 years ago committed by Facebook GitHub Bot
parent 61a63ae2f9
commit 2acffecca1
  1. 7
      db/blob/blob_file_reader.cc
  2. 1
      db/blob/blob_file_reader.h
  3. 6
      file/random_access_file_reader.cc

@ -358,11 +358,18 @@ void BlobFileReader::MultiGetBlob(
const autovector<uint64_t>& value_sizes, autovector<Status*>& statuses, const autovector<uint64_t>& value_sizes, autovector<Status*>& statuses,
autovector<PinnableSlice*>& values, uint64_t* bytes_read) const { autovector<PinnableSlice*>& values, uint64_t* bytes_read) const {
const size_t num_blobs = user_keys.size(); const size_t num_blobs = user_keys.size();
assert(num_blobs > 0);
assert(num_blobs == offsets.size()); assert(num_blobs == offsets.size());
assert(num_blobs == value_sizes.size()); assert(num_blobs == value_sizes.size());
assert(num_blobs == statuses.size()); assert(num_blobs == statuses.size());
assert(num_blobs == values.size()); assert(num_blobs == values.size());
#ifndef NDEBUG
for (size_t i = 0; i < offsets.size() - 1; ++i) {
assert(offsets[i] <= offsets[i + 1]);
}
#endif // !NDEBUG
std::vector<FSReadRequest> read_reqs(num_blobs); std::vector<FSReadRequest> read_reqs(num_blobs);
autovector<uint64_t> adjustments; autovector<uint64_t> adjustments;
uint64_t total_len = 0; uint64_t total_len = 0;

@ -44,6 +44,7 @@ class BlobFileReader {
CompressionType compression_type, PinnableSlice* value, CompressionType compression_type, PinnableSlice* value,
uint64_t* bytes_read) const; uint64_t* bytes_read) const;
// offsets must be sorted in ascending order by caller.
void MultiGetBlob( void MultiGetBlob(
const ReadOptions& read_options, const ReadOptions& read_options,
const autovector<std::reference_wrapper<const Slice>>& user_keys, const autovector<std::reference_wrapper<const Slice>>& user_keys,

@ -224,6 +224,12 @@ IOStatus RandomAccessFileReader::MultiRead(const IOOptions& opts,
(void)aligned_buf; // suppress warning of unused variable in LITE mode (void)aligned_buf; // suppress warning of unused variable in LITE mode
assert(num_reqs > 0); assert(num_reqs > 0);
#ifndef NDEBUG
for (size_t i = 0; i < num_reqs - 1; ++i) {
assert(read_reqs[i].offset <= read_reqs[i + 1].offset);
}
#endif // !NDEBUG
// To be paranoid modify scratch a little bit, so in case underlying // To be paranoid modify scratch a little bit, so in case underlying
// FileSystem doesn't fill the buffer but return succee and `scratch` returns // FileSystem doesn't fill the buffer but return succee and `scratch` returns
// contains a previous block, returned value will not pass checksum. // contains a previous block, returned value will not pass checksum.

Loading…
Cancel
Save