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

Aggregations Refactor: Refactor Range Aggregations #15399

Merged
merged 1 commit into from
Dec 14, 2015
Merged

Aggregations Refactor: Refactor Range Aggregations #15399

merged 1 commit into from
Dec 14, 2015

Conversation

colings86
Copy link
Contributor

No description provided.

public static String createCIDR(long ipAddress, int networkMask) {
long blockSize = 1L << (32 - networkMask);
return octetsToCIDR(longToOctets(ipAddress - (ipAddress & (blockSize - 1))), networkMask);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a good alternative to propose but wish we did not have to add this public method to Cidrs solely for testing purposes

Copy link
Contributor

Choose a reason for hiding this comment

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

if we keep it here, maybe we should at least require an address that is valid for the given mask like cidrMaskToMinMax expects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the reason for this method was so I could take a random IP address and a random networkMask and turn them into an appropriate CIDR. I'm not sure how to do that without either having this method or recreating a lot of the logic in this class in the test?

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed that's what I said I don't have a good alternative so let's keep it. But can we make it less lenient and expect an ip address that is compatible with the mask and move the - (ipAddress & (blockSize - 1)) part to the ipv4 range tests?

@jpountz
Copy link
Contributor

jpountz commented Dec 14, 2015

I left two minor comments but it looks good to me otherwise.

@colings86 colings86 merged commit 5513a76 into elastic:feature/aggs-refactoring Dec 14, 2015
@colings86 colings86 deleted the refactor/rangeAgg branch December 14, 2015 13:24
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Search Refactoring labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants