Skip to content
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

feat: add TLeafC - string - writing support #940

Merged
merged 14 commits into from
Sep 25, 2023
Merged

Conversation

ioanaif
Copy link
Collaborator

@ioanaif ioanaif commented Aug 16, 2023

No description provided.

@jpivarski
Copy link
Member

jpivarski commented Aug 17, 2023

                                          4 bytes          4 bytes
┌─────────┬────────────────────────────────┬───┬────────────┬───┐
│ TKey    │ content                        │ X │ offsets    │ x │
└─────────┴────────────────────────────────┴───┴────────────┴───┘
          │←        fLast - fKeylen       →│                    │
          │                                                     │
          │←                       fObjlen                     →│

These offsets are measured in bytes, starting from the beginning of the TKey.

They do not include the last, so we have to get the last offset from fLast (in the TKey header).

As for what the two "4 bytes" X values are, see the jagged array writer.

Example to follow:

>>> import uproot, skhep_testdata
>>> uproot.open(skhep_testdata.data_path("uproot-simple.root"))["tree"]["three"].array()
<Array ['uno', 'dos', 'tres', 'quatro'] type='4 * string'>

Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just needs one more test to pass. See below!

Comment on lines +41 to +48
"unu",
"doi",
"trei",
"patru",
"cinci",
"sase",
"sapte",
"opt",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

Copy link
Member

@jpivarski jpivarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! It's great to see this working!

I added some tests of extreme situations, to make sure that fLen is increasing as it should be before and after write_anew, that length-zero string arrays can be written, and that ROOT is still okay with all of these cases. (I had to guess that fLen should be 0 when there are no strings. I could be wrong and maybe it ought to be 1. ROOT didn't complain, though.)

If you have any counter-edits, go ahead and apply them, otherwise, feel free to squash-and-merge.

@ioanaif ioanaif merged commit 1d85f27 into main Sep 25, 2023
15 checks passed
@ioanaif ioanaif deleted the ioanaif/add-TLeafC-support branch September 25, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants