Skip to content

Commit

Permalink
[ntuple] don't set fMaxKeySize in GetNTuple()
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Oct 14, 2024
1 parent db3dc0b commit 0daab25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
4 changes: 0 additions & 4 deletions tree/ntuple/v7/src/RMiniFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,6 @@ ROOT::Experimental::Internal::RMiniFileReader::GetNTupleProper(std::string_view
return R__FAIL("RNTuple anchor checksum mismatch");
}

fMaxKeySize = ntuple->fMaxKeySize;

return CreateAnchor(ntuple->fVersionEpoch, ntuple->fVersionMajor, ntuple->fVersionMinor, ntuple->fVersionPatch,
ntuple->fSeekHeader, ntuple->fNBytesHeader, ntuple->fLenHeader, ntuple->fSeekFooter,
ntuple->fNBytesFooter, ntuple->fLenFooter, ntuple->fMaxKeySize);
Expand Down Expand Up @@ -816,8 +814,6 @@ ROOT::Experimental::Internal::RMiniFileReader::GetNTupleBare(std::string_view nt
if (checksum != static_cast<uint64_t>(onDiskChecksum))
return R__FAIL("RNTuple bare file: anchor checksum mismatch");

fMaxKeySize = ntuple.fMaxKeySize;

return CreateAnchor(ntuple.fVersionEpoch, ntuple.fVersionMajor, ntuple.fVersionMinor, ntuple.fVersionPatch,
ntuple.fSeekHeader, ntuple.fNBytesHeader, ntuple.fLenHeader, ntuple.fSeekFooter,
ntuple.fNBytesFooter, ntuple.fLenFooter, ntuple.fMaxKeySize);
Expand Down
3 changes: 1 addition & 2 deletions tree/ntuple/v7/src/RPageStorageFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,8 @@ void ROOT::Experimental::Internal::RPageSourceFile::LoadStructureImpl()
// Otherwise, the page source was created by OpenFromAnchor()
if (!fAnchor) {
fAnchor = fReader.GetNTuple(fNTupleName).Unwrap();
} else {
fReader.SetMaxKeySize(fAnchor->GetMaxKeySize());
}
fReader.SetMaxKeySize(fAnchor->GetMaxKeySize());

// TOOD(jblomer): can the epoch check be factored out across anchors?
if (fAnchor->GetVersionEpoch() != RNTuple::kVersionEpoch) {
Expand Down
16 changes: 8 additions & 8 deletions tree/ntuple/v7/test/ntuple_minifile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ TEST(MiniFile, MultiKeyBlob)

auto rawFile = RRawFile::Create(fileGuard.GetPath());
auto reader = RMiniFileReader{rawFile.get()};
// Force reader to read the max key size
(void)reader.GetNTuple("ntpl");
auto ntuple = reader.GetNTuple("ntpl").Unwrap();
reader.SetMaxKeySize(ntuple.GetMaxKeySize());
reader.ReadBuffer(data.get(), dataSize, blobOffset);

EXPECT_EQ(data[0], 0x99);
Expand Down Expand Up @@ -419,8 +419,8 @@ TEST(MiniFile, MultiKeyBlob_ExactlyMax)

auto rawFile = RRawFile::Create(fileGuard.GetPath());
auto reader = RMiniFileReader{rawFile.get()};
// Force reader to read the max key size
(void)reader.GetNTuple("ntpl");
auto ntuple = reader.GetNTuple("ntpl").Unwrap();
reader.SetMaxKeySize(ntuple.GetMaxKeySize());
rawFile->ReadAt(data.get(), dataSize, blobOffset);

// If we didn't split the key, we expect to find all zeroes at the end of `data`.
Expand Down Expand Up @@ -458,8 +458,8 @@ TEST(MiniFile, MultiKeyBlob_ExactlyTwo)

auto rawFile = RRawFile::Create(fileGuard.GetPath());
auto reader = RMiniFileReader{rawFile.get()};
// Force reader to read the max key size
(void)reader.GetNTuple("ntpl");
auto ntuple = reader.GetNTuple("ntpl").Unwrap();
reader.SetMaxKeySize(ntuple.GetMaxKeySize());

rawFile->ReadAt(data.get(), dataSize, blobOffset);
// If the blob was split into exactly two keys, there should be only one pointer to the next chunk.
Expand Down Expand Up @@ -502,8 +502,8 @@ TEST(MiniFile, MultiKeyBlob_SmallKey)

auto rawFile = RRawFile::Create(fileGuard.GetPath());
auto reader = RMiniFileReader{rawFile.get()};
// Force reader to read the max key size
(void)reader.GetNTuple("ntpl");
auto ntuple = reader.GetNTuple("ntpl").Unwrap();
reader.SetMaxKeySize(ntuple.GetMaxKeySize());
reader.ReadBuffer(data.get(), dataSize, blobOffset);

EXPECT_EQ(data[0], 0x99);
Expand Down

0 comments on commit 0daab25

Please sign in to comment.