Skip to content

Commit 32f264c

Browse files
albfsgsilverweed
authored andcommitted
[ntuple] Merge Speedscopes strings
Now everything is printed in the `name` field of the JSON schema. This is because fSecondaryString was mapped into the `file` field of the schema, which forced it to end with ":".
1 parent ebc6315 commit 32f264c

2 files changed

Lines changed: 15 additions & 19 deletions

File tree

tree/ntupleutil/src/RNTupleInspector.cxx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ void ROOT::Experimental::RNTupleInspector::PrintFieldTreeAsDot(const ROOT::RFiel
568568
namespace {
569569

570570
struct SpeedscopeFrame {
571-
std::string fPrimaryString;
572-
std::string fSecondaryString;
571+
std::string fString;
573572
std::uint64_t fOpeningPosition = 0;
574573
std::uint64_t fClosingPosition = 0;
575574
};
@@ -582,10 +581,7 @@ static void PrintSpeedscopeFrames(const std::vector<SpeedscopeFrame> &frames, st
582581
output << " \"frames\":[\n";
583582

584583
for (std::size_t i = 0; i < frames.size(); ++i) {
585-
output << " { \"name\":\"" << frames[i].fPrimaryString
586-
<< "\", \"file\":\"Type: " << frames[i].fSecondaryString
587-
<< ", Size: " << frames[i].fClosingPosition - frames[i].fOpeningPosition << "B\" }"
588-
<< (i + 1 < frames.size() ? ",\n" : "\n");
584+
output << " { \"name\":\"" << frames[i].fString << "\" }" << (i + 1 < frames.size() ? ",\n" : "\n");
589585
}
590586

591587
output << " ]\n";
@@ -650,12 +646,12 @@ void ROOT::Experimental::RNTupleInspector::PrintSchemaProfile(ESchemaProfileForm
650646
// Returns size of the visited field
651647
auto visitFieldsRecursive = [&](auto &self, const ROOT::RFieldDescriptor &fieldDescriptor) -> std::size_t {
652648
SpeedscopeFrame fieldSpeedscopeFrame;
653-
fieldSpeedscopeFrame.fPrimaryString = tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId());
654-
fieldSpeedscopeFrame.fSecondaryString = fieldDescriptor.GetTypeName();
649+
fieldSpeedscopeFrame.fString =
650+
tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) + " (" + fieldDescriptor.GetTypeName() + ")";
655651
fieldSpeedscopeFrame.fOpeningPosition = positionCursor;
656652
frames.push_back(fieldSpeedscopeFrame);
657653

658-
const std::size_t fieldSpeedscopeFrameIndex = frames.size() - 1;
654+
std::size_t fieldSpeedscopeFrameIndex = frames.size() - 1;
659655

660656
std::size_t subTreeSize = 0;
661657
const auto &childIds = fieldDescriptor.GetLinkIds();
@@ -670,10 +666,10 @@ void ROOT::Experimental::RNTupleInspector::PrintSchemaProfile(ESchemaProfileForm
670666
std::size_t columnSize = columnInfo.GetCompressedSize();
671667

672668
SpeedscopeFrame columnSpeedscopeFrame;
673-
columnSpeedscopeFrame.fPrimaryString = "[col#" + std::to_string(columnDescriptor.GetPhysicalId()) + "]" +
674-
tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId());
675-
columnSpeedscopeFrame.fSecondaryString =
676-
ROOT::Internal::RColumnElementBase::GetColumnTypeName(columnDescriptor.GetType());
669+
columnSpeedscopeFrame.fString =
670+
"[col#" + std::to_string(columnDescriptor.GetPhysicalId()) + "] " +
671+
tupleDescriptor.GetQualifiedFieldName(fieldDescriptor.GetId()) + " (" +
672+
ROOT::Internal::RColumnElementBase::GetColumnTypeName(columnDescriptor.GetType()) + ")";
677673
columnSpeedscopeFrame.fOpeningPosition = positionCursor;
678674
positionCursor += columnSize;
679675
columnSpeedscopeFrame.fClosingPosition = positionCursor;

tree/ntupleutil/test/ntuple_inspector.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -882,14 +882,14 @@ TEST(RNTupleInspector, SchemaProfile)
882882
std::ostringstream schemaProfileStream;
883883
inspector->PrintSchemaProfile(ROOT::Experimental::ESchemaProfileFormat::kSpeedscopeJSON, schemaProfileStream);
884884
const std::string schemaProfile = schemaProfileStream.str();
885-
const std::string expected = R"({
885+
const std::string expected = R"foo({
886886
"$schema":"https://www.speedscope.app/file-format-schema.json",
887887
"shared":{
888888
"frames":[
889-
{ "name":"float1", "file":"Type: float, Size: 40B" },
890-
{ "name":"[col#0]float1", "file":"Type: SplitReal32, Size: 40B" },
891-
{ "name":"int", "file":"Type: std::int32_t, Size: 40B" },
892-
{ "name":"[col#1]int", "file":"Type: SplitInt32, Size: 40B" }
889+
{ "name":"float1 (float)" },
890+
{ "name":"[col#0] float1 (SplitReal32)" },
891+
{ "name":"int (std::int32_t)" },
892+
{ "name":"[col#1] int (SplitInt32)" }
893893
]
894894
},
895895
"profiles":[
@@ -912,6 +912,6 @@ TEST(RNTupleInspector, SchemaProfile)
912912
}
913913
]
914914
}
915-
)";
915+
)foo";
916916
EXPECT_EQ(schemaProfile, expected);
917917
}

0 commit comments

Comments
 (0)