If I take a snapshot of an empty RDataFrame
, ImplicitMT
results in an empty output file. If ImplicitMT
is not enabled, however, I end up with an output file that stores an empty TTree
. Reproducers follow.
Enabling ImplicitMT
results in an empty file:
import ROOT as r
r.ROOT.EnableImplicitMT() # turn on multithreading
rdf = r.RDataFrame(10).Define('e', 'rdfentry_').Filter('e > 20') # create 0 entry data frame
s = rdf.Snapshot('test', 'test.root')
f = r.TFile.Open('test.root')
f.ls()
# TFile** test.root test.root
# TFile* test.root test.root
Disabling ImplicitMT
results in an empty tree:
r.ROOT.DisableImplicitMT() # turn off multithreading
rdf = r.RDataFrame(10).Define('e', 'rdfentry_').Filter('e > 20') # create 0 entry data frame
s = rdf.Snapshot('test', 'test.root')
f = r.TFile.Open('test.root')
f.ls()
# TFile** test.root
# TFile* test.root
# OBJ: TTree test test : 0 at: 0x5565946dda70
# KEY: TTree test;1 test
t = f.Get('test')
t.Print()
# ******************************************************************************
# *Tree :test : test *
# *Entries : 0 : Total = 317 bytes File Size = 179 *
# * : : Tree compression factor = 1.00 *
# ******************************************************************************
If the RDataFrame
is not empty, there are other storage differences. Specifically, the file size, total size, and number of baskets differ:
r.ROOT.EnableImplicitMT()
rdf = r.RDataFrame(10).Define('e', 'rdfentry_')
s = rdf.Snapshot('test', 'test.root')
f = r.TFile.Open('test.root')
t = f.Get('test')
t.Print()
# ******************************************************************************
# *Tree :test : test *
# *Entries : 10 : Total = 1594 bytes File Size = 1153 *
# * : : Tree compression factor = 1.00 *
# ******************************************************************************
# *Br 0 :e : e/l *
# *Entries : 10 : Total Size= 1257 bytes File Size = 760 *
# *Baskets : 10 : Basket Size= 32000 bytes Compression= 1.00 *
# *............................................................................*
r.ROOT.DisableImplicitMT()
rdf = r.RDataFrame(10).Define('e', 'rdfentry_')
s = rdf.Snapshot('test', 'test.root')
f = r.TFile.Open('test.root')
t = f.Get('test')
t.Print()
# ******************************************************************************
# *Tree :test : test *
# *Entries : 10 : Total = 962 bytes File Size = 457 *
# * : : Tree compression factor = 1.35 *
# ******************************************************************************
# *Br 0 :e : e/l *
# *Entries : 10 : Total Size= 625 bytes File Size = 110 *
# *Baskets : 1 : Basket Size= 32000 bytes Compression= 1.35 *
# *............................................................................*
ROOT Version: 6.22/00
Platform: linux
Compiler: conda-forge