diff --git a/src/vt-tv/api/object_info.h b/src/vt-tv/api/object_info.h index 20c321eeb3..0948009d28 100644 --- a/src/vt-tv/api/object_info.h +++ b/src/vt-tv/api/object_info.h @@ -72,13 +72,11 @@ struct ObjectInfo { ElementIDType in_id, NodeType in_home, bool in_migratable, - std::vector const& in_index, - std::unordered_map in_attributes = {} + std::vector const& in_index ) : id_(in_id), home_(in_home), migratable_(in_migratable), - index_(in_index), - attributes_(std::move(in_attributes)) + index_(in_index) { } /** @@ -157,13 +155,6 @@ struct ObjectInfo { */ CollectionObjGroupIDType getMetaID() const { return meta_id_; } - /** - * \brief Get attribute fields - * - * \return attribute fields - */ - auto const& getAttributes() const { return attributes_; } - /** * \brief Serializer for data * @@ -178,7 +169,6 @@ struct ObjectInfo { s | meta_id_; s | is_objgroup_; s | is_collection_; - s | attributes_; } private: @@ -196,8 +186,6 @@ struct ObjectInfo { bool is_objgroup_ = false; /// Whether it's an collection bool is_collection_ = false; - /// QOIs to be visualized - std::unordered_map attributes_; }; } /* end namespace vt::tv */ diff --git a/src/vt-tv/api/object_work.h b/src/vt-tv/api/object_work.h index f140658046..e63f84152e 100644 --- a/src/vt-tv/api/object_work.h +++ b/src/vt-tv/api/object_work.h @@ -77,12 +77,14 @@ struct ObjectWork { ElementIDType in_id, TimeType in_whole_phase_load, std::unordered_map in_subphase_loads, - std::unordered_map in_user_defined = {} + std::unordered_map in_user_defined = {}, + std::unordered_map in_attributes = {} ) : id_(in_id), whole_phase_load_(in_whole_phase_load), subphase_loads_(std::move(in_subphase_loads)), user_defined_(std::move(in_user_defined)), - communicator_(id_) + communicator_(id_), + attributes_(std::move(in_attributes)) { } /** @@ -113,6 +115,13 @@ struct ObjectWork { */ auto const& getUserDefined() const { return user_defined_; } + /** + * \brief Get attribute fields + * + * \return attribute fields + */ + auto const& getAttributes() const { return attributes_; } + /** * \brief set communications for this object * @@ -174,6 +183,7 @@ struct ObjectWork { s | subphase_loads_; s | user_defined_; s | communicator_; + s | attributes_; } private: @@ -185,6 +195,8 @@ struct ObjectWork { std::unordered_map subphase_loads_; // User-defined field---used to populate the memory block std::unordered_map user_defined_; + /// QOIs to be visualized + std::unordered_map attributes_; /// @todo: add communications ObjectCommunicator communicator_; diff --git a/src/vt-tv/utility/json_reader.cc b/src/vt-tv/utility/json_reader.cc index 153ef33cd0..34c1bbb55f 100644 --- a/src/vt-tv/utility/json_reader.cc +++ b/src/vt-tv/utility/json_reader.cc @@ -146,17 +146,7 @@ std::unique_ptr JSONReader::parseFile() { } } - std::unordered_map readed_metadata; - if (task["entity"].find("attributes") != task["entity"].end()) { - auto attributes = task["entity"]["attributes"]; - if (attributes.is_object()) { - for (auto& [key, value] : attributes.items()) { - readed_metadata[key] = value; - } - } - } - - ObjectInfo oi{object, home, migratable, std::move(index_arr), std::move(readed_metadata)}; + ObjectInfo oi{object, home, migratable, std::move(index_arr)}; if (task["entity"].find("collection_id") != task["entity"].end()) { oi.setIsCollection(true); @@ -196,11 +186,22 @@ std::unique_ptr JSONReader::parseFile() { } } } + + std::unordered_map readed_metadata; + if (task["entity"].find("attributes") != task["entity"].end()) { + auto attributes = task["entity"]["attributes"]; + if (attributes.is_object()) { + for (auto& [key, value] : attributes.items()) { + readed_metadata[key] = value; + } + } + } + // fmt::print(" Add object {}\n", (ElementIDType)object); objects.try_emplace( object, ObjectWork{ - object, time, std::move(subphase_loads), std::move(user_defined) + object, time, std::move(subphase_loads), std::move(user_defined), std::move(readed_metadata) } ); } diff --git a/tests/unit/test_json_reader.cc b/tests/unit/test_json_reader.cc index 78e9da5021..70c2d888b6 100644 --- a/tests/unit/test_json_reader.cc +++ b/tests/unit/test_json_reader.cc @@ -155,10 +155,10 @@ TEST_F(TestJSONReader, test_json_reader_object_info_attributes) { auto& rank_info = info->getRank(rank); EXPECT_EQ(rank_info.getRankID(), rank); - auto const& objects = info->getObjectInfo(); - auto const& object_info = objects.at(3407875); + auto const& objects = info->getRankObjects(0, 0); + auto const& object_work = objects.at(3407875); - auto& object_attributes = object_info.getAttributes(); + auto& object_attributes = object_work.getAttributes(); EXPECT_TRUE(object_attributes.find("boolSample") != object_attributes.end()); EXPECT_EQ(false, std::get(object_attributes.at("boolSample")));