Skip to content

Commit 937de1a

Browse files
Fix available_chunks() for constant components (#942)
* Add (failing) test for available_chunks() on a constant record * Fix available_chunks() for constant components
1 parent 969b430 commit 937de1a

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/backend/BaseRecordComponent.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ BaseRecordComponent::constant() const
5959
ChunkTable
6060
BaseRecordComponent::availableChunks()
6161
{
62+
if( m_isConstant && *m_isConstant )
63+
{
64+
Offset offset( m_dataset->extent.size(), 0 );
65+
return ChunkTable{ { std::move( offset ), m_dataset->extent } };
66+
}
6267
Parameter< Operation::AVAILABLE_CHUNKS > param;
6368
IOTask task( this, param );
6469
IOHandler()->enqueue( task );

test/SerialIOTest.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ TEST_CASE( "available_chunks_test_json", "[serial][json]" )
183183
{
184184
E_x.storeChunk( data, { line, 0 }, { 1, 2 } );
185185
}
186-
E_x.storeChunk( data, { 8, 3 }, {2, 1 } );
186+
E_x.storeChunk( data, { 8, 3 }, { 2, 1 } );
187+
188+
auto E_y = it0.meshes[ "E" ][ "y" ];
189+
E_y.resetDataset( { Datatype::INT, { height, 4 } } );
190+
E_y.makeConstant( 1234 );
191+
187192
it0.close();
188193
}
189194

@@ -200,6 +205,12 @@ TEST_CASE( "available_chunks_test_json", "[serial][json]" )
200205
REQUIRE( bool( table[ 0 ] == WrittenChunkInfo( { 2, 0 }, { 5, 4 } ) ) );
201206
REQUIRE( bool( table[ 1 ] == WrittenChunkInfo( { 7, 0 }, { 2, 2 } ) ) );
202207
REQUIRE( bool( table[ 2 ] == WrittenChunkInfo( { 8, 3 }, { 2, 1 } ) ) );
208+
209+
auto E_y = it0.meshes[ "E" ][ "y" ];
210+
table = E_y.availableChunks();
211+
REQUIRE( table.size() == 1 );
212+
REQUIRE(
213+
bool( table[ 0 ] == WrittenChunkInfo( { 0, 0 }, { height, 4 } ) ) );
203214
}
204215
}
205216

0 commit comments

Comments
 (0)