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

[ntuple] return const char* instead of std::string from RColumnElemen… #16695

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tree/ntuple/v7/inc/ROOT/RColumnElementBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public:
/// If CppT == void, use the default C++ type for the given column type
template <typename CppT = void>
static std::unique_ptr<RColumnElementBase> Generate(EColumnType type);
static std::string GetTypeName(EColumnType type);
static const char *GetTypeName(EColumnType type);
/// Most types have a fixed on-disk bit width. Some low-precision column types
/// have a range of possible bit widths. Return the minimum and maximum allowed
/// bit size per type.
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/v7/src/RColumnElement.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ROOT::Experimental::Internal::RColumnElementBase::GetValidBitRange(EColumnType t
return std::make_pair(0, 0);
}

std::string ROOT::Experimental::Internal::RColumnElementBase::GetTypeName(EColumnType type)
const char *ROOT::Experimental::Internal::RColumnElementBase::GetTypeName(EColumnType type)
{
switch (type) {
case EColumnType::kIndex64: return "Index64";
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/v7/src/RNTupleDescriptorFmt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void ROOT::Experimental::RNTupleDescriptor::PrintInfo(std::ostream &output) cons
std::string nameAndType = std::string(" ") + col.fFieldName + " [#" + std::to_string(col.fColumnIndex);
if (col.fRepresentationIndex > 0)
nameAndType += " / R." + std::to_string(col.fRepresentationIndex);
nameAndType += "] -- " + Internal::RColumnElementBase::GetTypeName(col.fType);
nameAndType += "] -- " + std::string{Internal::RColumnElementBase::GetTypeName(col.fType)};
std::string id = std::string("{id:") + std::to_string(col.fLogicalColumnId) + "}";
if (col.fLogicalColumnId != col.fPhysicalColumnId)
id += " --alias--> " + std::to_string(col.fPhysicalColumnId);
Expand Down
13 changes: 7 additions & 6 deletions tree/ntupleutil/v7/src/RNTupleInspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ ROOT::Experimental::RNTupleInspector::GetColumnTypeInfoAsHist(ROOT::Experimental
default: throw RException(R__FAIL("Unknown histogram type"));
}

hist->AddBinContent(
hist->GetXaxis()->FindBin(Internal::RColumnElementBase::GetTypeName(colInfo.GetType()).c_str()), data);
hist->AddBinContent(hist->GetXaxis()->FindBin(Internal::RColumnElementBase::GetTypeName(colInfo.GetType())),
data);
}

return hist;
Expand All @@ -322,9 +322,10 @@ ROOT::Experimental::RNTupleInspector::GetPageSizeDistribution(ROOT::Experimental
std::string histName, std::string histTitle, size_t nBins)
{
if (histName.empty())
histName = "pageSizeHistCol" + Internal::RColumnElementBase::GetTypeName(colType);
histName = "pageSizeHistCol" + std::string{Internal::RColumnElementBase::GetTypeName(colType)};
if (histTitle.empty())
histTitle = "Page size distribution for columns with type " + Internal::RColumnElementBase::GetTypeName(colType);
histTitle = "Page size distribution for columns with type " +
std::string{Internal::RColumnElementBase::GetTypeName(colType)};

auto perTypeHist = GetPageSizeDistribution({colType}, histName, histTitle, nBins);

Expand Down Expand Up @@ -414,8 +415,8 @@ std::unique_ptr<THStack> ROOT::Experimental::RNTupleInspector::GetPageSizeDistri

for (const auto &[colType, pageSizesForColType] : pageSizes) {
auto hist = std::make_unique<TH1D>(
TString::Format("%s%s", histName.c_str(), Internal::RColumnElementBase::GetTypeName(colType).c_str()),
Internal::RColumnElementBase::GetTypeName(colType).c_str(), nBins, histMin,
TString::Format("%s%s", histName.c_str(), Internal::RColumnElementBase::GetTypeName(colType)),
Internal::RColumnElementBase::GetTypeName(colType), nBins, histMin,
histMax + ((histMax - histMin) / static_cast<double>(nBins)));

for (const auto pageSize : pageSizesForColType) {
Expand Down
Loading