Skip to content

Conversation

@pdet
Copy link
Collaborator

@pdet pdet commented Feb 16, 2021

I'm using map, since I guess that's preferred over unordered_map?

Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks exquisite. Some minor comments:

if (!state->hist) {
state->hist = new map<T, size_t>();
}
T value = input.GetValue(i).GetValue<T>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change this to use the underlying array directly (i.e. auto input_data = (T *) input_data.data;) instead of the much slower value interface?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I guess I'll have to write a specialized method for strings then

@hannes
Copy link
Member

hannes commented Feb 17, 2021

Looks great, I have a suggestion: Instead of naming the map entries k and v maybe use something more descriptive like bucket and count or something of the like.

@pdet
Copy link
Collaborator Author

pdet commented Feb 17, 2021

@hannesmuehleisen I don't have a strong opposition to that, the reason I went for k and v was to not make the answer super large
[<k: 1, v: 2>, <k: 2, v: 3>, <k: 3, v: 1>, <k: 5, v: 1>]

would be
[<bucket: 1, count: 2>, <bucket: 2, count: 3>, <bucket: 3, count: 1>, <bucket: 5, count: 1>]

As a comparison, Presto would output:
{1=2, 2=3, 3=1, 5=1}

@hannes
Copy link
Member

hannes commented Feb 17, 2021

@pdet i think self-describing names are better, since this only affects the ToString representation.

@hannes hannes merged commit 4241b40 into duckdb:master Feb 18, 2021
@hannes
Copy link
Member

hannes commented Feb 18, 2021

Thanks!

@pdet pdet deleted the histogram branch March 10, 2021 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants