From cbd3a0b143918636790cf8888338da1b034d73d4 Mon Sep 17 00:00:00 2001 From: silverweed Date: Wed, 4 Mar 2026 12:56:34 +0100 Subject: [PATCH] [rfile] Add some more information in RKeyInfo --- io/io/inc/ROOT/RFile.hxx | 22 ++++++++++++++++++++++ io/io/src/RFile.cxx | 20 ++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/io/io/inc/ROOT/RFile.hxx b/io/io/inc/ROOT/RFile.hxx index 93c8d9f1398c1..31d24ea1ee7c7 100644 --- a/io/io/inc/ROOT/RFile.hxx +++ b/io/io/inc/ROOT/RFile.hxx @@ -83,8 +83,17 @@ private: std::string fClassName; std::uint16_t fCycle = 0; ECategory fCategory = ECategory::kInvalid; + std::uint64_t fLenObj = 0; + std::uint64_t fNBytesObj = 0; + std::uint64_t fNBytesKey = 0; + std::uint64_t fSeekKey = 0; + std::uint64_t fSeekParentDir = 0; + + explicit RKeyInfo(const TKey &key); public: + RKeyInfo() = default; + /// Returns the absolute path of this key, i.e. the directory part plus the object name. const std::string &GetPath() const { return fPath; } /// Returns the base name of this key, i.e. the name of the object without the directory part. @@ -93,6 +102,19 @@ public: const std::string &GetClassName() const { return fClassName; } std::uint16_t GetCycle() const { return fCycle; } ECategory GetCategory() const { return fCategory; } + /// Returns the in-memory size of the uncompressed object. + + std::uint64_t GetLenObj() const { return fLenObj; } + /// Returns the on-disk size of the (potentially compressed) object, excluding its key. + std::uint64_t GetNBytesObj() const { return fNBytesObj; } + + /// Returns the on-disk size of this object's key. + std::uint64_t GetNBytesKey() const { return fNBytesKey; } + /// Returns the on-disk offset of this object's key. + std::uint64_t GetSeekKey() const { return fSeekKey; } + + /// Returns the on-disk offset of this object's parent directory key. + std::uint64_t GetSeekParentDir() const { return fSeekParentDir; } }; /// The iterable returned by RFile::ListKeys() diff --git a/io/io/src/RFile.cxx b/io/io/src/RFile.cxx index 2d7f78120a8c1..9bc73417de241 100644 --- a/io/io/src/RFile.cxx +++ b/io/io/src/RFile.cxx @@ -540,18 +540,26 @@ void RFile::Close() fFile.reset(); } +ROOT::Experimental::RKeyInfo::RKeyInfo(const TKey &key) + : fPath(ReconstructFullKeyPath(key)), + fTitle(key.GetTitle()), + fClassName(key.GetClassName()), + fCycle(key.GetCycle()), + fLenObj(key.GetObjlen()), + fNBytesObj(key.GetNbytes() - key.GetKeylen()), + fNBytesKey(key.GetKeylen()), + fSeekKey(key.GetSeekKey()), + fSeekParentDir(key.GetSeekPdir()) +{ +} + std::optional RFile::GetKeyInfo(std::string_view path) const { const TKey *key = GetTKey(path); if (!key) return {}; - RKeyInfo keyInfo; - keyInfo.fPath = ReconstructFullKeyPath(*key); - keyInfo.fClassName = key->GetClassName(); - keyInfo.fCycle = key->GetCycle(); - keyInfo.fTitle = key->GetTitle(); - + RKeyInfo keyInfo(*key); return keyInfo; }