Skip to content

Commit

Permalink
Merge branch 'fix/metadata-serialization' into 'master'
Browse files Browse the repository at this point in the history
[PGIS] Fix MetaCG serialization

See merge request tuda-sc/projects/metacg!134
  • Loading branch information
jplehr committed Feb 7, 2024
2 parents cdafc66 + 17d1599 commit b31ea1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
8 changes: 1 addition & 7 deletions pgis/lib/include/MetaData/CgNodeMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ class PiraOneData : public metacg::MetaData::Registrar<PiraOneData> {
}

nlohmann::json to_json() const final {
nlohmann::json j;
j["numStatements"] = getNumberOfStatements();
return j;
return getNumberOfStatements();
};

virtual const char *getKey() const final { return key; }
Expand Down Expand Up @@ -189,10 +187,6 @@ inline void setPiraOneData(T node, int numStmts = 0, bool hasBody = false, bool
}
}

inline void to_json(nlohmann::json &j, const PiraOneData &data) {
j = nlohmann::json{{"numStatements", data.getNumberOfStatements()}};
}

/**
* This class holds data relevant to the PIRA II anslyses.
* Most notably it encapsulates the Extra-P peformance models
Expand Down
5 changes: 2 additions & 3 deletions pgis/test/unit/PIRAPGISMetadataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ TEST(PIRAPGISMetadataTest, PiraOneData) {
const auto &j = origMetadata->to_json();

// Compare all exported values
EXPECT_TRUE(j.contains("numStatements"));
EXPECT_EQ(j.at("numStatements"), origMetadata->getNumberOfStatements());
EXPECT_EQ(j.get<long long int>(), origMetadata->getNumberOfStatements());

// Import Json Object
// Note: due to historical reasons, PiraOne Data is not a json object, but only a single value
const auto &jsonMetadata = new pira::PiraOneData(j.at("numStatements"));
const auto &jsonMetadata = new pira::PiraOneData(j);

// Compare all imported values
EXPECT_EQ(jsonMetadata->getNumberOfStatements(), origMetadata->getNumberOfStatements());
Expand Down

0 comments on commit b31ea1d

Please sign in to comment.