Skip to content

Andrei/text columns prefix#92

Merged
AndreiBozantan merged 3 commits intomasterfrom
andrei/text-columns-prefix
Apr 1, 2020
Merged

Andrei/text columns prefix#92
AndreiBozantan merged 3 commits intomasterfrom
andrei/text-columns-prefix

Conversation

@AndreiBozantan
Copy link
Copy Markdown
Contributor

Added exploration for prefixes of text columns.

AndreiBozantan and others added 3 commits March 30, 2020 21:49
improved the method that performs summing of counts from the results of a query; added computation for suppressed rows and total rows, which are useful for the prefix explorer
added exploration of column prefixes
Copy link
Copy Markdown
Contributor

@dandanlen dandanlen left a comment

Choose a reason for hiding this comment

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

Looks good. Just check out my comment below and let me know what you think.

I've approved the PR anyway, so feel free to merge.

acc.Item1 + next.Count,
acc.Item2 + (next.IsSuppressed ? next.Count : 0L)));
default(CountResultType),
(acc, row) => new CountResultType(acc, row.Count, row.IsSuppressed));
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.

A constructor that exists merely to increment the count isn't very intuitive. And it seems wasteful to create a new value at every iteration of the loop? (maybe it doesn't matter since it's a value type?)

Would it be better / more idiomatic here to have a member function that updates the counter in-place? Something like:

public CountResultType Accumulate<T>(T row)
where T : ICountAggregate, ISuppressible
=> new CountResultType
{
    TotalCount = TotalCount + row.Count,
    TotalRows = TotalRows + 1,
    SuppressedCount = SuppressedCount + (row.IsSuppressed ? row.Count : 0),
    SuppressedRows = SuppressedRows + (row.IsSuppressed ? 1 : 0), 
};

Then we could write

(acc, row) => acc.Accumulate(row)

Or otherwise make the member function static:

(acc, row) => CountResultType.Accumulate(acc, row)

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I will try to fix it in a separate PR.

@AndreiBozantan AndreiBozantan merged commit 92aa3ed into master Apr 1, 2020
@AndreiBozantan AndreiBozantan mentioned this pull request Apr 1, 2020
@AndreiBozantan AndreiBozantan deleted the andrei/text-columns-prefix branch April 22, 2020 13:07
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.

2 participants