Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c51f0b9
[ntuple] minor cleanup in RPageSink declaration
jblomer Nov 21, 2026
3d046f2
[ntuple] move RPageStorage::DropColumn() to RPageSource
jblomer Nov 19, 2026
ee37874
[ntuple] make RPageSink::fOptions private
jblomer Nov 19, 2026
d66023e
[ntuple] remove unused EPageStorageType
jblomer Nov 19, 2026
c459154
[ntuple] RPageSink::GetNEntries() --> RPagePersistentSink::GetNCommit…
jblomer Nov 19, 2026
055a706
[ntuple] RPagePersistentSink::InitImpl() overload --> CommitHeaderImpl()
jblomer Nov 19, 2026
775f9fd
[ntuple] remove ColumnHandle_t from internal LoadPage methods
jblomer Nov 20, 2026
213fda1
[ntuple] remove ColumnHandle_t from LoadPage()
jblomer Nov 20, 2026
c674aa6
[ntuple] remove ColumnHandle_t from RPageSource::DropColumn()
jblomer Nov 20, 2026
e98fd4d
[ntuple] remove ColumnHandle_t from RPageSource::AddColumn()
jblomer Nov 20, 2026
73c084d
[ntuple] remove AddColumn from RPageStorage base class
jblomer Nov 20, 2026
525210a
[ntuple] remove ColumnHandle_t from CommitSuppressedColumn()
jblomer Nov 20, 2026
3a8d68c
[ntuple] remove ColumnHandle_t from RColumnBuf
jblomer Nov 20, 2026
0664915
[ntuple] remove ColumnHandle_t from RPageSink::CommitPage()
jblomer Nov 20, 2026
445d473
[ntuple] remove ColumnHandle_t from RPageSink::ReservePage()
jblomer Nov 20, 2026
32c27b7
[ntuple] remove RPageStorage::ColumnHandle_t
jblomer Nov 20, 2026
7626a45
[ntuple] move RPageStorage::fMetrics into Sink/Source
jblomer Nov 20, 2026
86ad0c2
[ntuple] move RPageStorage::fPageAllocator into Sink/Source
jblomer Nov 20, 2026
b884832
[ntuple] move RPageStorage::fNTupleName into Sink/Source
jblomer Nov 21, 2026
2e5f2a0
[ntuple] RPageStorage::RTaskScheduler --> Internal::RNTupleTaskScheduler
jblomer Nov 21, 2026
32b689a
[ntuple] move RPageStorage::fTaskScheduler into Sink/Source
jblomer Nov 21, 2026
faa793e
[ntuple] move RPageStorage::RSealedPage to internal stand-alone class
jblomer Nov 21, 2026
ca2dd53
[ntuple] remove empty RPageStorage base class
jblomer Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tree/ntuple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ set(ROOTNTuple_HEADERS
ROOT/RPageStorage.hxx
ROOT/RPageStorageFile.hxx
ROOT/RRawPtrWriteEntry.hxx
ROOT/RSealedPage.hxx
)

