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

[measurement] HDF5 v6 - Store channel ID in measurement #1375

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KerstinKeller
Copy link
Contributor

Description

Related issues

This is looseley related to #1076, and also to #1292

Cherry-pick to

  • master-v5 (master for eCAL 5 feature backporting) ??? (To be discussed - probably not. Maybe we can add the v6 reader to master-v5, however this requires a separate commit.)

Docs???

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 20 out of 55. Check the log or trigger a new build to see more.

@@ -76,12 +76,12 @@ void MeasurementExporter::setData(eCALMeasCutterUtils::Timestamp timestamp, cons
const auto sender_timestamp = (iter != meta_data.end()) ? iter->second.sender_timestamp : static_cast<eCALMeasCutterUtils::Timestamp>(0);

iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_ID);
const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : static_cast<uint64_t>(0);
const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

  const auto sender_id = (iter != meta_data.end()) ? iter->second.sender_id : 0;
                                                                  ^


iter = meta_data.find(eCALMeasCutterUtils::MetaDatumKey::SENDER_CLOCK);
const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : static_cast<uint64_t>(0);
const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access]

  const auto sender_clock = (iter != meta_data.end()) ? iter->second.sender_clock : 0;
                                                                     ^


std::array<char,64> __union_size;
std::array<char,64> __union_size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: declaration uses identifier '__union_size', which is a reserved identifier [bugprone-reserved-identifier]

Suggested change
std::array<char,64> __union_size;
std::array<char,64> _union_size;

