From 096e8314169aaacfaf0d98649cb1f54e8ce0f94e Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Wed, 5 Dec 2018 17:14:11 +0100 Subject: [PATCH] Created fixed datasets for non chunked datasets --- lib/src/H5Writer.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/src/H5Writer.cpp b/lib/src/H5Writer.cpp index 7ac8548..6b80e59 100644 --- a/lib/src/H5Writer.cpp +++ b/lib/src/H5Writer.cpp @@ -154,8 +154,8 @@ void H5Writer::create_dataset(const string& dataset_name, const vector& // This should be equivalent to the total number of frames in this file. dataset_dimension[0] = dataset_size; - // This dataset can be resized without limits. - max_dataset_dimension[0] = H5S_UNLIMITED; + // The maximum dataset size is the same as the number of images. + max_dataset_dimension[0] = dataset_size; // Chunking is always set to a single data point. dataset_chunking[0] = 1; @@ -165,6 +165,15 @@ void H5Writer::create_dataset(const string& dataset_name, const vector& dataset_chunking[index+1] = data_shape[index]; } + // Create a chunked dataset if needed. + H5::DSetCreatPropList dataset_properties; + if (chunked) { + dataset_properties.setChunk(dataset_rank, dataset_chunking); + + // Chunked datasets can be resized without limits. + max_dataset_dimension[0] = H5S_UNLIMITED; + } + H5::DataSpace dataspace(dataset_rank, dataset_dimension, max_dataset_dimension); #ifdef DEBUG_OUTPUT @@ -176,12 +185,6 @@ void H5Writer::create_dataset(const string& dataset_name, const vector& } cout << ")" << endl; #endif - - // Create a chunked dataset if needed. - H5::DSetCreatPropList dataset_properties; - if (chunked) { - dataset_properties.setChunk(dataset_rank, dataset_chunking); - } H5::AtomType dataset_data_type(H5FormatUtils::get_dataset_data_type(data_type));