-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[tree] allow skipping longdoubles when building tree index #19561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a4932f
[tree] allow skipping longdoubles when building tree index
ferdymercury 39fea9c
[tree] avoid warning and run test
ferdymercury 96c6468
[tree] remove const par and add helper function
ferdymercury 8c04b11
[nfc] add docu
ferdymercury 486bc62
[nfc] document higher limit
ferdymercury a9caec1
[tree] fix repeated word and clarify
ferdymercury 17f8478
Update roottest/root/tree/index/runindexl64.C
ferdymercury aff1543
clangf
ferdymercury File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Processing runindexl64.C... | ||
Tree BuildIndex returns 9 | ||
Entries in chain: 9 | ||
BuildIndex returns 9 | ||
Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1: | ||
-1 | ||
Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4: | ||
4 | ||
Entries in chain: 9 | ||
BuildIndex returns 1 | ||
Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1: | ||
-1 | ||
Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4: | ||
4 | ||
(int) 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "TFile.h" | ||
#include "TChain.h" | ||
#include "Riostream.h" | ||
|
||
bool test(TTree *); | ||
|
||
const char *fname = "indexl64.root"; | ||
https : // github.com/root-project/root/pull/19561 | ||
const Long64_t bigval = | ||
0x0FFFFFFFFFFFFFFF; // here we skip long double, so we can go higher than with runindex64.C | ||
|
||
int runindexl64() | ||
{ | ||
|
||
/////////////////////////////////////////////////// | ||
// Make a tree and a file and write them to disk // | ||
/////////////////////////////////////////////////// | ||
|
||
TFile file(fname, "recreate"); | ||
TTree *tree = new TTree("testTree", "my test tree"); | ||
ULong64_t run, event; | ||
// ULong64 is "l" | ||
tree->Branch("run", &run, "run/l"); | ||
tree->Branch("event", &event, "event/l"); | ||
|
||
// clang-format off | ||
ULong64_t runs[] = { 8,5,5,5, 5, 0, 4, 6, bigval}; | ||
ULong64_t events[] = { 0,1,3,2, bigval, 5, bigval, 3, bigval}; | ||
ferdymercury marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// clang-format on | ||
for (size_t i = 0; i < sizeof(events) / sizeof(*events); i++) { | ||
run = runs[i]; | ||
event = events[i]; | ||
tree->Fill(); | ||
} | ||
tree->Write(); | ||
|
||
bool pass = true; | ||
cout << "Tree BuildIndex returns " << tree->BuildIndex("run", "event", true, true) << endl; | ||
for (size_t i = 0; i < sizeof(events) / sizeof(*events); i++) { | ||
run = runs[i]; | ||
event = events[i]; | ||
pass &= (tree->GetEntryNumberWithIndex(run, event) == i); | ||
} | ||
if (!pass) { | ||
tree->Scan("run:event", "", "colsize=30"); | ||
for (size_t i = 0; i < sizeof(events) / sizeof(*events); i++) { | ||
run = runs[i]; | ||
event = events[i]; | ||
cout << i << ": Run " << run << ", Event " << event | ||
<< " found at entry number: " << tree->GetEntryNumberWithIndex(run, event) << endl; | ||
} | ||
} | ||
|
||
test(tree); | ||
file.Close(); | ||
|
||
//////////////////////////////////////////////////// | ||
// Try loading back in as a TChain // | ||
//////////////////////////////////////////////////// | ||
TChain *chain = new TChain("testTree"); | ||
chain->Add(fname); | ||
bool result = !test(chain); | ||
|
||
delete chain; | ||
|
||
return result; | ||
} | ||
|
||
bool test(TTree *chain) | ||
{ | ||
cout << "Entries in chain: " << chain->GetEntries() << endl; | ||
cout << "BuildIndex returns " << chain->BuildIndex("run", "event", true, true) << endl; | ||
cout << "Try to find the position of run=0, event=500 in the chain, as it does not exist, this should return a -1:" | ||
<< endl; | ||
cout << chain->GetEntryWithIndex(500) << endl; | ||
cout << "Try to find the position of run=5, event=bigval in the chain, which was inserted in position 4:" << endl; | ||
cout << chain->GetEntryNumberWithIndex(5, bigval) << endl; | ||
return (chain->GetEntryNumberWithIndex(500) == -1) && (chain->GetEntryNumberWithIndex(5, bigval) == 4); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.