예제 #1
0
파일: query.py 프로젝트: skvrahul/dagoba
    def _filter(graph, args: Args, gremlin, state):
        if not gremlin:
            return 'pull'

        # Filter query is a property dictionary
        if isinstance(args.get(0), dict):
            return gremlin if gremlin.vertex.matches(args.get(0)) else 'pull'
        # Filter query is a function or lambda
        elif callable(args.get(0)):
            filter_func = args.get(0)
            return gremlin if filter_func(gremlin.vertex) else 'pull'
        # Unsupported filter type
        else:
            Core.error("Unrecognized filter query:" + str(type(args.get(0))))
            return gremlin
예제 #2
0
파일: query.py 프로젝트: skvrahul/dagoba
 def _as(graph, args: Args, gremlin, state):
     if not gremlin:
         # No gremlin. Try to get one
         return 'pull'
     if gremlin.state.alias is None:
         gremlins.state.alias = {}
     gremlin.state.alias[args.get(0)] = gremlin.vertex
     return gremlin
예제 #3
0
파일: query.py 프로젝트: skvrahul/dagoba
 def _property(graph, args: Args, gremlin: Gremlin, state):
     if not gremlin:
         return 'pull'
     gremlin.result = gremlin.vertex.getProperty(args.get(0))
     if gremlin.result is not None:
         return gremlin
     else:
         return False
예제 #4
0
파일: query.py 프로젝트: skvrahul/dagoba
    def _take(graph, args: Args, gremlin, state):
        state.num_taken = state.num_taken or 0
        if state.num_taken == args.get(0):
            state.num_taken = 0
            return 'done'

        if not gremlin:
            return 'pull'

        state.num_taken += 1
        return gremlin
예제 #5
0
파일: query.py 프로젝트: skvrahul/dagoba
    def _in(graph, args: Args, gremlin, state):
        state_has_no_edges = state.edges is None or len(state.edges) == 0
        if gremlin is None and state_has_no_edges:
            return 'pull'

        if state_has_no_edges:
            state.gremlin = gremlin
            state.edges = graph.findInEdges(gremlin.vertex).filter(Core.filterEdges(args.get(0)))

        if len(state.edges) == 0:
            return 'pull'

        vertex = state.edges.pop()._in
        return Gremlin(vertex, gremlin.state)       # Return a Gremlin sitting on the vertex
예제 #6
0
파일: query.py 프로젝트: skvrahul/dagoba
    def _out(graph, args: Args, gremlin, state):
        state_has_no_edges = state.edges is None or len(state.edges) == 0
        if not gremlin and state_has_no_edges:
            return 'pull'

        if state_has_no_edges:
            state.gremlin = gremlin
            out_edges = graph.findOutEdges(gremlin.vertex)
            state.edges = list(filter(Core.filterEdges(args.get(0)), out_edges))

        if len(state.edges) == 0:
            return 'pull'

        vertex = state.edges.pop()._out

        if gremlin:
            return Gremlin(vertex, gremlin.state)       # Return a Gremlin sitting on the vertex
        else:
            return Gremlin(vertex, None)
예제 #7
0
파일: query.py 프로젝트: skvrahul/dagoba
 def _func(self, *args):
     args_ob = Args.from_tuple(args=args)
     return self.add(pipetype=name, args=args_ob)