Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make SSOne/SSMany constructors private and add apply method with count #519

Merged
merged 1 commit into from
Apr 27, 2016
Merged

make SSOne/SSMany constructors private and add apply method with count #519

merged 1 commit into from
Apr 27, 2016

Conversation

koertkuipers
Copy link
Contributor

These constructors should have been private from the beginning. The documentation already says other constructors should be used instead.
Also a new constructor/apply is added to set the exact count of an item instead of default value of 1

SSMany(capacity, counters, bucketsFromCounters(counters))

private[algebird] def apply[T](one: SSOne[T]): SSMany[T] =
SSMany(one.capacity, Map(one.item -> (1L, 0L)), SortedMap(1L -> Set(one.item)))
}

case class SSMany[T](capacity: Int, counters: Map[T, (Long, Long)], buckets: SortedMap[Long, Set[T]]) extends SpaceSaver[T] {
case class SSMany[T] private (capacity: Int, counters: Map[T, (Long, Long)], buckets: SortedMap[Long, Set[T]]) extends SpaceSaver[T] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be private[algebird] why are the others if not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the 2 apply methods in companion object are now both called from other classes so they both need to be private[algebird]. the one on line 110 had to be opened up because of new SpaceSaver.apply method on line 16.

the main constructor is not used outside the class. it can also very easily be used incorrectly (e.g. create buckets that are inconsistent with counters), so i rather keep it as private as possible.

@johnynek johnynek merged commit 95072eb into twitter:develop Apr 27, 2016
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