ROOT_STANDARD_LIBRARY_PACKAGE(ROOTNTuple
Expand Down Expand Up @@ -118,6 +119,7 @@ SOURCES
src/RPageSinkBuf.cxx
src/RPageStorage.cxx
src/RPageStorageFile.cxx
src/RSealedPage.cxx
${ROOTNTuple_EXTRA_SOURCES}
LINKDEF
LinkDef.h
Expand All @@ -141,7 +143,7 @@ set(ROOTNTuple_NONSTANDALONE_HEADERS
set(RELATIVE_INC_HEADERS ${ROOTNTuple_HEADERS} ${ROOTNTuple_EXTRA_HEADERS} ${ROOTNTuple_NONSTANDALONE_HEADERS})
if(daos_mock)
list(APPEND RELATIVE_INC_HEADERS ROOT/libdaos_mock/daos.h ROOT/RDaos.hxx)
endif()
endif()
list(TRANSFORM RELATIVE_INC_HEADERS PREPEND inc/)
target_sources(ROOTNTuple
PRIVATE
Expand Down
6 changes: 2 additions & 4 deletions tree/ntuple/inc/ROOT/RColumn.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ protected:
{
}

ROOT::Internal::RPageStorage::ColumnHandle_t MakeHandle() { return {fOnDiskId, this}; }

public:
enum class EColumnType {
kRead,
Expand Down Expand Up @@ -334,7 +332,7 @@ private:
// Maximum page size reached, flush and reset
Flush();
} else {
auto expandedPage = fPageSink->ReservePage(MakeHandle(), newMaxElements);
auto expandedPage = fPageSink->ReservePage(*this, newMaxElements);
if (expandedPage.IsNull()) {
Flush();
} else {
Expand Down Expand Up @@ -363,7 +361,7 @@ public:
return column;
}

~RWriteColumn();
~RWriteColumn() = default;

/// Connect the column to a page sink. `firstElementIndex` can be used to specify the first column element index
/// with backing storage for this column. On read back, elements before `firstElementIndex` will cause the zero page
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/inc/ROOT/RNTupleFillContext.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class RNTupleFillContext {
private:
/// The page sink's parallel page compression scheduler if IMT is on.
/// Needs to be destructed after the page sink is destructed and so declared before.
std::unique_ptr<ROOT::Internal::RPageStorage::RTaskScheduler> fZipTasks;
std::unique_ptr<ROOT::Internal::RNTupleTaskScheduler> fZipTasks;
std::unique_ptr<ROOT::Internal::RPageSink> fSink;
/// Needs to be destructed before fSink
std::unique_ptr<ROOT::RNTupleModel> fModel;
Expand Down
4 changes: 2 additions & 2 deletions tree/ntuple/inc/ROOT/RNTupleImtTaskScheduler.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#ifdef R__USE_IMT

#include <ROOT/RPageStorage.hxx>
#include <ROOT/RNTupleUtils.hxx>
#include <ROOT/TTaskGroup.hxx>

#include <functional>
Expand All @@ -28,7 +28,7 @@ namespace Experimental {

namespace Internal {

class RNTupleImtTaskScheduler : public ROOT::Internal::RPageStorage::RTaskScheduler {
class RNTupleImtTaskScheduler : public ROOT::Internal::RNTupleTaskScheduler {
private:
TTaskGroup fTaskGroup;

Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/inc/ROOT/RNTupleReader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private:

/// Set as the page source's scheduler for parallel page decompression if implicit multi-threading (IMT) is on.
/// Needs to be destructed after the page source is destructed (and thus be declared before)
std::unique_ptr<Internal::RPageStorage::RTaskScheduler> fUnzipTasks;
std::unique_ptr<Internal::RNTupleTaskScheduler> fUnzipTasks;

std::unique_ptr<Internal::RPageSource> fSource;
/// Needs to be destructed before fSource
Expand Down
11 changes: 11 additions & 0 deletions tree/ntuple/inc/ROOT/RNTupleUtils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <ROOT/RError.hxx>

#include <cstddef>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -73,6 +74,16 @@ public:
void Freeze() { fFrozen = true; }
};

/// The interface of a task scheduler to schedule page (de)compression tasks
class RNTupleTaskScheduler {
public:
virtual ~RNTupleTaskScheduler() = default;
/// Take a callable that represents a task
virtual void AddTask(const std::function<void(void)> &taskFunc) = 0;
/// Blocks until all scheduled tasks finished
virtual void Wait() = 0;
};

} // namespace Internal
} // namespace ROOT

Expand Down
15 changes: 5 additions & 10 deletions tree/ntuple/inc/ROOT/RPageNullSink.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,14 @@ public:
{
}

ColumnHandle_t AddColumn(ROOT::DescriptorId_t, ROOT::Internal::RColumn &column) final
{
return {fNColumns++, &column};
}
DescriptorId_t AddColumn(ROOT::DescriptorId_t, const ROOT::Internal::RColumn &) final { return fNColumns++; }

const ROOT::RNTupleDescriptor &GetDescriptor() const final
{
static ROOT::RNTupleDescriptor descriptor;
return descriptor;
}

ROOT::NTupleSize_t GetNEntries() const final { return 0; }

void ConnectFields(const std::vector<ROOT::RFieldBase *> &fields, ROOT::NTupleSize_t firstEntry)
{
auto connectField = [&](ROOT::RFieldBase &f) {
Expand All @@ -80,16 +75,16 @@ public:
}
void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &) final {}

void CommitSuppressedColumn(ColumnHandle_t) final {}
void CommitPage(ColumnHandle_t, const ROOT::Internal::RPage &page) final
void CommitSuppressedColumn(DescriptorId_t) final {}
void CommitPage(DescriptorId_t, const ROOT::Internal::RColumnElementBase &, const ROOT::Internal::RPage &page) final
{
fNBytesCurrentCluster += page.GetNBytes();
}
void CommitSealedPage(ROOT::DescriptorId_t, const RSealedPage &page) final
void CommitSealedPage(ROOT::DescriptorId_t, const ROOT::Internal::RSealedPage &page) final
{
fNBytesCurrentCluster += page.GetBufferSize();
}
void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final
void CommitSealedPageV(std::span<ROOT::Internal::RSealedPageGroup> ranges) final
{
for (auto &range : ranges) {
for (auto sealedPageIt = range.fFirst; sealedPageIt != range.fLast; ++sealedPageIt) {
Expand Down
33 changes: 15 additions & 18 deletions tree/ntuple/inc/ROOT/RPageSinkBuf.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class RPageSinkBuf : public RPageSink {
RPage fPage;
// Compression scratch buffer for fSealedPage.
std::unique_ptr<unsigned char[]> fBuf;
RPageStorage::RSealedPage *fSealedPage = nullptr;
RSealedPage *fSealedPage = nullptr;
bool IsSealed() const { return fSealedPage != nullptr; }
};
public:

RColumnBuf() = default;
RColumnBuf(const RColumnBuf&) = delete;
RColumnBuf& operator=(const RColumnBuf&) = delete;
Expand All @@ -58,19 +58,15 @@ class RPageSinkBuf : public RPageSink {

/// Returns a reference to the newly buffered page. The reference remains
/// valid until DropBufferedPages().
RPageZipItem &BufferPage(RPageStorage::ColumnHandle_t columnHandle)
RPageZipItem &BufferPage()
{
if (!fCol) {
fCol = columnHandle;
}
// Safety: Insertion at the end of a deque never invalidates references
// to existing elements.
return fBufferedPages.emplace_back();
}
const RPageStorage::ColumnHandle_t &GetHandle() const { return fCol; }
bool IsEmpty() const { return fBufferedPages.empty(); }
bool HasSealedPagesOnly() const { return fBufferedPages.size() == fSealedPages.size(); }
const RPageStorage::SealedPageSequence_t &GetSealedPages() const { return fSealedPages; }
const SealedPageSequence_t &GetSealedPages() const { return fSealedPages; }

void DropBufferedPages();

Expand All @@ -82,15 +78,14 @@ class RPageSinkBuf : public RPageSink {
}

private:
RPageStorage::ColumnHandle_t fCol;
/// Using a deque guarantees that element iterators are never invalidated
/// by appends to the end of the iterator by BufferPage.
std::deque<RPageZipItem> fBufferedPages;
/// Pages that have been already sealed by a concurrent task. A vector commit can be issued if all
/// buffered pages have been sealed.
/// Note that each RSealedPage refers to the same buffer as `fBufferedPages[i].fBuf` for some value of `i`, and
/// thus owned by RPageZipItem
RPageStorage::SealedPageSequence_t fSealedPages;
SealedPageSequence_t fSealedPages;
};

/// I/O performance counters that get registered in fMetrics
Expand All @@ -113,10 +108,12 @@ class RPageSinkBuf : public RPageSink {
/// Vector of buffered column pages. Indexed by column id.
std::vector<RColumnBuf> fBufferedColumns;
/// Columns committed as suppressed are stored and passed to the inner sink at cluster commit
std::vector<ColumnHandle_t> fSuppressedColumns;
std::vector<DescriptorId_t> fSuppressedColumns;
ROOT::DescriptorId_t fNFields = 0;
ROOT::DescriptorId_t fNColumns = 0;
RNTupleTaskScheduler *fTaskScheduler = nullptr; ///< For parallel page compression

void WaitForAllTasks();
void ConnectFields(const std::vector<ROOT::RFieldBase *> &fields, ROOT::NTupleSize_t firstEntry);
void FlushClusterImpl(const std::function<void(void)> &FlushClusterFn);

Expand All @@ -131,26 +128,26 @@ public:
RPageSinkBuf &operator=(RPageSinkBuf &&) = delete;
~RPageSinkBuf() override;

ColumnHandle_t AddColumn(ROOT::DescriptorId_t fieldId, RColumn &column) final;
void SetTaskScheduler(RNTupleTaskScheduler *taskScheduler) final { fTaskScheduler = taskScheduler; }

const ROOT::RNTupleDescriptor &GetDescriptor() const final;
DescriptorId_t AddColumn(ROOT::DescriptorId_t fieldId, const RColumn &column) final;

ROOT::NTupleSize_t GetNEntries() const final { return fInnerSink->GetNEntries(); }
const ROOT::RNTupleDescriptor &GetDescriptor() const final;

void UpdateSchema(const RNTupleModelChangeset &changeset, ROOT::NTupleSize_t firstEntry) final;
void UpdateExtraTypeInfo(const ROOT::RExtraTypeInfoDescriptor &extraTypeInfo) final;

void CommitSuppressedColumn(ColumnHandle_t columnHandle) final;
void CommitPage(ColumnHandle_t columnHandle, const RPage &page) final;
void CommitSuppressedColumn(DescriptorId_t physicalColumnId) final;
void CommitPage(DescriptorId_t physicalColumnId, const RColumnElementBase &elem, const RPage &page) final;
void CommitSealedPage(ROOT::DescriptorId_t physicalColumnId, const RSealedPage &sealedPage) final;
void CommitSealedPageV(std::span<RPageStorage::RSealedPageGroup> ranges) final;
void CommitSealedPageV(std::span<RSealedPageGroup> ranges) final;
std::uint64_t CommitCluster(ROOT::NTupleSize_t nNewEntries) final;
RStagedCluster StageCluster(ROOT::NTupleSize_t nNewEntries) final;
void CommitStagedClusters(std::span<RStagedCluster> clusters) final;
void CommitClusterGroup() final;
void CommitAttributeSet(std::string_view attrSetName, const RNTupleLink &attrAnchorInfo) final;

RPage ReservePage(ColumnHandle_t columnHandle, std::size_t nElements) final;
RPage ReservePage(RWriteColumn &column, std::size_t nElements) final;

std::unique_ptr<RPageSink> CloneAsHidden(std::string_view name, const RNTupleWriteOptions &opts) const final;
}; // RPageSinkBuf
Expand Down
Loading
Loading