Skip to content

Instantly share code, notes, and snippets.

@okram
Created October 28, 2011 19:04
Show Gist options
  • Save okram/1323134 to your computer and use it in GitHub Desktop.
Save okram/1323134 to your computer and use it in GitHub Desktop.
public static Iterator<Long> evaluateQuery(final IndexableGraph g, final String userName, final String savName, Long startDate, Long endDate) {
if (endDate == -1l) {
endDate = Long.MAX_VALUE;
}
final Vertex root = g.idx(T.v)[[share_id: 2l]] >> 1;
final Vertex user = g.idx(T.v)[[user_name: userName]] >> 1;
return root.out('contains').loop(1) {it.loops < 3}.out('hasUser').retain([user]).back(2).
out('contains').loop(1) {it.loops < 5}.out('hasSav').
out('hasProperty').filter {it.getProperty('_type') == 'sav_name'}.filter {it.getProperty('value') == savName}.
filter {it.getProperty('_startDate') >= startDate && it.getProperty('_endDate') <= endDate}.back(4).sav_id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment