Skip to content
Closed
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
15 changes: 8 additions & 7 deletions be/src/olap/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "vec/json/path_in_data.h"

namespace doris {
#include "common/compile_check_begin.h"

// A Field is used to represent a column in memory format.
// User can use this class to access or deal with column data in memory.
Expand All @@ -56,7 +57,7 @@ class Field {
virtual ~Field() = default;

size_t size() const { return _type_info->size(); }
int32_t length() const { return _length; }
size_t length() const { return _length; }
size_t field_size() const { return size() + 1; }
size_t index_size() const { return _index_size; }
int32_t unique_id() const { return _unique_id; }
Expand Down Expand Up @@ -202,7 +203,7 @@ class Field {
void add_sub_field(std::unique_ptr<Field> sub_field) {
_sub_fields.emplace_back(std::move(sub_field));
}
Field* get_sub_field(int i) const { return _sub_fields[i].get(); }
Field* get_sub_field(size_t i) const { return _sub_fields[i].get(); }
size_t get_sub_field_count() const { return _sub_fields.size(); }

void set_precision(int32_t precision) { _precision = precision; }
Expand All @@ -219,7 +220,7 @@ class Field {
// Note that, the struct type itself has fixed length, but due to
// its number of subfields is a variable, so the actual length of
// a struct field is not fixed.
uint32_t _length;
size_t _length;
// Since the length of the STRING type cannot be determined,
// only dynamic memory can be used. Arena cannot realize realloc.
// The schema information is shared globally. Therefore,
Expand Down Expand Up @@ -258,7 +259,7 @@ class Field {
// usually equal to length, except for variable-length strings
const KeyCoder* _key_coder;
std::string _name;
uint16_t _index_size;
size_t _index_size;
bool _is_nullable;
std::vector<std::unique_ptr<Field>> _sub_fields;
int32_t _precision;
Expand Down Expand Up @@ -342,7 +343,7 @@ class CharField : public Field {

void set_to_zone_map_max(char* ch) const override {
auto slice = reinterpret_cast<Slice*>(ch);
int length = _length < MAX_ZONE_MAP_INDEX_SIZE ? _length : MAX_ZONE_MAP_INDEX_SIZE;
size_t length = _length < MAX_ZONE_MAP_INDEX_SIZE ? _length : MAX_ZONE_MAP_INDEX_SIZE;
slice->size = length;
memset(slice->data, 0xFF, slice->size);
}
Expand Down Expand Up @@ -393,7 +394,7 @@ class VarcharField : public Field {
}
void set_to_zone_map_max(char* ch) const override {
auto slice = reinterpret_cast<Slice*>(ch);
int length = _length < MAX_ZONE_MAP_INDEX_SIZE ? _length : MAX_ZONE_MAP_INDEX_SIZE;
size_t length = _length < MAX_ZONE_MAP_INDEX_SIZE ? _length : MAX_ZONE_MAP_INDEX_SIZE;

slice->size = length - OLAP_VARCHAR_MAX_BYTES;
memset(slice->data, 0xFF, slice->size);
Expand Down Expand Up @@ -622,5 +623,5 @@ class FieldFactory {
return create(column);
}
};

#include "common/compile_check_end.h"
} // namespace doris
8 changes: 6 additions & 2 deletions be/src/olap/hll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <map>
#include <ostream>

#include "common/cast_set.h"
#include "common/logging.h"
#include "util/coding.h"
#include "util/slice.h"
Expand All @@ -29,6 +30,7 @@ using std::string;
using std::stringstream;

namespace doris {
#include "common/compile_check_begin.h"

HyperLogLog::HyperLogLog(const Slice& src) {
// When deserialize return false, we make this object a empty
Expand Down Expand Up @@ -194,7 +196,7 @@ size_t HyperLogLog::serialize(uint8_t* dst) const {
encode_fixed32_le(ptr, num_non_zero_registers);
ptr += 4;

for (uint32_t i = 0; i < HLL_REGISTERS_COUNT; ++i) {
for (uint16_t i = 0; i < HLL_REGISTERS_COUNT; ++i) {
if (_registers[i] == 0) {
continue;
}
Expand Down Expand Up @@ -335,7 +337,8 @@ int64_t HyperLogLog::estimate_cardinality() const {
}

float harmonic_mean = 0;
int num_zero_registers = 0;
// num_zero_registers will not exceed HLL_REGISTERS_COUNT
uint16_t num_zero_registers = 0;

for (int i = 0; i < HLL_REGISTERS_COUNT; ++i) {
harmonic_mean += powf(2.0F, -_registers[i]);
Expand Down Expand Up @@ -366,5 +369,6 @@ int64_t HyperLogLog::estimate_cardinality() const {
}
return (int64_t)(estimate + 0.5);
}
#include "common/compile_check_end.h"

} // namespace doris
9 changes: 6 additions & 3 deletions be/src/olap/hll.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
#include <string>
#include <utility>

#include "common/cast_set.h"

#ifdef __x86_64__
#include <immintrin.h>
#endif

#include "vec/common/hash_table/phmap_fwd_decl.h"

namespace doris {

#include "common/compile_check_begin.h"
struct Slice;

inline const int HLL_COLUMN_PRECISION = 14;
Expand Down Expand Up @@ -270,7 +272,8 @@ class HyperLogLog {
hash_value >>= HLL_COLUMN_PRECISION;
// make sure max first_one_bit is HLL_ZERO_COUNT_BITS + 1
hash_value |= ((uint64_t)1 << HLL_ZERO_COUNT_BITS);
uint8_t first_one_bit = __builtin_ctzl(hash_value) + 1;
// result of __builtin_ctzl never exceed 63, so we can safely
uint8_t first_one_bit = cast_set<uint8_t>(__builtin_ctzl(hash_value)) + 1;
_registers[idx] = (_registers[idx] < first_one_bit ? first_one_bit : _registers[idx]);
}

Expand Down Expand Up @@ -302,5 +305,5 @@ class HyperLogLog {
// it only when it is really needed.
uint8_t* _registers = nullptr;
};

#include "common/compile_check_end.h"
} // namespace doris
10 changes: 5 additions & 5 deletions be/src/olap/in_list_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct std::equal_to<doris::uint24_t> {
};

namespace doris {

#include "common/compile_check_begin.h"
/**
* Use HybridSetType can avoid virtual function call in the loop.
* @tparam Type
Expand Down Expand Up @@ -322,10 +322,10 @@ class InListPredicateBase : public ColumnPredicate {
}
} else if constexpr (Type == PrimitiveType::TYPE_DATE) {
const T* value = (const T*)(iter->get_value());
uint24_t date_value(value->to_olap_date());
int64_t date_value(value->to_olap_date());
if (bf->test_bytes(
const_cast<char*>(reinterpret_cast<const char*>(&date_value)),
sizeof(uint24_t))) {
sizeof(int64_t))) {
return true;
}
// DatetimeV1 using int64_t in bloom filter
Expand Down Expand Up @@ -363,7 +363,7 @@ class InListPredicateBase : public ColumnPredicate {
private:
uint16_t _evaluate_inner(const vectorized::IColumn& column, uint16_t* sel,
uint16_t size) const override {
int64_t new_size = 0;
uint16_t new_size = 0;

if (column.is_nullable()) {
const auto* nullable_col =
Expand Down Expand Up @@ -674,5 +674,5 @@ ColumnPredicate* create_in_list_predicate(uint32_t column_id,
return _create_in_list_predicate<Type, PT>(column_id, hybrid_set, char_length);
}
}

#include "common/compile_check_end.h"
} //namespace doris
Loading