Skip to content

Add test for attributes#77

Open
undefined-panda wants to merge 1 commit into
root-project:mainfrom
undefined-panda:attributes-test
Open

Add test for attributes#77
undefined-panda wants to merge 1 commit into
root-project:mainfrom
undefined-panda:attributes-test

Conversation

@undefined-panda

Copy link
Copy Markdown
Collaborator

Skip write.C for versions that don't support attributes (everything before 6.40) and read.C if binary for attributes doesn't exist.

@jblomer jblomer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In principle looks good to me. Since we are at it, I think we should make the test slightly more interesting and write three entries, with one attribute attached to the first entry and another attribute attached to the second and third entry.

And then, for a corner case, also test an attribute for an empty RNTuple.

Comment thread structure/attributes/write.C Outdated
Comment thread structure/attributes/read.C Outdated
Comment thread structure/attributes/read.C Outdated
Comment thread structure/attributes/read.C Outdated
Comment thread structure/attributes/read.C Outdated
Comment thread structure/attributes/read.C Outdated
os << "}\n";
return;
} catch (const runtime_error &e) {
cout << "Skipped structure/attributes/read.C - " << e.what() << endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we handle the case of missing structure.attributes.root more explicitly? That is the only error that I think is permissable, all others should make the test fail.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAICT the code hasn't changed, a missing structure.attributes.root is not handled explicitly...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Explicit error handling for missing file was added.

Comment thread structure/attributes/README.md Outdated
Comment thread structure/attributes/read.C Outdated
@undefined-panda undefined-panda force-pushed the attributes-test branch 3 times, most recently from 0fa2cd4 to 047cee5 Compare July 8, 2026 13:01
Comment thread structure/attributes/read.C Outdated
} else {
os << " }\n";
}
std::cout << " attr = " << *attr << " (valid for range [" << *range.GetFirst() << ", " << *range.GetLast() << "])\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this still debugging output?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

Comment thread structure/attributes/read.C Outdated
Comment on lines +12 to +13
// same logic as is read_structure.hxx, with additional special part for
// attributes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, the latest code doesn't print the main entry anymore. Probably we don't need this, but then we should update / remove this comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment updated

Comment thread structure/attributes/read.C Outdated
Comment on lines +32 to +33
auto Int32 =
reader->GetModel().GetDefaultEntry().GetPtr<std::int32_t>("Int32");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

unused

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

// list of values for attr with its range
os << " {\n";
os << " \"Attr\": " << "[\n";
first = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

already set above

Comment thread structure/attributes/README.md Outdated

## Fields

* `Int{32}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* `Int{32}`
* `Int32`

Comment thread structure/attributes/read.C Outdated
os << "}\n";
return;
} catch (const runtime_error &e) {
cout << "Skipped structure/attributes/read.C - " << e.what() << endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAICT the code hasn't changed, a missing structure.attributes.root is not handled explicitly...

Comment thread structure/attributes/README.md Outdated
Comment on lines +12 to +14
1. Attribute set name
2. Attribute set description
3. List of attribute entries with value and regular field range

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These are not (RNTuple) entries. What you want to describe here is that there is one attribute entry spanning one main entry, and the second attribute entry spanning two main entries.

Comment thread structure/attributes/README.md Outdated
## Fields

* `Int{32}`
* `Attr`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the code it's "attr" (lower-case). Maybe you can also make it explicit that Int32 is the field in the main RNTuple, and attr is the field in the attribute model

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.

3 participants