blob_file_meta.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include "db/blob/blob_file_meta.h"
  6. #include <ostream>
  7. #include <sstream>
  8. #include "db/blob/blob_log_format.h"
  9. #include "rocksdb/slice.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. uint64_t SharedBlobFileMetaData::GetBlobFileSize() const {
  12. return BlobLogHeader::kSize + total_blob_bytes_ + BlobLogFooter::kSize;
  13. }
  14. std::string SharedBlobFileMetaData::DebugString() const {
  15. std::ostringstream oss;
  16. oss << (*this);
  17. return oss.str();
  18. }
  19. std::ostream& operator<<(std::ostream& os,
  20. const SharedBlobFileMetaData& shared_meta) {
  21. os << "blob_file_number: " << shared_meta.GetBlobFileNumber()
  22. << " total_blob_count: " << shared_meta.GetTotalBlobCount()
  23. << " total_blob_bytes: " << shared_meta.GetTotalBlobBytes()
  24. << " checksum_method: " << shared_meta.GetChecksumMethod()
  25. << " checksum_value: "
  26. << Slice(shared_meta.GetChecksumValue()).ToString(/* hex */ true);
  27. return os;
  28. }
  29. std::string BlobFileMetaData::DebugString() const {
  30. std::ostringstream oss;
  31. oss << (*this);
  32. return oss.str();
  33. }
  34. std::ostream& operator<<(std::ostream& os, const BlobFileMetaData& meta) {
  35. const auto& shared_meta = meta.GetSharedMeta();
  36. assert(shared_meta);
  37. os << (*shared_meta);
  38. os << " linked_ssts: {";
  39. for (uint64_t file_number : meta.GetLinkedSsts()) {
  40. os << ' ' << file_number;
  41. }
  42. os << " }";
  43. os << " garbage_blob_count: " << meta.GetGarbageBlobCount()
  44. << " garbage_blob_bytes: " << meta.GetGarbageBlobBytes();
  45. return os;
  46. }
  47. } // namespace ROCKSDB_NAMESPACE