Exemplo n.º 1
0
    def _read_bytecode(cls, b, r):
        bytecode = Bytecode()

        step_count = cls.read_int(b)
        ix = 0
        while ix < step_count:
            inst = [r.toObject(b, DataType.string, False)]
            inst_ct = cls.read_int(b)
            iy = 0
            while iy < inst_ct:
                inst.append(r.readObject(b))
                iy += 1
            bytecode.step_instructions.append(inst)
            ix += 1

        source_count = cls.read_int(b)
        ix = 0
        while ix < source_count:
            inst = [r.toObject(b, DataType.string, False)]
            inst_ct = cls.read_int(b)
            iy = 0
            while iy < inst_ct:
                inst.append(r.readObject(b))
                iy += 1
            bytecode.source_instructions.append(inst)
            ix += 1

        return bytecode
Exemplo n.º 2
0
 def test_bytecode(self):
     x = Bytecode()
     x.source_instructions.append(["withStrategies", "SubgraphStrategy"])
     x.step_instructions.append(["V", 1, 2, 3])
     x.step_instructions.append(["out"])
     output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
     assert x == output
Exemplo n.º 3
0
def append_traversal(g: Traversal,
                     *traversals: Optional[Traversal]) -> GraphTraversal:
    """
    copy the traversal, and append the traversals to it.  (It's a little magic, but common-ish in the gremlin world
    forums.)
    """
    bytecode = Bytecode(bytecode=g.bytecode)
    for t in [t for t in traversals if t is not None]:
        assert t.graph is None, f'traversal has a graph source!  should be an anonymous traversal: {t}'
        for source_name, *source_args in t.bytecode.source_instructions:
            bytecode.add_source(source_name, *source_args)
        for step_name, *step_args in t.bytecode.step_instructions:
            bytecode.add_step(step_name, *step_args)
    return GraphTraversal(graph=g.graph,
                          traversal_strategies=g.traversal_strategies,
                          bytecode=bytecode)
Exemplo n.º 4
0
 def createdAtLeast(cls, *args):
     return cls.graph_traversal(None, None,
                                Bytecode()).createdAtLeast(*args)
Exemplo n.º 5
0
 def youngestFriendsAge(cls, *args):
     return cls.graph_traversal(None, None,
                                Bytecode()).youngestFriendsAge(*args)
Exemplo n.º 6
0
 def knows(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).knows(*args)
Exemplo n.º 7
0
 def ensure(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).ensure(*args)
Exemplo n.º 8
0
 def actor(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).actor(*args)
Exemplo n.º 9
0
 def person(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).person(*args)
Exemplo n.º 10
0
 def recommend(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).recommend(*args)
Exemplo n.º 11
0
 def by_ages(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).by_ages(*args)
Exemplo n.º 12
0
 def genre(cls, *args):
     return cls.graph_traversal(None, None, Bytecode()).genre(*args)
Exemplo n.º 13
0
 def ratings(cls):
     return cls.graph_traversal(None, None, Bytecode()).ratings()
Exemplo n.º 14
0
 def actors(cls):
     return cls.graph_traversal(None, None, Bytecode()).actors()
Exemplo n.º 15
0
 def agent(cls, *args):
     return cls.graph_traversal(None, None, Bytecode().agent(*args))