Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
00f86b64
Commit
00f86b64
authored
2 years ago
by
Florine de Geus
Committed by
Jakob Blomer
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[ntuple] Change importer source tree object ownership
parent
57c09c9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tree/ntupleutil/v7/inc/ROOT/RNTupleImporter.hxx
+1
-0
1 addition, 0 deletions
tree/ntupleutil/v7/inc/ROOT/RNTupleImporter.hxx
tree/ntupleutil/v7/src/RNTupleImporter.cxx
+9
-8
9 additions, 8 deletions
tree/ntupleutil/v7/src/RNTupleImporter.cxx
with
10 additions
and
8 deletions
tree/ntupleutil/v7/inc/ROOT/RNTupleImporter.hxx
+
1
−
0
View file @
00f86b64
...
...
@@ -210,6 +210,7 @@ private:
std
::
unique_ptr
<
TFile
>
fSourceFile
;
std
::
unique_ptr
<
TTree
>
fSourceTree
;
TTree
*
fSourceTreePtr
;
std
::
string
fDestFileName
;
std
::
string
fNTupleName
;
...
...
This diff is collapsed.
Click to expand it.
tree/ntupleutil/v7/src/RNTupleImporter.cxx
+
9
−
8
View file @
00f86b64
...
...
@@ -94,8 +94,9 @@ ROOT::Experimental::RNTupleImporter::Create(std::string_view sourceFileName, std
if
(
!
importer
->
fSourceTree
)
{
return
R__FAIL
(
"cannot read TTree "
+
std
::
string
(
treeName
)
+
" from "
+
std
::
string
(
sourceFileName
));
}
importer
->
fSourceTreePtr
=
importer
->
fSourceTree
.
get
();
// If we have IMT enabled, its best use is for parallel page compression
importer
->
fSourceTree
->
SetImplicitMT
(
false
);
importer
->
fSourceTree
Ptr
->
SetImplicitMT
(
false
);
importer
->
SetupDestination
(
destFileName
);
...
...
@@ -107,10 +108,10 @@ ROOT::Experimental::RNTupleImporter::Create(TTree *sourceTree, std::string_view
{
auto
importer
=
std
::
unique_ptr
<
RNTupleImporter
>
(
new
RNTupleImporter
());
importer
->
fNTupleName
=
sourceTree
->
GetName
();
importer
->
fSourceTree
=
std
::
unique_ptr
<
TTree
>
(
sourceTree
)
;
importer
->
fSourceTree
Ptr
=
sourceTree
;
// If we have IMT enabled, its best use is for parallel page compression
importer
->
fSourceTree
->
SetImplicitMT
(
false
);
importer
->
fSourceTree
Ptr
->
SetImplicitMT
(
false
);
importer
->
SetupDestination
(
destFileName
);
...
...
@@ -153,7 +154,7 @@ ROOT::Experimental::RResult<void> ROOT::Experimental::RNTupleImporter::PrepareSc
// Browse through all branches and their leaves, create corresponding fields and prepare the memory buffers for
// reading and writing. Usually, reading and writing share the same memory buffer, i.e. the object is read from TTree
// and written as-is to the RNTuple. There are exceptions, e.g. for leaf count arrays and C strings.
for
(
auto
b
:
TRangeDynCast
<
TBranch
>
(
*
fSourceTree
->
GetListOfBranches
()))
{
for
(
auto
b
:
TRangeDynCast
<
TBranch
>
(
*
fSourceTree
Ptr
->
GetListOfBranches
()))
{
assert
(
b
);
const
auto
firstLeaf
=
static_cast
<
TLeaf
*>
(
b
->
GetListOfLeaves
()
->
First
());
assert
(
firstLeaf
);
...
...
@@ -181,7 +182,7 @@ ROOT::Experimental::RResult<void> ROOT::Experimental::RNTupleImporter::PrepareSc
c
.
fMaxLength
=
firstLeaf
->
GetMaximum
();
c
.
fCountVal
=
std
::
make_unique
<
Int_t
>
();
// count leafs are integers
// Casting to void * makes it work for both Int_t and UInt_t
fSourceTree
->
SetBranchAddress
(
b
->
GetName
(),
static_cast
<
void
*>
(
c
.
fCountVal
.
get
()));
fSourceTree
Ptr
->
SetBranchAddress
(
b
->
GetName
(),
static_cast
<
void
*>
(
c
.
fCountVal
.
get
()));
fLeafCountCollections
.
emplace
(
firstLeaf
->
GetName
(),
std
::
move
(
c
));
continue
;
}
...
...
@@ -277,9 +278,9 @@ ROOT::Experimental::RResult<void> ROOT::Experimental::RNTupleImporter::PrepareSc
std
::
string
(
b
->
GetName
()));
}
auto
ptrBuf
=
reinterpret_cast
<
void
**>
(
ib
.
fBranchBuffer
.
get
());
fSourceTree
->
SetBranchAddress
(
b
->
GetName
(),
ptrBuf
,
klass
,
EDataType
::
kOther_t
,
true
/* isptr*/
);
fSourceTree
Ptr
->
SetBranchAddress
(
b
->
GetName
(),
ptrBuf
,
klass
,
EDataType
::
kOther_t
,
true
/* isptr*/
);
}
else
{
fSourceTree
->
SetBranchAddress
(
b
->
GetName
(),
reinterpret_cast
<
void
*>
(
ib
.
fBranchBuffer
.
get
()));
fSourceTree
Ptr
->
SetBranchAddress
(
b
->
GetName
(),
reinterpret_cast
<
void
*>
(
ib
.
fBranchBuffer
.
get
()));
}
// If the TTree branch type and the RNTuple field type match, use the branch read buffer as RNTuple write buffer
...
...
@@ -365,7 +366,7 @@ ROOT::Experimental::RResult<void> ROOT::Experimental::RNTupleImporter::Import()
}
for
(
decltype
(
nEntries
)
i
=
0
;
i
<
nEntries
;
++
i
)
{
fSourceTree
->
GetEntry
(
i
);
fSourceTree
Ptr
->
GetEntry
(
i
);
for
(
const
auto
&
[
_
,
c
]
:
fLeafCountCollections
)
{
for
(
Int_t
l
=
0
;
l
<
*
c
.
fCountVal
;
++
l
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment