From 525d063abf8a5fe3fb2c26818145620779bb3ad8 Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 5 Jun 2020 10:21:22 +0800 Subject: [PATCH] [Dataset] Fix codedex. --- .../ccsrc/mindrecord/include/shard_column.h | 6 +++--- .../ccsrc/mindrecord/meta/shard_column.cc | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mindspore/ccsrc/mindrecord/include/shard_column.h b/mindspore/ccsrc/mindrecord/include/shard_column.h index ec71fd5bd..968d82e71 100644 --- a/mindspore/ccsrc/mindrecord/include/shard_column.h +++ b/mindspore/ccsrc/mindrecord/include/shard_column.h @@ -67,7 +67,7 @@ class ShardColumn { /// \brief get column value by column name MSRStatus GetColumnValueByName(const std::string &column_name, const std::vector &columns_blob, const json &columns_json, const unsigned char **data, - std::unique_ptr *data_ptr, uint64_t *n_bytes, + std::unique_ptr *data_ptr, uint64_t *const n_bytes, ColumnDataType *column_data_type, uint64_t *column_data_type_size, std::vector *column_shape); @@ -88,7 +88,7 @@ class ShardColumn { /// \brief get column value from blob MSRStatus GetColumnFromBlob(const std::string &column_name, const std::vector &columns_blob, const unsigned char **data, std::unique_ptr *data_ptr, - uint64_t *n_bytes); + uint64_t *const n_bytes); std::pair GetColumnTypeByName(const std::string &column_name, ColumnDataType *column_data_type, uint64_t *column_data_type_size, @@ -119,7 +119,7 @@ class ShardColumn { /// \brief uncompress integer array column template - static MSRStatus UncompressInt(const uint64_t &column_id, std::unique_ptr *data_ptr, + static MSRStatus UncompressInt(const uint64_t &column_id, std::unique_ptr *const data_ptr, const std::vector &columns_blob, uint64_t *num_bytes, uint64_t shift_idx); /// \brief convert big-endian bytes to unsigned int diff --git a/mindspore/ccsrc/mindrecord/meta/shard_column.cc b/mindspore/ccsrc/mindrecord/meta/shard_column.cc index 8c3e83178..b0cd6b631 100644 --- a/mindspore/ccsrc/mindrecord/meta/shard_column.cc +++ b/mindspore/ccsrc/mindrecord/meta/shard_column.cc @@ -87,7 +87,7 @@ std::pair ShardColumn::GetColumnTypeByName(const std: MSRStatus ShardColumn::GetColumnValueByName(const std::string &column_name, const std::vector &columns_blob, const json &columns_json, const unsigned char **data, - std::unique_ptr *data_ptr, uint64_t *n_bytes, + std::unique_ptr *data_ptr, uint64_t *const n_bytes, ColumnDataType *column_data_type, uint64_t *column_data_type_size, std::vector *column_shape) { // Skip if column not found @@ -250,7 +250,7 @@ MSRStatus ShardColumn::GetInt(std::unique_ptr *data_ptr, const MSRStatus ShardColumn::GetColumnFromBlob(const std::string &column_name, const std::vector &columns_blob, const unsigned char **data, std::unique_ptr *data_ptr, - uint64_t *n_bytes) { + uint64_t *const n_bytes) { uint64_t offset_address = 0; auto column_id = column_name_id_[column_name]; if (GetColumnAddressInBlock(column_id, columns_blob, n_bytes, &offset_address) == FAILED) { @@ -357,7 +357,7 @@ vector ShardColumn::CompressInt(const vector &src_bytes, const // Update date type in bit map dst_bytes[i / kNumDataOfByte + kBytesOfColumnLen] |= - (dst_int_type << (kDataTypeBits * (kNumDataOfByte - kUnsignedOne - (i % kNumDataOfByte)))); + (static_cast(dst_int_type) << (kDataTypeBits * (kNumDataOfByte - kUnsignedOne - (i % kNumDataOfByte)))); } // Resize destination blob dst_bytes.resize(i_dst); @@ -385,7 +385,7 @@ MSRStatus ShardColumn::GetColumnAddressInBlock(const uint64_t &column_id, const } template -MSRStatus ShardColumn::UncompressInt(const uint64_t &column_id, std::unique_ptr *data_ptr, +MSRStatus ShardColumn::UncompressInt(const uint64_t &column_id, std::unique_ptr *const data_ptr, const std::vector &columns_blob, uint64_t *num_bytes, uint64_t shift_idx) { auto num_elements = BytesBigToUInt64(columns_blob, shift_idx, kInt32Type); @@ -406,7 +406,7 @@ MSRStatus ShardColumn::UncompressInt(const uint64_t &column_id, std::unique_ptr< auto data = reinterpret_cast(array_data.get()); *data_ptr = std::make_unique(*num_bytes); - memcpy(data_ptr->get(), data, *num_bytes); + memcpy_s(data_ptr->get(), *num_bytes, data, *num_bytes); return SUCCESS; } @@ -414,14 +414,14 @@ MSRStatus ShardColumn::UncompressInt(const uint64_t &column_id, std::unique_ptr< uint64_t ShardColumn::BytesBigToUInt64(const std::vector &bytes_array, const uint64_t &pos, const IntegerType &i_type) { uint64_t result = 0; - for (uint64_t i = 0; i < (kUnsignedOne << i_type); i++) { + for (uint64_t i = 0; i < (kUnsignedOne << static_cast(i_type)); i++) { result = (result << kBitsOfByte) + bytes_array[pos + i]; } return result; } std::vector ShardColumn::UIntToBytesBig(uint64_t value, const IntegerType &i_type) { - uint64_t n_bytes = kUnsignedOne << i_type; + uint64_t n_bytes = kUnsignedOne << static_cast(i_type); std::vector result(n_bytes, 0); for (uint64_t i = 0; i < n_bytes; i++) { result[n_bytes - 1 - i] = value & std::numeric_limits::max(); @@ -431,7 +431,7 @@ std::vector ShardColumn::UIntToBytesBig(uint64_t value, const IntegerTy } std::vector ShardColumn::UIntToBytesLittle(uint64_t value, const IntegerType &i_type) { - uint64_t n_bytes = kUnsignedOne << i_type; + uint64_t n_bytes = kUnsignedOne << static_cast(i_type); std::vector result(n_bytes, 0); for (uint64_t i = 0; i < n_bytes; i++) { result[i] = value & std::numeric_limits::max(); @@ -443,7 +443,7 @@ std::vector ShardColumn::UIntToBytesLittle(uint64_t value, const Intege int64_t ShardColumn::BytesLittleToMinIntType(const std::vector &bytes_array, const uint64_t &pos, const IntegerType &src_i_type, IntegerType *dst_i_type) { uint64_t u_temp = 0; - for (uint64_t i = 0; i < (kUnsignedOne << src_i_type); i++) { + for (uint64_t i = 0; i < (kUnsignedOne << static_cast(src_i_type)); i++) { u_temp = (u_temp << kBitsOfByte) + bytes_array[pos + (kUnsignedOne << src_i_type) - kUnsignedOne - i]; } -- GitLab