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
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
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)
def createdAtLeast(cls, *args): return cls.graph_traversal(None, None, Bytecode()).createdAtLeast(*args)
def youngestFriendsAge(cls, *args): return cls.graph_traversal(None, None, Bytecode()).youngestFriendsAge(*args)
def knows(cls, *args): return cls.graph_traversal(None, None, Bytecode()).knows(*args)
def ensure(cls, *args): return cls.graph_traversal(None, None, Bytecode()).ensure(*args)
def actor(cls, *args): return cls.graph_traversal(None, None, Bytecode()).actor(*args)
def person(cls, *args): return cls.graph_traversal(None, None, Bytecode()).person(*args)
def recommend(cls, *args): return cls.graph_traversal(None, None, Bytecode()).recommend(*args)
def by_ages(cls, *args): return cls.graph_traversal(None, None, Bytecode()).by_ages(*args)
def genre(cls, *args): return cls.graph_traversal(None, None, Bytecode()).genre(*args)
def ratings(cls): return cls.graph_traversal(None, None, Bytecode()).ratings()
def actors(cls): return cls.graph_traversal(None, None, Bytecode()).actors()
def agent(cls, *args): return cls.graph_traversal(None, None, Bytecode().agent(*args))