示例#1
0
 def vertex_property(self, id, name, value):
     self._add_req(vertex_property=proto.VertexPropertyBulkInsertItem(
         id=proto.Uuid(value=id.bytes),
         name=proto.Identifier(value=name),
         value=proto.Json(value=json.dumps(value)),
     ))
     return self
示例#2
0
 def edge_property(self, key, name, value):
     self._add_req(edge_property=proto.EdgePropertyBulkInsertItem(
         key=key.to_message(),
         name=proto.Identifier(value=name),
         value=proto.Json(value=json.dumps(value)),
     ))
     return self
示例#3
0
 def to_message(self):
     return proto.VertexQuery(range=proto.RangeVertexQuery(
         limit=self._limit,
         t=proto.Identifier(value=self._t) if self._t is not None else None,
         start_id=proto.Uuid(value=self._start_id.bytes)
         if self._start_id is not None else None,
     ), )
示例#4
0
 def to_message(self):
     return proto.VertexQuery(pipe=proto.PipeVertexQuery(
         inner=self._inner.to_message(),
         direction=self._direction.value,
         limit=self._limit,
         t=proto.Identifier(value=self._t) if self._t is not None else None,
     ), )
示例#5
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PropertyValueVertexQuery(
         inner=self._inner.to_message(),
         name=proto.Identifier(value=self._name),
         value=json.dumps(self._value),
         equal=self._equal,
     ), )
示例#6
0
    def create_vertex_from_type(self, t):
        """
        Creates a new vertex from a type.

        `t` specifies the new vertex's type.
        """
        req = proto.Identifier(value=t)
        res = self.stub.CreateVertexFromType(req)
        return uuid.UUID(bytes=res.value)
示例#7
0
    def get_edge_count(self, id, t, direction):
        """
        Gets the number of edges related to a vertex.

        `id` specifies the ID of the vertex. `t` specifies which
        type of edges to count - set this to `None` if all edges should be
        counted. `direction` specifies the direction of edges to count.
        """
        req = proto.GetEdgeCountRequest(
            id=proto.Uuid(value=id.bytes),
            t=proto.Identifier(value=t) if t is not None else None,
            direction=direction.value,
        )
        return self.stub.GetEdgeCount(req).count
示例#8
0
    def to_message(self):
        high = None
        if self._high is not None:
            high = proto.google_dot_protobuf_dot_timestamp__pb2.Timestamp()
            high.FromDatetime(self._high)

        low = None
        if self._low is not None:
            low = proto.google_dot_protobuf_dot_timestamp__pb2.Timestamp()
            low.FromDatetime(self._low)

        return proto.EdgeQuery(pipe=proto.PipeEdgeQuery(
            inner=self._inner.to_message(),
            direction=self._direction.value,
            t=proto.Identifier(value=self._t) if self._t is not None else None,
            high=high,
            low=low,
            limit=self._limit,
        ), )
示例#9
0
 def index_property(self, name):
     req = proto.IndexPropertyRequest(name=proto.Identifier(value=name))
     return self.stub.IndexProperty(req)
示例#10
0
 def to_message(self):
     return proto.EdgeKey(
         outbound_id=proto.Uuid(value=self.outbound_id.bytes),
         t=proto.Identifier(value=self.t),
         inbound_id=proto.Uuid(value=self.inbound_id.bytes),
     )
示例#11
0
 def to_message(self):
     return proto.EdgePropertyQuery(
         inner=self._inner.to_message(),
         name=proto.Identifier(value=self._name),
     )
示例#12
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PipePropertyPresenceVertexQuery(
         inner=self._inner.to_message(),
         name=proto.Identifier(value=self._name),
         exists=self._exists,
     ), )
示例#13
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PropertyValueVertexQuery(
         name=proto.Identifier(value=self._name),
         value=json.dumps(self._value),
     ), )
示例#14
0
 def to_message(self):
     return proto.VertexQuery(range=proto.PropertyPresenceVertexQuery(
         name=proto.Identifier(value=self._name), ), )
示例#15
0
 def to_message(self):
     return proto.Vertex(
         id=proto.Uuid(value=self.id.bytes),
         t=proto.Identifier(value=self.t),
     )