Example #1
0
 def undefine(self,
              query: str,
              options: TypeDBOptions = None) -> QueryFuture:
     if not options:
         options = TypeDBOptions.core()
     return self.query_void(
         query_manager_undefine_req(query, options.proto()))
Example #2
0
 def insert(self,
            query: str,
            options: TypeDBOptions = None) -> Iterator[ConceptMap]:
     if not options:
         options = TypeDBOptions.core()
     return (_ConceptMap.of(cm) for rp in self.stream(
         query_manager_insert_req(query, options.proto()))
             for cm in rp.insert_res_part.answers)
Example #3
0
 def match_aggregate(self,
                     query: str,
                     options: TypeDBOptions = None) -> QueryFuture[Numeric]:
     if not options:
         options = TypeDBOptions.core()
     return self.query(
         query_manager_match_aggregate_req(query, options.proto())).map(
             lambda res: _Numeric.of(res.match_aggregate_res.answer))
Example #4
0
 def match_group_aggregate(
         self,
         query: str,
         options: TypeDBOptions = None) -> Iterator[NumericGroup]:
     if not options:
         options = TypeDBOptions.core()
     return (_NumericGroup.of(ng) for rp in self.stream(
         query_manager_match_group_aggregate_req(query, options.proto()))
             for ng in rp.match_group_aggregate_res_part.answers)
Example #5
0
 def match_group(
         self,
         query: str,
         options: TypeDBOptions = None) -> Iterator[ConceptMapGroup]:
     if not options:
         options = TypeDBOptions.core()
     return (_ConceptMapGroup.of(cmg) for rp in self.stream(
         query_manager_match_group_req(query, options.proto()))
             for cmg in rp.match_group_res_part.answers)
Example #6
0
 def explain(self,
             explainable: ConceptMap.Explainable,
             options: TypeDBOptions = None) -> Iterator[Explanation]:
     if not options:
         options = TypeDBOptions.core()
     return (_Explanation.of(ex) for rp in self.stream(
         query_manager_explain_req(explainable.explainable_id(),
                                   options.proto()))
             for ex in rp.explain_res_part.explanations)
Example #7
0
    def __init__(self,
                 client: "_TypeDBClientImpl",
                 database: str,
                 session_type: SessionType,
                 options: TypeDBOptions = None):
        if not options:
            options = TypeDBOptions.core()
        self._client = client
        self._address = client.address()
        self._session_type = session_type
        self._options = options
        self._rw_lock = ReadWriteLock()
        self._database = _TypeDBDatabaseImpl(stub=self._stub(), name=database)

        start_time = time.time() * 1000.0
        res = self._stub().session_open(
            session_open_req(database, session_type.proto(), options.proto()))
        end_time = time.time() * 1000.0
        self._network_latency_millis = int(end_time - start_time -
                                           res.server_duration_millis)
        self._session_id = res.session_id
        self._is_open = AtomicBoolean(True)
Example #8
0
    def __init__(self,
                 session: "_TypeDBSessionImpl",
                 transaction_type: TransactionType,
                 options: TypeDBOptions = None):
        if not options:
            options = TypeDBOptions.core()
        self._transaction_type = transaction_type
        self._options = options
        self._concept_manager = _ConceptManager(self)
        self._query_manager = _QueryManager(self)
        self._logic_manager = _LogicManager(self)

        try:
            self._channel, stub = session.client().new_channel_and_stub()
            self._bidirectional_stream = BidirectionalStream(
                stub, session.transmitter())
            req = transaction_open_req(session.session_id(),
                                       transaction_type.proto(),
                                       options.proto(),
                                       session.network_latency_millis())
            self.execute(request=req, batch=False)
        except RpcError as e:
            raise TypeDBClientException.of_rpc(e)