Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor writeStringDataBlock to overload writeDataBlock #140

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/io/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,10 @@ class BaseRecordingData
* @param data Vector with the string data
* @return The status of the write operation.
*/
virtual Status writeStringDataBlock(
const std::vector<SizeType>& dataShape,
const std::vector<SizeType>& positionOffset,
const BaseDataType& type,
const std::vector<std::string>& data) = 0;
virtual Status writeDataBlock(const std::vector<SizeType>& dataShape,
const std::vector<SizeType>& positionOffset,
const BaseDataType& type,
const std::vector<std::string>& data) = 0;

protected:
/**
Expand Down
8 changes: 4 additions & 4 deletions src/io/hdf5/HDF5IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,10 @@ Status HDF5IO::createStringDataSet(const std::string& path,
dataset = std::unique_ptr<IO::BaseRecordingData>(createArrayDataSet(
IO::BaseDataType::V_STR, SizeArray {values.size()}, SizeArray {1}, path));

dataset->writeStringDataBlock(std::vector<SizeType> {1},
std::vector<SizeType> {0},
IO::BaseDataType::V_STR,
values);
dataset->writeDataBlock(std::vector<SizeType> {1},
std::vector<SizeType> {0},
IO::BaseDataType::V_STR,
values);

return Status::Success;
}
Expand Down
4 changes: 2 additions & 2 deletions src/io/hdf5/HDF5RecordingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Status HDF5RecordingData::writeDataBlock(
return Status::Success;
}

Status HDF5RecordingData::writeStringDataBlock(
Status HDF5RecordingData::writeDataBlock(
const std::vector<SizeType>& dataShape,
const std::vector<SizeType>& positionOffset,
const AQNWB::IO::BaseDataType& type,
Expand Down Expand Up @@ -208,4 +208,4 @@ Status HDF5RecordingData::writeDataBlockHelper(
fSpace.selectHyperslab(H5S_SELECT_SET, dataDims.data(), offset.data());

return Status::Success;
}
}
8 changes: 4 additions & 4 deletions src/io/hdf5/HDF5RecordingData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ class HDF5RecordingData : public AQNWB::IO::BaseRecordingData
* @param data Vector with the string data
* @return The status of the write operation.
*/
Status writeStringDataBlock(const std::vector<SizeType>& dataShape,
const std::vector<SizeType>& positionOffset,
const AQNWB::IO::BaseDataType& type,
const std::vector<std::string>& data);
Status writeDataBlock(const std::vector<SizeType>& dataShape,
const std::vector<SizeType>& positionOffset,
const AQNWB::IO::BaseDataType& type,
const std::vector<std::string>& data);

/**
* @brief Gets a const pointer to the HDF5 dataset.
Expand Down
9 changes: 4 additions & 5 deletions src/nwb/base/TimeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ void TimeSeries::initialize(const IO::BaseDataType& dataType,
controlDescriptionShape,
controlDescriptionChunkSize,
AQNWB::mergePaths(m_path, "control_description")));
this->control_description->writeStringDataBlock(
controlDescriptionShape,
controlDescriptionPositionOffset,
controlDesriptionType,
controlDescription);
this->control_description->writeDataBlock(controlDescriptionShape,
controlDescriptionPositionOffset,
controlDesriptionType,
controlDescription);
} else {
this->control = nullptr;
this->control_description = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/nwb/hdmf/table/DynamicTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void DynamicTable::addColumn(std::unique_ptr<VectorData>& vectorData,
} else {
// write in loop because variable length string
for (SizeType i = 0; i < values.size(); i++)
vectorData->m_dataset->writeStringDataBlock(
vectorData->m_dataset->writeDataBlock(
std::vector<SizeType> {1},
std::vector<SizeType> {i},
IO::BaseDataType::STR(values[i].size() + 1),
Expand Down
12 changes: 6 additions & 6 deletions tests/testHDF5IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ TEST_CASE("HDF5IO; read dataset", "[hdf5io]")
// Write fixed-length string data block
std::vector<SizeType> strDataShape = {3};
std::vector<SizeType> strPositionOffset = {0};
writeStatus = strDataset->writeStringDataBlock(
writeStatus = strDataset->writeDataBlock(
strDataShape, strPositionOffset, strType, testDataStr);
REQUIRE(writeStatus == Status::Success);

Expand All @@ -1391,10 +1391,10 @@ TEST_CASE("HDF5IO; read dataset", "[hdf5io]")
std::vector<SizeType> vstrDataShape = {3};
std::vector<SizeType> vstrPositionOffset = {0};
writeStatus =
vstrDataset->writeStringDataBlock(vstrDataShape,
vstrPositionOffset,
vstrType, // Pass the vstrType object
testDataVStr);
vstrDataset->writeDataBlock(vstrDataShape,
vstrPositionOffset,
vstrType, // Pass the vstrType object
testDataVStr);
REQUIRE(writeStatus == Status::Success);

// Confirm reading the variable-length string data is correct
Expand Down Expand Up @@ -1547,4 +1547,4 @@ TEST_CASE("HDF5IO; read dataset subset", "[hdf5io]")

hdf5io->close();
}
}
}
2 changes: 1 addition & 1 deletion tests/testVectorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ TEST_CASE("VectorData", "[base]")
columnVectorData.initialize(std::move(columnDataset), description);

// Write data to file
Status writeStatus = columnVectorData.m_dataset->writeStringDataBlock(
Status writeStatus = columnVectorData.m_dataset->writeDataBlock(
dataShape, positionOffset, dataType, data);
REQUIRE(writeStatus == Status::Success);
io->flush();
Expand Down
Loading