blob_read_request.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) Meta Platforms, Inc. and affiliates.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <cinttypes>
  7. #include "rocksdb/compression_type.h"
  8. #include "rocksdb/slice.h"
  9. #include "rocksdb/status.h"
  10. #include "util/autovector.h"
  11. namespace ROCKSDB_NAMESPACE {
  12. // A read Blob request structure for use in BlobSource::MultiGetBlob and
  13. // BlobFileReader::MultiGetBlob.
  14. struct BlobReadRequest {
  15. // User key to lookup the paired blob
  16. const Slice* user_key = nullptr;
  17. // File offset in bytes
  18. uint64_t offset = 0;
  19. // Length to read in bytes
  20. size_t len = 0;
  21. // Blob compression type
  22. CompressionType compression = kNoCompression;
  23. // Output parameter set by MultiGetBlob() to point to the data buffer, and
  24. // the number of valid bytes
  25. PinnableSlice* result = nullptr;
  26. // Status of read
  27. Status* status = nullptr;
  28. BlobReadRequest(const Slice& _user_key, uint64_t _offset, size_t _len,
  29. CompressionType _compression, PinnableSlice* _result,
  30. Status* _status)
  31. : user_key(&_user_key),
  32. offset(_offset),
  33. len(_len),
  34. compression(_compression),
  35. result(_result),
  36. status(_status) {}
  37. BlobReadRequest() = default;
  38. BlobReadRequest(const BlobReadRequest& other) = default;
  39. BlobReadRequest& operator=(const BlobReadRequest& other) = default;
  40. };
  41. using BlobFileReadRequests =
  42. std::tuple<uint64_t /* file_number */, uint64_t /* file_size */,
  43. autovector<BlobReadRequest>>;
  44. } // namespace ROCKSDB_NAMESPACE