do_uncompress_(do_uncompress),
maybe_compressed_(maybe_compressed),
block_type_(block_type),
+ block_size_(static_cast<size_t>(handle_.size())),
+ block_size_with_trailer_(block_size(handle_)),
uncompression_dict_(uncompression_dict),
cache_options_(cache_options),
memory_allocator_(memory_allocator),
Status ReadBlockContents();
CompressionType get_compression_type() const { return compression_type_; }
+#ifndef NDEBUG
+ int TEST_GetNumStackBufMemcpy() const { return num_stack_buf_memcpy_; }
+ int TEST_GetNumHeapBufMemcpy() const { return num_heap_buf_memcpy_; }
+ int TEST_GetNumCompressedBufMemcpy() const {
+ return num_compressed_buf_memcpy_;
+ }
+
+#endif
private:
+#ifndef NDEBUG
+ int num_stack_buf_memcpy_ = 0;
+ int num_heap_buf_memcpy_ = 0;
+ int num_compressed_buf_memcpy_ = 0;
+
+#endif
static const uint32_t kDefaultStackBufferSize = 5000;
RandomAccessFileReader* file_;
const BlockHandle& handle_;
BlockContents* contents_;
const ImmutableCFOptions& ioptions_;
- bool do_uncompress_;
- bool maybe_compressed_;
- BlockType block_type_;
+ const bool do_uncompress_;
+ const bool maybe_compressed_;
+ const BlockType block_type_;
+ const size_t block_size_;
+ const size_t block_size_with_trailer_;
const UncompressionDict& uncompression_dict_;
const PersistentCacheOptions& cache_options_;
MemoryAllocator* memory_allocator_;
Status status_;
Slice slice_;
char* used_buf_ = nullptr;
- size_t block_size_;
+ AlignedBuf direct_io_buf_;
CacheAllocationPtr heap_buf_;
CacheAllocationPtr compressed_buf_;
char stack_buf_[kDefaultStackBufferSize];
bool got_from_prefetch_buffer_ = false;
- ROCKSDB_NAMESPACE::CompressionType compression_type_;
+ CompressionType compression_type_;
bool for_compaction_ = false;
// return true if found
bool TryGetFromPrefetchBuffer();
bool TryGetCompressedBlockFromPersistentCache();
void PrepareBufferForBlockFromFile();
- // Copy content from used_buf_ to new heap buffer.
- void CopyBufferToHeap();
+ // Copy content from used_buf_ to new heap_buf_.
+ void CopyBufferToHeapBuf();
+ // Copy content from used_buf_ to new compressed_buf_.
+ void CopyBufferToCompressedBuf();
void GetBlockContents();
void InsertCompressedBlockToPersistentCacheIfNeeded();
void InsertUncompressedBlockToPersistentCacheIfNeeded();