MCPcopy Create free account
hub / github.com/facebook/CacheLib / PtrCompressor

Class PtrCompressor

cachelib/allocator/memory/CompressedPtr.h:356–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354
355template <typename PtrType, typename AllocatorT, typename CompressedPtrType>
356class PtrCompressor {
357 public:
358 explicit PtrCompressor(const AllocatorT& allocator) noexcept
359 : allocator_(allocator) {}
360
361 const CompressedPtrType compress(const PtrType* uncompressed) const {
362 return allocator_.template compress<CompressedPtrType>(
363 uncompressed, false /* isMultiTiered */);
364 }
365
366 PtrType* unCompress(const CompressedPtrType& compressed) const {
367 return static_cast<PtrType*>(
368 allocator_.template unCompress<CompressedPtrType>(
369 compressed, false /* isMultiTiered */));
370 }
371
372 bool operator==(const PtrCompressor& rhs) const noexcept {
373 return &allocator_ == &rhs.allocator_;
374 }
375
376 bool operator!=(const PtrCompressor& rhs) const noexcept {
377 return !(*this == rhs);
378 }
379
380 private:
381 // memory allocator that does the pointer compression.
382 const AllocatorT& allocator_;
383};
384} // namespace cachelib
385} // namespace facebook

Callers 1

ContainerMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected