From dcf157e3c7da0f4746eb8b2910572081d6a42f76 Mon Sep 17 00:00:00 2001 From: BenPinet Date: Fri, 14 Aug 2026 14:09:14 +0200 Subject: [PATCH] fix(AttributeManager): remove import method taking span --- include/geode/basic/attribute.hpp | 4 --- include/geode/basic/attribute_manager.hpp | 7 ---- include/geode/basic/constant_attribute.hpp | 7 ---- include/geode/basic/sparse_attribute.hpp | 22 ------------ include/geode/basic/variable_attribute.hpp | 42 ---------------------- src/geode/basic/attribute_manager.cpp | 15 -------- src/geode/mesh/helpers/internal/copy.cpp | 16 +++++---- tests/basic/test-attribute.cpp | 14 ++++---- 8 files changed, 16 insertions(+), 111 deletions(-) diff --git a/include/geode/basic/attribute.hpp b/include/geode/basic/attribute.hpp index b29d69b6d..70a2dcc79 100644 --- a/include/geode/basic/attribute.hpp +++ b/include/geode/basic/attribute.hpp @@ -100,10 +100,6 @@ namespace geode index_t nb_elements, AttributeKey /*key*/ ) const = 0; - virtual void import( absl::Span< const index_t > old2new, - const std::shared_ptr< AttributeBase >& from, - AttributeBase::AttributeKey /*key*/ ) = 0; - virtual void import( const GenericMapping< index_t >& old2new_mapping, const std::shared_ptr< AttributeBase >& from, AttributeBase::AttributeKey /*key*/ ) = 0; diff --git a/include/geode/basic/attribute_manager.hpp b/include/geode/basic/attribute_manager.hpp index 35df569ae..4c1f9d030 100644 --- a/include/geode/basic/attribute_manager.hpp +++ b/include/geode/basic/attribute_manager.hpp @@ -252,13 +252,6 @@ namespace geode void copy( const AttributeManager& attribute_manager ); - void import( const AttributeManager& attribute_manager, - absl::Span< const index_t > old2new ); - - void import( const AttributeManager& attribute_manager, - absl::Span< const index_t > old2new, - const uuid& attribute_id ); - void import( const AttributeManager& attribute_manager, const GenericMapping< index_t >& old2new_mapping ); diff --git a/include/geode/basic/constant_attribute.hpp b/include/geode/basic/constant_attribute.hpp index acbd5c898..67434221b 100644 --- a/include/geode/basic/constant_attribute.hpp +++ b/include/geode/basic/constant_attribute.hpp @@ -203,13 +203,6 @@ namespace geode return attribute; } - void import( absl::Span< const index_t > /* unused */, - const std::shared_ptr< AttributeBase >& from, - AttributeBase::AttributeKey /*key*/ ) override - { - import( dynamic_cast< const ReadOnlyAttribute< T >& >( *from ) ); - } - void import( const GenericMapping< index_t >& /* unused */, const std::shared_ptr< AttributeBase >& from, AttributeBase::AttributeKey /*key*/ ) override diff --git a/include/geode/basic/sparse_attribute.hpp b/include/geode/basic/sparse_attribute.hpp index 304e8b20e..eabc85200 100644 --- a/include/geode/basic/sparse_attribute.hpp +++ b/include/geode/basic/sparse_attribute.hpp @@ -311,14 +311,6 @@ namespace geode return attribute; } - void import( absl::Span< const index_t > old2new, - const std::shared_ptr< AttributeBase >& from, - AttributeBase::AttributeKey /*key*/ ) override - { - import( old2new, - dynamic_cast< const ReadOnlyAttribute< T >& >( *from ) ); - } - void import( const GenericMapping< index_t >& old2new_mapping, const std::shared_ptr< AttributeBase >& from, AttributeBase::AttributeKey /*key*/ ) override @@ -327,20 +319,6 @@ namespace geode dynamic_cast< const ReadOnlyAttribute< T >& >( *from ) ); } - void import( absl::Span< const index_t > old2new, - const ReadOnlyAttribute< T >& from ) - { - for( const auto i : Indices{ old2new } ) - { - const auto new_index = old2new[i]; - if( from.value( i ) != default_values_.default_value - && new_index != NO_ID ) - { - this->set_value( new_index, from.value( i ) ); - } - } - } - void import( const GenericMapping< index_t >& old2new_mapping, const ReadOnlyAttribute< T >& from ) { diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index c4df6294f..7753de23a 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -287,14 +287,6 @@ namespace geode return attribute; } - void import( absl::Span< const index_t > old2new, - const std::shared_ptr< AttributeBase >& from, - AttributeBase::AttributeKey /*key*/ ) override - { - import( old2new, - dynamic_cast< const ReadOnlyAttribute< T >& >( *from ) ); - } - void import( const GenericMapping< index_t >& old2new_mapping, const std::shared_ptr< AttributeBase >& from, AttributeBase::AttributeKey /*key*/ ) override @@ -303,19 +295,6 @@ namespace geode dynamic_cast< const ReadOnlyAttribute< T >& >( *from ) ); } - void import( absl::Span< const index_t > old2new, - const ReadOnlyAttribute< T >& from ) - { - for( const auto i : Indices{ old2new } ) - { - const auto new_index = old2new[i]; - if( new_index != NO_ID ) - { - this->set_value( new_index, from.value( i ) ); - } - } - } - void import( const GenericMapping< index_t >& old2new_mapping, const ReadOnlyAttribute< T >& from ) { @@ -569,14 +548,6 @@ namespace geode return attribute; } - void import( absl::Span< const index_t > old2new, - const std::shared_ptr< AttributeBase >& from, - AttributeBase::AttributeKey /*key*/ ) override - { - import( old2new, - dynamic_cast< const ReadOnlyAttribute< bool >& >( *from ) ); - } - void import( const GenericMapping< index_t >& old2new_mapping, const std::shared_ptr< AttributeBase >& from, AttributeBase::AttributeKey /*key*/ ) override @@ -585,19 +556,6 @@ namespace geode dynamic_cast< const ReadOnlyAttribute< bool >& >( *from ) ); } - void import( absl::Span< const index_t > old2new, - const ReadOnlyAttribute< bool >& from ) - { - for( const auto i : Indices{ old2new } ) - { - const auto new_index = old2new[i]; - if( new_index != NO_ID ) - { - this->set_value( new_index, from.value( i ) ); - } - } - } - void import( const GenericMapping< index_t >& old2new_mapping, const ReadOnlyAttribute< bool >& from ) { diff --git a/src/geode/basic/attribute_manager.cpp b/src/geode/basic/attribute_manager.cpp index f6f607ede..4f1509878 100644 --- a/src/geode/basic/attribute_manager.cpp +++ b/src/geode/basic/attribute_manager.cpp @@ -570,21 +570,6 @@ namespace geode return impl_->attribute_ids_matching_name( name ); } - void AttributeManager::import( const AttributeManager &attribute_manager, - absl::Span< const index_t > old2new ) - { - impl_->import( - *attribute_manager.impl_, old2new, AttributeBase::AttributeKey{} ); - } - - void AttributeManager::import( const AttributeManager &attribute_manager, - absl::Span< const index_t > old2new, - const geode::uuid &attribute_id ) - { - impl_->import( *attribute_manager.impl_, old2new, attribute_id, - AttributeBase::AttributeKey{} ); - } - void AttributeManager::import( const AttributeManager &attribute_manager, const GenericMapping< index_t > &old2new_mapping ) { diff --git a/src/geode/mesh/helpers/internal/copy.cpp b/src/geode/mesh/helpers/internal/copy.cpp index c590c69ca..fcf2f9554 100644 --- a/src/geode/mesh/helpers/internal/copy.cpp +++ b/src/geode/mesh/helpers/internal/copy.cpp @@ -21,6 +21,8 @@ * */ +#include + #include #include @@ -32,13 +34,13 @@ namespace geode void copy_attributes( const AttributeManager& manager_in, AttributeManager& manager_out ) { - absl::FixedArray< index_t > old2new( manager_in.nb_elements() ); - async::parallel_for( - async::irange( index_t{ 0 }, manager_in.nb_elements() ), - [&old2new]( index_t i ) { - old2new[i] = i; - } ); - manager_out.import( manager_in, old2new ); + GenericMapping< index_t > mapping; + for( const auto attribute_element : + geode::Range{ manager_in.nb_elements() } ) + { + mapping.map( attribute_element, attribute_element ); + } + manager_out.import( manager_in, mapping ); } } // namespace internal } // namespace geode diff --git a/tests/basic/test-attribute.cpp b/tests/basic/test-attribute.cpp index 666389748..d84cc02e7 100644 --- a/tests/basic/test-attribute.cpp +++ b/tests/basic/test-attribute.cpp @@ -637,19 +637,18 @@ void test_import_manager( geode::AttributeManager& manager, { const auto nb_elements = manager.nb_elements(); geode::AttributeManager manager2; - std::vector< geode::index_t > old2new( nb_elements, geode::NO_ID ); + geode::GenericMapping< geode::index_t > old2new_mapping; manager2.resize( 0 ); - manager2.import( manager, old2new ); + manager2.import( manager, old2new_mapping ); test_attribute_types( manager2, bool_variable_attribute_id ); test_number_of_attributes( manager2, 8 ); - geode::AttributeManager manager3; for( const auto i : geode::LRange( nb_elements - 2 ) ) { - old2new[i] = nb_elements - 3 - i; + old2new_mapping.map( i, nb_elements - 3 - i ); } manager3.resize( nb_elements - 2 ); - manager3.import( manager, old2new ); + manager3.import( manager, old2new_mapping ); test_attribute_types( manager3, bool_variable_attribute_id ); test_number_of_attributes( manager3, 8 ); auto array_attr = @@ -663,12 +662,13 @@ void test_import_manager( geode::AttributeManager& manager, "Error in attribute import value." ); geode::AttributeManager manager4; + old2new_mapping.clear(); for( const auto i : geode::LRange( nb_elements ) ) { - old2new[i] = i; + old2new_mapping.map( i, i ); } manager4.resize( nb_elements ); - manager4.import( manager, old2new ); + manager4.import( manager, old2new_mapping ); test_attribute_types( manager4, bool_variable_attribute_id ); test_number_of_attributes( manager4, 8 ); test_sparse_attribute_after_element_deletion(