MCPcopy Create free account
hub / github.com/questdb/questdb / getIPv4Subnet

Method getIPv4Subnet

core/src/main/java/io/questdb/std/Numbers.java:882–903  ·  view source on GitHub ↗
(CharSequence sequence)

Source from the content-addressed store, hash-verified

880 // returns net addr + netmask in a single long value
881 // throws NumericException on error
882 public static long getIPv4Subnet(CharSequence sequence) throws NumericException {
883 int netmask = getIPv4Netmask(sequence);
884 if (netmask == BAD_NETMASK) {
885 throw NumericException.instance().put("invalid netmask in IPv4 subnet: ").put(sequence);
886 }
887
888 int mid = Chars.indexOf(sequence, 0, '/');
889
890 try {
891 if (mid == -1) { // no netmask
892 return pack(parseIPv4(sequence), netmask);
893 }
894
895 int ipv4 = parseIPv4_0(sequence, 0, mid);
896 return pack(ipv4, netmask);
897 } catch (NumericException e) {
898 if (mid == -1) {
899 throw NumericException.instance().put("invalid IPv4 subnet format, expected format: x.x.x.x/mask, got: ").put(sequence);
900 }
901 return pack(parseSubnet0(sequence, 0, mid, getNetmaskLength(netmask)), netmask);
902 }
903 }
904
905 /**
906 * Returns the maximum value for a specific precision.

Callers 12

testGetIPv4SubnetMethod · 0.95
getBroadcastAddressMethod · 0.95
containsIPv4StrMethod · 0.80
containsIPv4VarcharMethod · 0.80
initMethod · 0.80
getBoolMethod · 0.80
getBoolMethod · 0.80
containsIPv4StrMethod · 0.80
containsIPv4VarcharMethod · 0.80
initMethod · 0.80
getBoolMethod · 0.80
getBoolMethod · 0.80

Calls 9

getIPv4NetmaskMethod · 0.95
instanceMethod · 0.95
indexOfMethod · 0.95
packMethod · 0.95
parseIPv4Method · 0.95
parseIPv4_0Method · 0.95
parseSubnet0Method · 0.95
getNetmaskLengthMethod · 0.95
putMethod · 0.65

Tested by 1

testGetIPv4SubnetMethod · 0.76