Skip to content

Commit 9bb5f4b

Browse files
committed
Solve the bug of float/double type column when checksum
1 parent 9402e11 commit 9bb5f4b

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

be/src/olap/row.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ bool equal_row(const std::vector<uint32_t>& ids,
5959
template<typename LhsRowType, typename RhsRowType>
6060
int compare_row(const LhsRowType& lhs, const RhsRowType& rhs) {
6161
for (uint32_t cid = 0; cid < lhs.schema()->num_key_columns(); ++cid) {
62-
//because the num_column_ids include the column of double/float type
63-
if (lhs.schema()->column(cid) == NULL) {
64-
continue;
65-
}
6662
auto res = lhs.schema()->column(cid)->compare_cell(lhs.cell(cid), rhs.cell(cid));
6763
if (res != 0) {
6864
return res;
@@ -80,10 +76,6 @@ template<typename LhsRowType, typename RhsRowType>
8076
int compare_row_key(const LhsRowType& lhs, const RhsRowType& rhs) {
8177
auto cmp_cids = std::min(lhs.schema()->num_column_ids(), rhs.schema()->num_column_ids());
8278
for (uint32_t cid = 0; cid < cmp_cids; ++cid) {
83-
//because the num_column_ids include the column of double/float type
84-
if (lhs.schema()->column(cid) == NULL) {
85-
continue;
86-
}
8779
auto res = lhs.schema()->column(cid)->compare_cell(lhs.cell(cid), rhs.cell(cid));
8880
if (res != 0) {
8981
return res;
@@ -194,7 +186,12 @@ void agg_finalize_row(const std::vector<uint32_t>& ids, RowType* row, MemPool* m
194186

195187
template<typename RowType>
196188
uint32_t hash_row(const RowType& row, uint32_t seed) {
189+
FieldType type;
197190
for (uint32_t cid : row.schema()->column_ids()) {
191+
type = row.schema()->column(cid)->type();
192+
if (type == OLAP_FIELD_TYPE_FLOAT || type == OLAP_FIELD_TYPE_DOUBLE) {
193+
continue;
194+
}
198195
seed = row.schema()->column(cid)->hash_code(row.cell(cid), seed);
199196
}
200197
return seed;

be/src/olap/task/engine_checksum_task.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,7 @@ OLAPStatus EngineChecksumTask::_compute_checksum() {
8080
}
8181
}
8282

83-
// ignore float and double type considering to precision lose
8483
for (size_t i = 0; i < tablet->tablet_schema().num_columns(); ++i) {
85-
FieldType type = tablet->tablet_schema().column(i).type();
86-
if (type == OLAP_FIELD_TYPE_FLOAT || type == OLAP_FIELD_TYPE_DOUBLE) {
87-
continue;
88-
}
89-
9084
reader_params.return_columns.push_back(i);
9185
}
9286

@@ -109,6 +103,7 @@ OLAPStatus EngineChecksumTask::_compute_checksum() {
109103

110104
bool eof = false;
111105
uint32_t row_checksum = 0;
106+
uint32_t one_checksum;
112107
while (true) {
113108
OLAPStatus res = reader.next_row_with_aggregation(&row, mem_pool.get(), agg_object_pool.get(), &eof);
114109
if (res == OLAP_SUCCESS && eof) {
@@ -118,8 +113,10 @@ OLAPStatus EngineChecksumTask::_compute_checksum() {
118113
OLAP_LOG_WARNING("fail to read in reader. [res=%d]", res);
119114
return res;
120115
}
121-
122-
row_checksum = hash_row(row, row_checksum);
116+
one_checksum = 0;
117+
one_checksum = hash_row(row, one_checksum);
118+
// The value of checksum is independent of the sorting of data rows.
119+
row_checksum = row_checksum ^ one_checksum;
123120
// the memory allocate by mem pool has been copied,
124121
// so we should release memory immediately
125122
mem_pool->clear();

0 commit comments

Comments
 (0)