auto escaped_channels = hdf_meas_impl_->GetChannels();
for (const auto& escaped_channel : escaped_channels)
{
ret_val.emplace(eCAL::eh5::SChannel{ GetUnescapedString(escaped_channel.name), escaped_channel.id });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unnecessary temporary object created while calling emplace [modernize-use-emplace]

Suggested change
ret_val.emplace(eCAL::eh5::SChannel{ GetUnescapedString(escaped_channel.name), escaped_channel.id });
ret_val.emplace( GetUnescapedString(escaped_channel.name), escaped_channel.id );

for (const auto& escaped_channel : escaped_channels)
{
if (GetUnescapedString(escaped_channel.name) == channel_name)
ret_val.emplace(eCAL::eh5::SChannel{ channel_name, escaped_channel.id });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unnecessary temporary object created while calling emplace [modernize-use-emplace]

Suggested change
ret_val.emplace(eCAL::eh5::SChannel{ channel_name, escaped_channel.id });
ret_val.emplace( channel_name, escaped_channel.id );

if (!IsOk())
return false;

hsize_t hsSize = static_cast<hsize_t>(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'hsSize' of type 'hsize_t' (aka 'unsigned long long') can be declared 'const' [misc-const-correctness]

Suggested change
hsize_t hsSize = static_cast<hsize_t>(size);
hsize_t const hsSize = static_cast<hsize_t>(size);

auto dataSet = H5Dcreate(file_id_, std::to_string(entries_counter_).c_str(), H5T_NATIVE_UCHAR, dataSpace, H5P_DEFAULT, dsProperty, H5P_DEFAULT);

// Write buffer to dataset
herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'writeStatus' of type 'herr_t' (aka 'int') can be declared 'const' [misc-const-correctness]

Suggested change
herr_t writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
herr_t const writeStatus = H5Dwrite(dataSet, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);

H5Pclose(dsProperty);
H5Sclose(dataSpace);

channels_[channel_name][id].Entries.emplace_back(SEntryInfo(rcv_timestamp, static_cast<long long>(entries_counter_), clock, snd_timestamp, id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unnecessary temporary object created while calling emplace_back [modernize-use-emplace]

Suggested change
channels_[channel_name][id].Entries.emplace_back(SEntryInfo(rcv_timestamp, static_cast<long long>(entries_counter_), clock, snd_timestamp, id));
channels_[channel_name][id].Entries.emplace_back(rcv_timestamp, static_cast<long long>(entries_counter_), clock, snd_timestamp, id);

filePath += ".hdf5";

// create file access property
hid_t fileAccessPropery = H5Pcreate(H5P_FILE_ACCESS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'fileAccessPropery' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t fileAccessPropery = H5Pcreate(H5P_FILE_ACCESS);
hid_t const fileAccessPropery = H5Pcreate(H5P_FILE_ACCESS);

// create file access property
hid_t fileAccessPropery = H5Pcreate(H5P_FILE_ACCESS);
// create file create property
hid_t fileCreateProperty = H5Pcreate(H5P_FILE_CREATE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'fileCreateProperty' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t fileCreateProperty = H5Pcreate(H5P_FILE_CREATE);
hid_t const fileCreateProperty = H5Pcreate(H5P_FILE_CREATE);

@KerstinKeller KerstinKeller marked this pull request as draft February 28, 2024 08:15
@KerstinKeller
Copy link
Contributor Author

Will be reimplemented.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 20 out of 35. Check the log or trigger a new build to see more.

bool eCAL::eh5::HDF5MeasFileWriterV6::EntryFitsTheFile(const hsize_t& size) const
{
hsize_t fileSize = 0;
bool status = GetFileSize(fileSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'status' of type 'bool' can be declared 'const' [misc-const-correctness]

Suggested change
bool status = GetFileSize(fileSize);
bool const status = GetFileSize(fileSize);

// const size_t dataSetsSize = entries.size();
// if (dataSetsSize == 0) return false;

std::string hex_id = printHex(channelId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'hex_id' of type 'std::string' (aka 'basic_string') can be declared 'const' [misc-const-correctness]

Suggested change
std::string hex_id = printHex(channelId);
std::string const hex_id = printHex(channelId);

bool CreateStringEntryInRoot(hid_t root, const std::string& url, const std::string& dataset_content)
{
// create scalar dataset
hid_t scalar_dataspace = H5Screate(H5S_SCALAR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'scalar_dataspace' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t scalar_dataspace = H5Screate(H5S_SCALAR);
hid_t const scalar_dataspace = H5Screate(H5S_SCALAR);

// create scalar dataset
hid_t scalar_dataspace = H5Screate(H5S_SCALAR);
// create new string data type
hid_t string_data_type = H5Tcopy(H5T_C_S1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'string_data_type' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t string_data_type = H5Tcopy(H5T_C_S1);
hid_t const string_data_type = H5Tcopy(H5T_C_S1);

//H5Pset_create_intermediate_group(ds_property, 1);

// create attribute
hid_t data_set = H5Dcreate(root, url.c_str(), string_data_type, scalar_dataspace, H5P_DEFAULT, ds_property, H5P_DEFAULT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'data_set' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t data_set = H5Dcreate(root, url.c_str(), string_data_type, scalar_dataspace, H5P_DEFAULT, ds_property, H5P_DEFAULT);
hid_t const data_set = H5Dcreate(root, url.c_str(), string_data_type, scalar_dataspace, H5P_DEFAULT, ds_property, H5P_DEFAULT);

hid_t scalarDataset = H5Screate(H5S_SCALAR);

// create new string data type
hid_t stringDataType = H5Tcopy(H5T_C_S1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'stringDataType' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t stringDataType = H5Tcopy(H5T_C_S1);
hid_t const stringDataType = H5Tcopy(H5T_C_S1);

H5Tset_size(stringDataType, value.length());

// create attribute
hid_t attribute = H5Acreate(id, name.c_str(), stringDataType, scalarDataset, H5P_DEFAULT, H5P_DEFAULT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'attribute' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t attribute = H5Acreate(id, name.c_str(), stringDataType, scalarDataset, H5P_DEFAULT, H5P_DEFAULT);
hid_t const attribute = H5Acreate(id, name.c_str(), stringDataType, scalarDataset, H5P_DEFAULT, H5P_DEFAULT);

if (attribute < 0) return false;

// write attribute value to attribute
herr_t writeStatus = H5Awrite(attribute, stringDataType, value.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'writeStatus' of type 'herr_t' (aka 'int') can be declared 'const' [misc-const-correctness]

Suggested change
herr_t writeStatus = H5Awrite(attribute, stringDataType, value.c_str());
herr_t const writeStatus = H5Awrite(attribute, stringDataType, value.c_str());

if (H5Aexists(id, name.c_str()) != 0)
{
// open attribute by name, getting the attribute index
hid_t attr_id = H5Aopen_name(id, name.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'attr_id' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t attr_id = H5Aopen_name(id, name.c_str());
hid_t const attr_id = H5Aopen_name(id, name.c_str());

if (attr_id <= 0) return false;

// get attribute type
hid_t attr_type = H5Aget_type(attr_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'attr_type' of type 'hid_t' (aka 'long') can be declared 'const' [misc-const-correctness]

Suggested change
hid_t attr_type = H5Aget_type(attr_id);
hid_t const attr_type = H5Aget_type(attr_id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant