Skip to content

Commit

Permalink
[ntuple] general rename 'BytesOnStorage' --> 'NBytesOnDisk'
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Jan 7, 2025
1 parent 3ae01fe commit 1b4422e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion tree/ntuple/v7/inc/ROOT/RNTupleDescriptor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public:
{
return fColumnRanges.find(physicalId) != fColumnRanges.end();
}
std::uint64_t GetBytesOnStorage() const;
std::uint64_t GetNBytesOnDisk() const;
};

class RClusterDescriptor::RColumnRangeIterable {
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/v7/src/RNTupleDescriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ bool ROOT::Experimental::RClusterDescriptor::operator==(const RClusterDescriptor
fNEntries == other.fNEntries && fColumnRanges == other.fColumnRanges && fPageRanges == other.fPageRanges;
}

std::uint64_t ROOT::Experimental::RClusterDescriptor::GetBytesOnStorage() const
std::uint64_t ROOT::Experimental::RClusterDescriptor::GetNBytesOnDisk() const
{
std::uint64_t nbytes = 0;
for (const auto &pr : fPageRanges) {
Expand Down
38 changes: 19 additions & 19 deletions tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ struct ClusterInfo {
std::uint64_t fFirstEntry = 0;
std::uint32_t fNPages = 0;
std::uint32_t fNEntries = 0;
std::uint32_t fBytesOnStorage = 0;
std::uint32_t fBytesInMemory = 0;
std::uint32_t fNBytesOnDisk = 0;
std::uint32_t fNBytesInMemory = 0;

bool operator==(const ClusterInfo &other) const { return fFirstEntry == other.fFirstEntry; }

Expand All @@ -43,7 +43,7 @@ struct ColumnInfo {
ROOT::Experimental::DescriptorId_t fFieldId = 0;
std::uint64_t fNElements = 0;
std::uint64_t fNPages = 0;
std::uint64_t fBytesOnStorage = 0;
std::uint64_t fNBytesOnDisk = 0;
std::uint32_t fElementSize = 0;
std::uint32_t fColumnIndex = 0;
std::uint16_t fRepresentationIndex = 0;
Expand Down Expand Up @@ -94,8 +94,8 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
clusters.emplace_back(info);
}

std::uint64_t bytesOnStorage = 0;
std::uint64_t bytesInMemory = 0;
std::uint64_t nBytesOnDisk = 0;
std::uint64_t nBytesInMemory = 0;
std::uint64_t nPages = 0;
int compression = -1;
for (const auto &column : fColumnDescriptors) {
Expand Down Expand Up @@ -129,12 +129,12 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
const auto &pageRange = cluster.second.GetPageRange(column.second.GetPhysicalId());
auto idx = cluster2Idx[cluster.first];
for (const auto &page : pageRange.fPageInfos) {
bytesOnStorage += page.fLocator.GetNBytesOnDisk();
bytesInMemory += page.fNElements * elementSize;
clusters[idx].fBytesOnStorage += page.fLocator.GetNBytesOnDisk();
clusters[idx].fBytesInMemory += page.fNElements * elementSize;
nBytesOnDisk += page.fLocator.GetNBytesOnDisk();
nBytesInMemory += page.fNElements * elementSize;
clusters[idx].fNBytesOnDisk += page.fLocator.GetNBytesOnDisk();
clusters[idx].fNBytesInMemory += page.fNElements * elementSize;
++clusters[idx].fNPages;
info.fBytesOnStorage += page.fLocator.GetNBytesOnDisk();
info.fNBytesOnDisk += page.fLocator.GetNBytesOnDisk();
++info.fNPages;
++nPages;
}
Expand All @@ -153,16 +153,16 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
output << " # Alias Columns: " << GetNLogicalColumns() - GetNPhysicalColumns() << "\n";
output << " # Pages: " << nPages << "\n";
output << " # Clusters: " << GetNClusters() << "\n";
output << " Size on storage: " << bytesOnStorage << " B"
output << " Size on storage: " << nBytesOnDisk << " B"
<< "\n";
output << " Compression rate: " << std::fixed << std::setprecision(2) << float(nBytesInMemory) / float(nBytesOnDisk)
<< "\n";
output << " Compression rate: " << std::fixed << std::setprecision(2)
<< float(bytesInMemory) / float(bytesOnStorage) << "\n";
output << " Header size: " << headerSize << " B"
<< "\n";
output << " Footer size: " << footerSize << " B"
<< "\n";
output << " Meta-data / data: " << std::fixed << std::setprecision(3)
<< float(headerSize + footerSize) / float(bytesOnStorage) << "\n";
<< float(headerSize + footerSize) / float(nBytesOnDisk) << "\n";
output << "------------------------------------------------------------\n";
output << "CLUSTER DETAILS\n";
output << "------------------------------------------------------------" << std::endl;
Expand All @@ -174,10 +174,10 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
output << " "
<< " # Pages: " << clusters[i].fNPages << "\n";
output << " "
<< " Size on storage: " << clusters[i].fBytesOnStorage << " B\n";
<< " Size on storage: " << clusters[i].fNBytesOnDisk << " B\n";
output << " "
<< " Compression: " << std::fixed << std::setprecision(2)
<< float(clusters[i].fBytesInMemory) / float(float(clusters[i].fBytesOnStorage)) << std::endl;
<< float(clusters[i].fNBytesInMemory) / float(float(clusters[i].fNBytesOnDisk)) << std::endl;
}

output << "------------------------------------------------------------\n";
Expand All @@ -189,7 +189,7 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
}
std::sort(columns.begin(), columns.end());
for (const auto &col : columns) {
auto avgPageSize = (col.fNPages == 0) ? 0 : (col.fBytesOnStorage / col.fNPages);
auto avgPageSize = (col.fNPages == 0) ? 0 : (col.fNBytesOnDisk / col.fNPages);
auto avgElementsPerPage = (col.fNPages == 0) ? 0 : (col.fNElements / col.fNPages);
std::string nameAndType = std::string(" ") + col.fFieldName + " [#" + std::to_string(col.fColumnIndex);
if (col.fRepresentationIndex > 0)
Expand All @@ -205,9 +205,9 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
output << " # Pages: " << col.fNPages << "\n";
output << " Avg elements / page: " << avgElementsPerPage << "\n";
output << " Avg page size: " << avgPageSize << " B\n";
output << " Size on storage: " << col.fBytesOnStorage << " B\n";
output << " Size on storage: " << col.fNBytesOnDisk << " B\n";
output << " Compression: " << std::fixed << std::setprecision(2)
<< float(col.fElementSize * col.fNElements) / float(col.fBytesOnStorage) << "\n";
<< float(col.fElementSize * col.fNElements) / float(col.fNBytesOnDisk) << "\n";
output << "............................................................" << std::endl;
}
}
6 changes: 3 additions & 3 deletions tree/ntuple/v7/src/RNTupleMerger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,12 @@ static void GenerateExtraDstColumns(size_t nClusterEntries, std::span<RColumnMer

const auto colElement = RColumnElementBase::Generate(columnDesc.GetType());
const auto nElements = nClusterEntries * nRepetitions;
const auto bytesOnStorage = colElement->GetPackedSize(nElements);
const auto nBytesOnDisk = colElement->GetPackedSize(nElements);
constexpr auto kPageSizeLimit = 256 * 1024;
// TODO(gparolini): consider coalescing the last page if its size is less than some threshold
const size_t nPages = bytesOnStorage / kPageSizeLimit + !!(bytesOnStorage % kPageSizeLimit);
const size_t nPages = nBytesOnDisk / kPageSizeLimit + !!(nBytesOnDisk % kPageSizeLimit);
for (size_t i = 0; i < nPages; ++i) {
const auto pageSize = (i < nPages - 1) ? kPageSizeLimit : bytesOnStorage - kPageSizeLimit * (nPages - 1);
const auto pageSize = (i < nPages - 1) ? kPageSizeLimit : nBytesOnDisk - kPageSizeLimit * (nPages - 1);
const auto checksumSize = RPageStorage::kNBytesPageChecksum;
const auto bufSize = pageSize + checksumSize;
auto &buffer = sealedPageData.fBuffers.emplace_back(new unsigned char[bufSize]);
Expand Down
12 changes: 6 additions & 6 deletions tree/ntuple/v7/src/RNTupleSerialize.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -419,18 +419,18 @@ void DeserializeLocatorPayloadLarge(const unsigned char *buffer, ROOT::Experimen
std::uint32_t SerializeLocatorPayloadObject64(const ROOT::Experimental::RNTupleLocator &locator, unsigned char *buffer)
{
const auto &data = locator.GetPosition<ROOT::Experimental::RNTupleLocatorObject64>();
const uint32_t sizeofBytesOnStorage = (locator.GetNBytesOnDisk() > std::numeric_limits<std::uint32_t>::max())
? sizeof(std::uint64_t)
: sizeof(std::uint32_t);
const uint32_t sizeofNBytesOnDisk = (locator.GetNBytesOnDisk() > std::numeric_limits<std::uint32_t>::max())
? sizeof(std::uint64_t)
: sizeof(std::uint32_t);
if (buffer) {
if (sizeofBytesOnStorage == sizeof(std::uint32_t)) {
if (sizeofNBytesOnDisk == sizeof(std::uint32_t)) {
RNTupleSerializer::SerializeUInt32(locator.GetNBytesOnDisk(), buffer);
} else {
RNTupleSerializer::SerializeUInt64(locator.GetNBytesOnDisk(), buffer);
}
RNTupleSerializer::SerializeUInt64(data.GetLocation(), buffer + sizeofBytesOnStorage);
RNTupleSerializer::SerializeUInt64(data.GetLocation(), buffer + sizeofNBytesOnDisk);
}
return sizeofBytesOnStorage + sizeof(std::uint64_t);
return sizeofNBytesOnDisk + sizeof(std::uint64_t);
}

void DeserializeLocatorPayloadObject64(const unsigned char *buffer, std::uint32_t sizeofLocatorPayload,
Expand Down
4 changes: 2 additions & 2 deletions tree/ntuple/v7/test/ntuple_descriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ TEST(RColumnDescriptorIterable, IterateOverColumns)
EXPECT_EQ(desc.GetNLogicalColumns(), counter);
}

TEST(RClusterDescriptor, GetBytesOnStorage)
TEST(RClusterDescriptor, GetNBytesOnDisk)
{
auto model = RNTupleModel::Create();
auto fldJets = model->MakeField<std::vector<float>>("jets");
Expand All @@ -526,7 +526,7 @@ TEST(RClusterDescriptor, GetBytesOnStorage)

auto clusterID = desc.FindClusterId(0, 0);
ASSERT_NE(ROOT::Experimental::kInvalidDescriptorId, clusterID);
EXPECT_EQ(8 + 8 + 8 + 3, desc.GetClusterDescriptor(clusterID).GetBytesOnStorage());
EXPECT_EQ(8 + 8 + 8 + 3, desc.GetClusterDescriptor(clusterID).GetNBytesOnDisk());
}

TEST(RNTupleDescriptor, Clone)
Expand Down

0 comments on commit 1b4422e

Please sign in to comment.