Skip to content

[Vectorized][Feature] add ColumnHLL to support hll type - #7828

Merged
morningman merged 4 commits into
apache:masterfrom
zhangstar333:vec_hll2
Feb 17, 2022
Merged

[Vectorized][Feature] add ColumnHLL to support hll type#7828
morningman merged 4 commits into
apache:masterfrom
zhangstar333:vec_hll2

Conversation

@zhangstar333

Copy link
Copy Markdown
Contributor

Proposed changes

Issue Number: close#7826

Problem Summary:

Describe the overview of changes.

Checklist(Required)

  1. Does it affect the original behavior: (Yes/No/I Don't know)
  2. Has unit tests been added: (Yes/No/No Need)
  3. Has document been added or modified: (Yes/No/No Need)
  4. Does it need to update dependencies: (Yes/No)
  5. Are there any changes that cannot be rolled back: (Yes/No)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@zhangstar333zhangstar333 changed the title [vectorized][feature] add ColumnHLL to support hll type[Vectorized][Feature] add ColumnHLL to support hll typeJan 21, 2022

namespace doris::vectorized {

size_t DataTypeHLL::serialize(const IColumn& column, PColumn* pcolumn) const {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The serialize() method has been refactored in #7939 , please change it after that PR being merged.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

OK!

struct is_complex<DataTypeBitMap::FieldType> : std::true_type {};

template <>
struct is_complex<DataTypeHLL::FieldType> : std::true_type {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why define HLL in data_type_bitmap?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Why define HLL in data_type_bitmap?

I will deal with it

@morningmanmorningman self-assigned this Feb 3, 2022

@HappenLeeHappenLee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some problem need to fix

Comment threadbe/src/olap/hll.h Outdated

HyperLogLog& operator=(HyperLogLog&& other) {
if (this != &other) {
if(_registers) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if (

Comment threadbe/src/olap/hll.h Outdated

private:
DISALLOW_COPY_AND_ASSIGN(HyperLogLog);
//DISALLOW_COPY_AND_ASSIGN(HyperLogLog);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

delete the code

auto result = this->data(place).get();
column.insert_data(result.c_str(), result.length());
auto& column = static_cast<ColumnHLL&>(to);
column.get_data().push_back(this->data(place).get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

emplace_back to reduce unless copy

Comment threadbe/src/vec/functions/hll_empty.cpp Outdated
static HyperLogLog init_value() {
auto hll = HyperLogLog::empty();
return {hll.c_str(), hll.size()};
return HyperLogLog(hll);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

directly construct the class

Comment threadbe/src/vec/functions/hll_hash.cpp Outdated
if (nullmap[i]) {
hash_string = HyperLogLog::empty();
std::string hash_string = HyperLogLog::empty();
res_data[i] = HyperLogLog(Slice(hash_string));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here should direct continue

@zhangstar333
zhangstar333force-pushed the vec_hll2 branch 2 times, most recently from b8b3023 to 7c780c5CompareFebruary 10, 2022 03:47

@HappenLeeHappenLee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some little problem

Comment threadbe/src/vec/core/block.cpp Outdated
string_slot->len = size;
} else if (slot_desc->type() == TYPE_HLL) {
auto hll_value = (HyperLogLog*)(data_ref.data);
LOG(INFO)<<"block hll string: "<<hll_value->to_string();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

del the log(INFO)

Comment threadbe/src/vec/core/block.cpp Outdated
auto string_slot = dst->get_string_slot(slot_desc->tuple_offset());
string_slot->ptr = reinterpret_cast<char*>(pool->allocate(size));
hll_value->serialize((uint8_t*)string_slot->ptr);
string_slot->len = size;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

set string_slot->len to serialize size


for (size_t i = 0; i < column_num; ++i) {
auto& hll = const_cast<HyperLogLog&>(data_column.get_element(i));
hll.serialize(reinterpret_cast<uint8_t*>(buf));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the size is not match to max serialized size may cause error

auto& hll = const_cast<HyperLogLog&>(data_column.get_element(i));
allocate_content_size += hll.max_serialized_size();
std::string result(hll.max_serialized_size(), '0');
size_t actual_size = hll.serialize((uint8_t*)result.c_str());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should not serialize two times

@HappenLeeHappenLee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Feb 16, 2022
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Vectorized][Feature]add ColumnHLL to support HLL type

3 participants

@zhangstar333@morningman@HappenLee