Skip to content

Commit c8c960a

Browse files
Fix hdf5 dataset specific config (#1600)
* Add failing test * Fix
1 parent c2e0e83 commit c8c960a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/IO/HDF5/HDF5IOHandler.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,20 @@ void HDF5IOHandlerImpl::createDataset(
494494
*m_buffered_dataset_config,
495495
nlohmann::json::parse(mask_for_global_conf));
496496
}
497+
auto const &buffered_config = *m_buffered_dataset_config;
497498
auto parsed_config = json::parseOptions(
498499
parameters.options, /* considerFiles = */ false);
499500
if (auto hdf5_config_it = parsed_config.config.find("hdf5");
500501
hdf5_config_it != parsed_config.config.end())
501502
{
502-
hdf5_config_it.value() = json::merge(
503-
*m_buffered_dataset_config, hdf5_config_it.value());
503+
auto copy = buffered_config;
504+
json::merge(copy, hdf5_config_it.value());
505+
copy = nlohmann::json{{"hdf5", std::move(copy)}};
506+
parsed_config.config = std::move(copy);
504507
}
505508
else
506509
{
507-
parsed_config.config["hdf5"] = *m_buffered_dataset_config;
510+
parsed_config.config["hdf5"] = buffered_config;
508511
}
509512
return parsed_config;
510513
}();

test/ParallelIOTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ TEST_CASE("hdf5_write_test", "[parallel][hdf5]")
336336
"hdf5.dataset.chunks = [" + std::to_string(mpi_size) + "]"));
337337
e["positionOffset"]["x"].storeChunk(positionOffset_local, {mpi_rank}, {1});
338338

339+
// Test that chunking settings are not carried over to other datasets.
340+
// Just declare a dataset smaller than the previously chunks size to trigger
341+
// a failure in case the chunking is erroneously carried over.
342+
e["positionOffset"]["y"].resetDataset({Datatype::FLOAT, {1}});
343+
e["positionOffset"]["y"].storeChunk(
344+
std::make_unique<float>(3.141592654), {0}, {1});
345+
339346
o.flush();
340347
}
341348

0 commit comments

Comments
 (0)