Skip to content

[ntuple] Add RNTupleLocatorMulti class for kTypeMulti locator#22577

Open
JasMehta08 wants to merge 1 commit into
root-project:masterfrom
JasMehta08:ntuple-locator-multi-class
Open

[ntuple] Add RNTupleLocatorMulti class for kTypeMulti locator#22577
JasMehta08 wants to merge 1 commit into
root-project:masterfrom
JasMehta08:ntuple-locator-multi-class

Conversation

@JasMehta08

@JasMehta08 JasMehta08 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This Pull request:

(Is a part of the GSoC 2026 project S3 Backend for RNTuple.)

Changes or fixes:

Follow-up to #22434. Introduces a dedicated RNTupleLocatorMulti class for the kTypeMulti locator, replacing the previous reuse of RNTupleLocatorObject64.

The class stores the object identifier and byte offset as two uint32_t fields and exposes them via GetObjectId() / GetOffset(). The 32/32 packing into RNTupleLocator::fPosition is the only place the in-memory layout shows up, and it lives inside SetPosition(RNTupleLocatorMulti) and RNTupleLocatorHelper<RNTupleLocatorMulti>::Get.

RNTupleLocator::SetPosition and GetPosition<> are split accordingly so RNTupleLocatorObject64 is now reserved for kTypeObject64 only, and the new RNTupleLocatorMulti overload/specialization handle kTypeMulti.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

This PR is a follow-up #22434

@JasMehta08 JasMehta08 requested a review from jblomer as a code owner June 11, 2026 09:18
@jblomer jblomer self-assigned this Jun 11, 2026
@jblomer jblomer assigned JasMehta08 and unassigned jblomer Jun 11, 2026

@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.

Nice! Some simplification is possible, I think, by not storing reserved bits altogether.

Comment thread tree/ntuple/inc/ROOT/RNTupleTypes.hxx Outdated
Comment thread tree/ntuple/src/RNTupleSerialize.cxx Outdated
@github-actions

Copy link
Copy Markdown

Test Results

    19 files      19 suites   3d 2h 44m 25s ⏱️
 3 863 tests  3 810 ✅ 0 💤 53 ❌
66 233 runs  66 168 ✅ 1 💤 64 ❌

For more details on these failures, see this check.

Results for commit 0d8ca56.

@JasMehta08 JasMehta08 force-pushed the ntuple-locator-multi-class branch from 0d8ca56 to a78d828 Compare June 18, 2026 09:17
@JasMehta08 JasMehta08 requested a review from silverweed as a code owner June 18, 2026 09:17

@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.

LGTM!

EXPECT_EQ(1U, m.GetObjectId());
EXPECT_EQ(2U, m.GetOffset());

// GetPosition<Object64>() no longer accepts kTypeMulti after the split.

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.

Suggested change
// GetPosition<Object64>() no longer accepts kTypeMulti after the split.

@jblomer

jblomer commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

It would be good to also update the PR details.


/// RNTupleLocator payload for the kTypeMulti locator (type 0x03). Used by storage
/// backends that pack multiple pages into shared objects (e.g., S3 Mode A). The two
/// 32-bit fields are written to disk as separate integers, so the wire format is

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.

The "wire format"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I meant the on disk format I will update the comment so its more clear


/// Note that for GetPosition() / SetPosition(), the locator type must correspond (kTypeFile, kTypeObject64).
/// Note that for GetPosition() / SetPosition(), the locator type must correspond
/// (kTypeFile, kTypeObject64, kTypeMulti).

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.

For convenience we probably want to phrase it like

Suggested change
/// (kTypeFile, kTypeObject64, kTypeMulti).
/// (kTypeFile, kTypeObject64, ...).

and not update it with every locator type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will update this comment as well

RNTupleSerializer::SerializeUInt64(locator.GetNBytesOnStorage(), buffer);
}
RNTupleSerializer::SerializeUInt32(data.GetObjectId(), buffer + sizeofNBytesOnStorage);
RNTupleSerializer::SerializeUInt32(data.GetOffset(),

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.

I would use the pattern found in other serialize functions of:

   auto base = reinterpret_cast<unsigned char *>(buffer);
   auto pos = base;
   void **where = (buffer == nullptr) ? &buffer : reinterpret_cast<void **>(&pos);

   pos += RNTupleSerializer::SerializeUInt32(..., *where);
   pos += ...

instead of manually calculating the write position

}
std::uint32_t objectId;
std::uint32_t offset;
RNTupleSerializer::DeserializeUInt32(buffer + sizeofNBytesOnStorage, objectId);

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.

Like for the serialize: keep track of the buffer position with a variable and increment it with the Deserialize* return values instead of calculating the offset every time

case 0x03:
locator.SetType(RNTupleLocator::kTypeMulti);
DeserializeLocatorPayloadObject64(bytes, payloadSize, locator);
DeserializeLocatorPayloadMulti(bytes, payloadSize, locator);

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.

Both for this and the Object64 case: we need to check the return value and forward RResult in case of failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants