示例#1
0
 def next(self):
     message = super(RiakHttpIndexStream, self).next()
     payload = json.loads(message.get_payload())
     if u'keys' in payload:
         return payload[u'keys']
     elif u'results' in payload:
         structs = payload[u'results']
         # Format is {"results":[{"2ikey":"primarykey"}, ...]}
         return [self._decode_pair(d.items()[0]) for d in structs]
     elif u'continuation' in payload:
         return CONTINUATION(payload[u'continuation'])
示例#2
0
    def __next__(self):
        response = next(super(RiakPbcIndexStream, self))

        if response.done and not (response.keys or response.results
                                  or response.continuation):
            raise StopIteration

        if self.return_terms and response.results:
            return [(decode_index_value(self.index, r.key), r.value)
                    for r in response.results]
        elif response.keys:
            return response.keys[:]
        elif response.continuation:
            return CONTINUATION(response.continuation)
示例#3
0
    def next(self):
        response = super(PbufIndexStream, self).next()

        if response.done and not (response.keys or response.results
                                  or response.continuation):
            raise StopIteration

        if self.return_terms and response.results:
            return [(decode_index_value(self.index,
                                        r.key), bytes_to_str(r.value))
                    for r in response.results]
        elif response.keys:
            if PY2:
                return response.keys[:]
            else:
                return [bytes_to_str(key) for key in response.keys]
        elif response.continuation:
            return CONTINUATION(bytes_to_str(response.continuation))