patch 4.0
This commit is contained in:
@ -13,56 +13,59 @@
|
||||
#include "ob_exec_hash_struct.h"
|
||||
#include "common/row/ob_row_store.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
|
||||
// When there's stored_row_ and reserved_cells_, use store_row's reserved_cells_ for calc hash.
|
||||
// Other, use row_ for calc hash
|
||||
//When there's stored_row_ and reserved_cells_, use store_row's reserved_cells_ for calc hash.
|
||||
//Other, use row_ for calc hash
|
||||
uint64_t ObHashCols::inner_hash() const
|
||||
{
|
||||
uint64_t result = 99194853094755497L;
|
||||
if (hash_col_idx_ != NULL) {
|
||||
int64_t group_col_count = hash_col_idx_->count();
|
||||
if (stored_row_ != NULL && stored_row_->reserved_cells_count_ > 0) {
|
||||
const ObObj* cells = stored_row_->reserved_cells_;
|
||||
if (stored_row_ != NULL
|
||||
&& stored_row_->reserved_cells_count_ > 0) {
|
||||
const ObObj *cells = stored_row_->reserved_cells_;
|
||||
for (int32_t i = 0; i < group_col_count; ++i) {
|
||||
if (hash_col_idx_->at(i).index_ < stored_row_->reserved_cells_count_) {
|
||||
const ObObj& cell = cells[hash_col_idx_->at(i).index_];
|
||||
result = cell.is_string_type() ? cell.varchar_murmur_hash(hash_col_idx_->at(i).cs_type_, result)
|
||||
: cell.hash(result);
|
||||
const ObObj &cell = cells[hash_col_idx_->at(i).index_];
|
||||
result = cell.is_string_type() ?
|
||||
cell.varchar_murmur_hash(hash_col_idx_->at(i).cs_type_, result) :
|
||||
cell.hash(result);
|
||||
}
|
||||
}
|
||||
} else if (row_ != NULL && row_->is_valid()) {
|
||||
const ObObj* cells = row_->cells_;
|
||||
const int32_t* projector = row_->projector_;
|
||||
const ObObj *cells = row_->cells_;
|
||||
const int32_t *projector = row_->projector_;
|
||||
for (int64_t i = 0; i < group_col_count; ++i) {
|
||||
int64_t real_index =
|
||||
row_->projector_size_ > 0 ? projector[hash_col_idx_->at(i).index_] : hash_col_idx_->at(i).index_;
|
||||
const ObObj& cell = cells[real_index];
|
||||
result =
|
||||
cell.is_string_type() ? cell.varchar_murmur_hash(hash_col_idx_->at(i).cs_type_, result) : cell.hash(result);
|
||||
int64_t real_index = row_->projector_size_ > 0 ?
|
||||
projector[hash_col_idx_->at(i).index_] : hash_col_idx_->at(i).index_;
|
||||
const ObObj &cell = cells[real_index];
|
||||
result = cell.is_string_type() ?
|
||||
cell.varchar_murmur_hash(hash_col_idx_->at(i).cs_type_, result) :
|
||||
cell.hash(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// When there is stored_row_ reserved_cells, use stored_row_'s reserved_cells_ for calc equal.
|
||||
// Other use row_.
|
||||
bool ObHashCols::operator==(const ObHashCols& other) const
|
||||
//When there is stored_row_ reserved_cells, use stored_row_'s reserved_cells_ for calc equal.
|
||||
//Other use row_.
|
||||
bool ObHashCols::operator ==(const ObHashCols &other) const
|
||||
{
|
||||
bool result = true;
|
||||
const ObObj* lcell = NULL;
|
||||
const ObObj* rcell = NULL;
|
||||
const ObObj *lcell = NULL;
|
||||
const ObObj *rcell = NULL;
|
||||
|
||||
if (OB_ISNULL(hash_col_idx_)) {
|
||||
result = false;
|
||||
} else {
|
||||
int64_t group_col_count = hash_col_idx_->count();
|
||||
// When group_col_count<=0 is the case of hash group by const,
|
||||
// it should be considered as a group,
|
||||
// so result should be initialized to true
|
||||
//当group_col_count<=0是hash group by const的情况,应该认为是一个分组,所以result要初始化为true
|
||||
for (int32_t i = 0; i < group_col_count && result; ++i) {
|
||||
int64_t group_idx = hash_col_idx_->at(i).index_;
|
||||
if (stored_row_ != NULL) {
|
||||
@ -96,10 +99,11 @@ bool ObHashCols::operator==(const ObHashCols& other) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void ObHashCols::set_stored_row(const ObRowStore::StoredRow* stored_row)
|
||||
void ObHashCols::set_stored_row(const ObRowStore::StoredRow *stored_row)
|
||||
{
|
||||
stored_row_ = stored_row;
|
||||
row_ = NULL;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
}//ns sql
|
||||
}//ns oceanbase
|
||||
|
||||
|
||||
Reference in New Issue
Block a user