class QueryResult(iterable_wrapper(N1QLRequest)):
    def __init__(self,
                 params, parent, **kwargs
                 ):
        # type (...)->None
        super(QueryResult, self).__init__(params, parent, **kwargs)

    def metadata(self  # type: QueryResult
                 ):
        # type: (...) -> QueryMetaData
        return QueryMetaData(self)

    def _respond_to_timedelta(self, conv_query):
        first_entry = next(iter(conv_query), None)
        nanoseconds = first_entry.get('$1', None) if first_entry else None

        if nanoseconds is None:
            raise Exception("Cannot get result from first entry {} of query response {}".format(first_entry, conv_query.rows()))
        return timedelta(seconds=nanoseconds * 1e-9)

    def _duration_as_timedelta(self,
                               metrics_str):
        try:
            conv_query = self._parent.query(r'select str_to_duration("{}");'.format(metrics_str), timeout=timedelta(seconds=5))
            return self._respond_to_timedelta(conv_query)
        except Exception as e:
            raise QueryException.pyexc("Not able to get result in nanoseconds", inner=e)
Пример #2
0
class ViewResult(iterable_wrapper(CoreView)):
    def __init__(
            self,
            *args,
            row_factory=ViewRow,
            **kwargs  # type: CoreView
    ):
        super(ViewResult, self).__init__(*args,
                                         row_factory=row_factory,
                                         **kwargs)

    def metadata(self  # type: ViewResult
                 ):
        # type: (...) -> ViewMetaData
        return ViewMetaData(self)
Пример #3
0
class AnalyticsResult(iterable_wrapper(AnalyticsRequest)):
    def client_context_id(self):
        return super(AnalyticsResult, self).client_context_id()

    def signature(self):
        return super(AnalyticsResult, self).signature()

    def warnings(self):
        return super(AnalyticsResult, self).warnings()

    def request_id(self):
        return super(AnalyticsResult, self).request_id()

    def __init__(self,
                 *args, **kwargs  # type: N1QLRequest
                 ):
        super(AnalyticsResult, self).__init__(*args, **kwargs)
Пример #4
0
class SearchResultMock(search.SearchResultBase,
                       iterable_wrapper(SearchRequestMock)):
    pass
Пример #5
0
class SearchResult(SearchResultBase, iterable_wrapper(SearchRequest)):
    pass