Skip to content

Comments

Function to split an IP prefix into subnets (#2)#23656

Merged
NikhilCollooru merged 1 commit intoprestodb:masterfrom
matt-calder:mattcalder-ip-prefix-subnets-2
Sep 20, 2024
Merged

Function to split an IP prefix into subnets (#2)#23656
NikhilCollooru merged 1 commit intoprestodb:masterfrom
matt-calder:mattcalder-ip-prefix-subnets-2

Conversation

@matt-calder
Copy link
Contributor

@matt-calder matt-calder commented Sep 15, 2024

Description

This change introduces a function ip_prefix_subnets that, given an input ip_prefix and a subnet prefix_length, splits the IP prefix into subnets of the input prefix length. The functions return an array of new prefixes of the new input prefix length.

This is a new but identical PR to #23515 that I couldn't not figure out how to recover after a botched attempt to merge and squash.

This is a complimentary sister function to the ip_prefix_collapse function.

Motivation and Context

This change addresses issue 23514.

Impact

This change introduces a new user-facing function ip_prefix_subnets.

Test Plan

Unit tests

mvn clean install -Dtest=TestIpPrefixFunctions -Dmaven.javadoc.skip=true -DskipUI -T1C -fn -pl presto-main

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
== RELEASE NOTES ==

General Changes
* Add function :func:`ip_prefix_subnets` that splits the input prefix into subnets the size of the new prefix length. ... :pr:`23656`

elharo
elharo previously approved these changes Sep 15, 2024
steveburnett
steveburnett previously approved these changes Sep 16, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull branch, local doc build, looks good. Thanks!

{
private static final BigInteger TWO = BigInteger.valueOf(2);

private static final Block emptyBlock = IPPREFIX.createBlockBuilder(null, 0).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally use all upper case for static constants

kaikalur
kaikalur previously approved these changes Sep 19, 2024
NikhilCollooru
NikhilCollooru previously approved these changes Sep 19, 2024
@matt-calder matt-calder force-pushed the mattcalder-ip-prefix-subnets-2 branch from 90d4e5a to 014609a Compare September 19, 2024 20:25
@matt-calder matt-calder reopened this Sep 19, 2024
@matt-calder matt-calder reopened this Sep 20, 2024
@matt-calder matt-calder reopened this Sep 20, 2024
@NikhilCollooru NikhilCollooru merged commit 33ff952 into prestodb:master Sep 20, 2024
@jaystarshot jaystarshot mentioned this pull request Nov 1, 2024
25 tasks
@tdcmeehan tdcmeehan added the from:Meta PR from Meta label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:Meta PR from Meta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants