Bitwise operators in Gremlin

109 views Asked by At

Does Gremlin supports bitwise operators in where() (like property & flag > 0)? Maybe something like where(bitIsSet('property', 2)).

Could not find anything about that in apache docs but it feels at least strange that this basic operation would not be implemented in Gremlin.

1

There are 1 answers

0
stephen mallette On BEST ANSWER

No - there are no such steps that behave like a bitwise operator in Gremlin. You could of course use a lambda should your graph support such things (though CosmosDB does not):

gremlin> g.inject([a:-1,b:-1]).filter{(it.get().a & it.get().b) > 0}
gremlin> g.inject([a:00111100,b:00001101]).filter{(it.get().a & it.get().b) > 0}
==>[a:37440,b:577]

it feels at least strange that this basic operation would not be implemented in Gremlin.

Yes - I suppose it's simple but I don't think I've ever heard anyone ask for that functionality since the inception of the project. Gremlin is also missing some other important operators like basic string concatenation and date operations - those have definitely be requested.