Skip to content

Commit 729b95f

Browse files
committed
[rfile] Add some more information in RKeyInfo
1 parent 7dce919 commit 729b95f

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

io/io/inc/ROOT/RFile.hxx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,17 @@ private:
8383
std::string fClassName;
8484
std::uint16_t fCycle = 0;
8585
ECategory fCategory = ECategory::kInvalid;
86+
std::uint64_t fObjLen = 0;
87+
std::uint64_t fObjNBytes = 0;
88+
std::uint64_t fKeyLen = 0;
89+
std::uint64_t fKeySeek = 0;
90+
std::uint64_t fParentDirSeek = 0;
91+
92+
explicit RKeyInfo(const TKey &key);
8693

8794
public:
95+
RKeyInfo() = default;
96+
8897
/// Returns the absolute path of this key, i.e. the directory part plus the object name.
8998
const std::string &GetPath() const { return fPath; }
9099
/// Returns the base name of this key, i.e. the name of the object without the directory part.
@@ -93,6 +102,16 @@ public:
93102
const std::string &GetClassName() const { return fClassName; }
94103
std::uint16_t GetCycle() const { return fCycle; }
95104
ECategory GetCategory() const { return fCategory; }
105+
/// Returns the in-memory size of the uncompressed object.
106+
std::uint64_t GetObjLen() const { return fObjLen; }
107+
/// Returns the on-disk size of the (potentially compressed) object, excluding its key.
108+
std::uint64_t GetObjNBytes() const { return fObjNBytes; }
109+
/// Returns the on-disk size of this object's key.
110+
std::uint64_t GetKeyLen() const { return fKeyLen; }
111+
/// Returns the on-disk offset of this object's key.
112+
std::uint64_t GetKeySeek() const { return fKeySeek; }
113+
/// Returns the on-disk offset of this object's parent directory key.
114+
std::uint64_t GetParentDirSeek() const { return fParentDirSeek; }
96115
};
97116

98117
/// The iterable returned by RFile::ListKeys()

io/io/src/RFile.cxx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,26 @@ void RFile::Close()
540540
fFile.reset();
541541
}
542542

543+
ROOT::Experimental::RKeyInfo::RKeyInfo(const TKey &key)
544+
: fPath(ReconstructFullKeyPath(key)),
545+
fTitle(key.GetTitle()),
546+
fClassName(key.GetClassName()),
547+
fCycle(key.GetCycle()),
548+
fObjLen(key.GetObjlen()),
549+
fObjNBytes(key.GetNbytes() - key.GetKeylen()),
550+
fKeyLen(key.GetKeylen()),
551+
fKeySeek(key.GetSeekKey()),
552+
fParentDirSeek(key.GetSeekPdir())
553+
{
554+
}
555+
543556
std::optional<ROOT::Experimental::RKeyInfo> RFile::GetKeyInfo(std::string_view path) const
544557
{
545558
const TKey *key = GetTKey(path);
546559
if (!key)
547560
return {};
548561

549-
RKeyInfo keyInfo;
550-
keyInfo.fPath = ReconstructFullKeyPath(*key);
551-
keyInfo.fClassName = key->GetClassName();
552-
keyInfo.fCycle = key->GetCycle();
553-
keyInfo.fTitle = key->GetTitle();
554-
562+
RKeyInfo keyInfo(*key);
555563
return keyInfo;
556564
}
557565

0 commit comments

Comments
 (0)