Project
Loading...
Searching...
No Matches
Container.h
Go to the documentation of this file.
1// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_FRAMEWORK_AODNATIVE_CONTAINER_H_
13#define O2_FRAMEWORK_AODNATIVE_CONTAINER_H_
14
16#include "AODNative/Objects.h"
17#include <cstdint>
18#include <map>
19#include <memory>
20#include <optional>
21#include <string>
22#include <vector>
23
24namespace o2::aod::native
25{
26
27struct FileHeader {
28 int32_t version;
29 int32_t begin;
30 uint64_t end, seekFree;
32 uint8_t units;
33 int32_t compress;
34 uint64_t seekInfo;
35 int32_t nbytesInfo;
36};
37
38struct KeyInfo {
39 uint32_t nbytes;
40 int16_t version;
41 uint32_t objlen;
42 uint16_t keylen, cycle;
43 uint64_t seekKey, seekPdir;
44 std::string className, name, title;
45 bool compressed() const { return objlen != nbytes - keylen; }
46};
47
49 int16_t version;
52};
53
57{
58 public:
59 explicit RootFile(std::shared_ptr<ByteSource>);
60 FileHeader const& header() const { return mHeader; }
61 ByteSource& source() { return *mSource; }
62 std::shared_ptr<ByteSource> const& sourcePtr() const { return mSource; }
64 const std::vector<KeyInfo>& topKeys();
67 std::vector<std::string> dataFrames();
71 std::vector<KeyInfo> keysOf(const std::string& df);
73 void setTreesToPrefetch(std::vector<std::string> names) { mTreesToPrefetch = std::move(names); }
76 std::map<std::string, std::string> readStringMap(const std::string& key);
78 std::vector<uint8_t> readPayload(const KeyInfo&);
79
80 private:
81 KeyInfo parseKey(std::span<const uint8_t> buf, uint64_t fileOffset);
82 DirectoryInfo readDirectory(uint64_t offset);
83 std::vector<KeyInfo> readKeyList(DirectoryInfo const&);
84 std::optional<KeyInfo> findTopKey(std::string const& name);
85 std::vector<uint8_t> readStored(const KeyInfo&);
86
87 std::shared_ptr<ByteSource> mSource;
88 std::string mUrl;
89 FileHeader mHeader;
90 std::optional<std::vector<KeyInfo>> mTopKeys;
91 // Stored bytes of the TTrees of the last DF listed, by key offset, until read.
92 std::map<uint64_t, std::vector<uint8_t>> mPrefetched;
93 std::map<std::string, std::vector<KeyInfo>> mKeysOf;
94 std::vector<std::string> mTreesToPrefetch;
95 std::map<std::string, std::map<std::string, std::string>> mStringMaps;
96};
97
99std::vector<KeyInfo> highestCycles(std::vector<KeyInfo> const& keys);
100
101} // namespace o2::aod::native
102
103#endif // O2_FRAMEWORK_AODNATIVE_CONTAINER_H_
std::vector< std::string > keys
StringRef key
const std::vector< KeyInfo > & topKeys()
All the keys of the top directory, every cycle, in on-disk order.
TreeInfo readTree(const KeyInfo &)
std::shared_ptr< ByteSource > const & sourcePtr() const
Definition Container.h:62
std::vector< std::string > dataFrames()
void setTreesToPrefetch(std::vector< std::string > names)
The TTrees whose bytes keysOf() fetches along; all of them when empty.
Definition Container.h:73
std::map< std::string, std::string > readStringMap(const std::string &key)
Empty map if the key does not exist. Read once per key.
FileHeader const & header() const
Definition Container.h:60
ByteSource & source()
Definition Container.h:61
std::vector< uint8_t > readPayload(const KeyInfo &)
The uncompressed payload of a key.
std::vector< KeyInfo > keysOf(const std::string &df)
GLuint const GLchar * name
Definition glcorearb.h:781
GLintptr offset
Definition glcorearb.h:660
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glcorearb.h:2514
std::vector< KeyInfo > highestCycles(std::vector< KeyInfo > const &keys)
Keeps only the highest cycle of each name, preserving first-seen order.
bool compressed() const
Definition Container.h:45