30 std::unique_ptr<Internal::RPageSink> sink)
31 : fSink(std::move(sink)), fModel(std::move(model)), fMetrics(
"RNTupleFillContext")
37 const auto &writeOpts =
fSink->GetWriteOptions();
40 const int scale = writeOpts.GetCompression() ? 2 : 1;
55 if (fNEntries == fLastCommitted) {
58 if (fSink->GetWriteOptions().GetHasSmallClusters() &&
60 throw RException(
R__FAIL(
"invalid attempt to write a cluster > 512MiB with 'small clusters' option enabled"));
62 for (
auto &field : fModel->GetFieldZero()) {
65 auto nEntriesInCluster = fNEntries - fLastCommitted;
66 fNBytesCommitted += fSink->CommitCluster(nEntriesInCluster);
67 fNBytesFilled += fUnzippedClusterSize;
70 const float compressionFactor =
71 std::min(1000.f,
static_cast<float>(fNBytesFilled) /
static_cast<float>(fNBytesCommitted));
72 fUnzippedClusterSizeEst =
73 compressionFactor *
static_cast<float>(fSink->GetWriteOptions().GetApproxZippedClusterSize());
75 fLastCommitted = fNEntries;
76 fUnzippedClusterSize = 0;
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_ERROR(...)
void ObserveMetrics(RNTupleMetrics &observee)
std::string GetReport() const
Format a dignostics report, e.g. for an exception message.
Base class for all ROOT issued exceptions.
const RError & GetError() const
Detail::RNTupleMetrics fMetrics
std::size_t fUnzippedClusterSizeEst
Estimator of uncompressed cluster size, taking into account the estimated compression ratio.
void CommitCluster()
Ensure that the data from the so far seen Fill calls has been written to storage.
std::unique_ptr< RNTupleModel > fModel
Needs to be destructed before fSink.
std::size_t fMaxUnzippedClusterSize
Limit for committing cluster no matter the other tunables.
RNTupleFillContext(std::unique_ptr< RNTupleModel > model, std::unique_ptr< Internal::RPageSink > sink)
std::unique_ptr< Internal::RPageSink > fSink
static constexpr std::uint64_t kMaxSmallClusterSize
A maximum size of 512MB still allows for a vector of bool to be stored in a small cluster.
void CallCommitClusterOnField(RFieldBase &)
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.