Skip to content

Commit f861861

Browse files
committed
[ntuple] allow for returning field substitute in BeforeConnectPageSource()
1 parent 783e064 commit f861861

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

tree/ntuple/inc/ROOT/RField.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected:
207207
void ReadGlobalImpl(ROOT::NTupleSize_t globalIndex, void *to) final;
208208
void ReadInClusterImpl(RNTupleLocalIndex localIndex, void *to) final;
209209

210-
void BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final;
210+
std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource) final;
211211
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
212212

213213
public:
@@ -262,7 +262,7 @@ protected:
262262
// Returns the list of seen streamer infos
263263
ROOT::RExtraTypeInfoDescriptor GetExtraTypeInfo() const final;
264264

265-
void BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final;
265+
std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource &source) final;
266266
void ReconcileOnDiskField(const RNTupleDescriptor &desc) final;
267267

268268
public:

tree/ntuple/inc/ROOT/RFieldBase.hxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,11 @@ protected:
514514
/// Called by ConnectPageSource() before connecting; derived classes may override this as appropriate, e.g.
515515
/// for the application of I/O rules. In the process, the field at hand or its subfields may be marked as
516516
/// "artifical", i.e. introduced by schema evolution and not backed by on-disk information.
517-
virtual void BeforeConnectPageSource(ROOT::Internal::RPageSource & /* source */) {}
517+
/// May return a field substitute that fits the on-disk schema as a replacement for the field at hand
518+
virtual std::unique_ptr<RFieldBase> BeforeConnectPageSource(ROOT::Internal::RPageSource & /* source */)
519+
{
520+
return nullptr;
521+
}
518522

519523
/// For non-artificial fields, check compatibility of the in-memory field and the on-disk field. In the process,
520524
/// the field at hand may change its on-disk ID or perform other tasks related to automatic schema evolution.

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void ROOT::RClassField::AddReadCallbacksFromIORule(const TSchemaRule *rule)
440440
});
441441
}
442442

443-
void ROOT::RClassField::BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource)
443+
std::unique_ptr<ROOT::RFieldBase> ROOT::RClassField::BeforeConnectPageSource(ROOT::Internal::RPageSource &pageSource)
444444
{
445445
std::vector<const TSchemaRule *> rules;
446446
// On-disk members that are not targeted by an I/O rule; all other sub fields of the in-memory class
@@ -507,6 +507,8 @@ void ROOT::RClassField::BeforeConnectPageSource(ROOT::Internal::RPageSource &pag
507507
CallSetArtificialOn(*field);
508508
}
509509
}
510+
511+
return nullptr;
510512
}
511513

512514
void ROOT::RClassField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
@@ -979,9 +981,10 @@ void ROOT::RStreamerField::GenerateColumns(const ROOT::RNTupleDescriptor &desc)
979981
GenerateColumnsImpl<ROOT::Internal::RColumnIndex, std::byte>(desc);
980982
}
981983

982-
void ROOT::RStreamerField::BeforeConnectPageSource(ROOT::Internal::RPageSource &source)
984+
std::unique_ptr<ROOT::RFieldBase> ROOT::RStreamerField::BeforeConnectPageSource(ROOT::Internal::RPageSource &source)
983985
{
984986
source.RegisterStreamerInfos();
987+
return nullptr;
985988
}
986989

987990
void ROOT::RStreamerField::ReconcileOnDiskField(const RNTupleDescriptor &desc)

0 commit comments

Comments
 (0)