blob_db_gc_stats.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  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. //
  6. #pragma once
  7. #ifndef ROCKSDB_LITE
  8. namespace ROCKSDB_NAMESPACE {
  9. namespace blob_db {
  10. /**
  11. * Statistics related to a single garbage collection pass (i.e. a single
  12. * (sub)compaction).
  13. */
  14. class BlobDBGarbageCollectionStats {
  15. public:
  16. uint64_t AllBlobs() const { return all_blobs_; }
  17. uint64_t AllBytes() const { return all_bytes_; }
  18. uint64_t RelocatedBlobs() const { return relocated_blobs_; }
  19. uint64_t RelocatedBytes() const { return relocated_bytes_; }
  20. uint64_t NewFiles() const { return new_files_; }
  21. bool HasError() const { return error_; }
  22. void AddBlob(uint64_t size) {
  23. ++all_blobs_;
  24. all_bytes_ += size;
  25. }
  26. void AddRelocatedBlob(uint64_t size) {
  27. ++relocated_blobs_;
  28. relocated_bytes_ += size;
  29. }
  30. void AddNewFile() { ++new_files_; }
  31. void SetError() { error_ = true; }
  32. private:
  33. uint64_t all_blobs_ = 0;
  34. uint64_t all_bytes_ = 0;
  35. uint64_t relocated_blobs_ = 0;
  36. uint64_t relocated_bytes_ = 0;
  37. uint64_t new_files_ = 0;
  38. bool error_ = false;
  39. };
  40. } // namespace blob_db
  41. } // namespace ROCKSDB_NAMESPACE
  42. #endif // ROCKSDB_LITE