I have a set of vertices that contain a property Ip which is declared as String.
I want to check if this IP is inside a CIDR block or within IP ranges.
Is there a way to convert String up attribute to a number so that I can perform the operation.
Gremlin today does not have String manipulation steps and operators so you cannot do things like convert Strings to Integers or split and concatenate Strings. It does however have a math
step.
I see two options:
Store the IP as a list of 4 numbers or as four individual properties.
Use in-line code (lambdas) to do the work. However many graph DBs do not allow in-line lambda code and in general it is not recommended as a best practice.
If you were able to store the values as a list or as four properties you could then use the math
step to convert the four bytes into a single decimal number and compare with other numbers.
In the short term, it might be better to store IP addresses as simple 4-byte integer values to make the comparisons easier.