Beispiel #1
0
    async def iter_values(
        self,
        start: Key = Key(0),
        end: Optional[Key] = None,
    ) -> AsyncIterator[SGNodeAPI]:
        if end is None:
            direction = RIGHT
        elif end < start:
            direction = LEFT
        elif end >= start:
            direction = RIGHT
        else:
            raise Exception("Invariant")

        left, node, right = await self.find(start)
        if node is not None:
            cursor = node
        elif direction is RIGHT:
            cursor = right
        elif direction is LEFT:
            cursor = left
        else:
            raise Exception("Invariant")

        while cursor is not None:
            if end is not None and not direction.comparison_fn(
                    end, cursor.key):
                break
            await trio.hazmat.checkpoint()
            yield cursor

            cursor = await self._get_neighbor(cursor, 0, direction)
Beispiel #2
0
 async def iter_items(
     self,
     start: Key = Key(0),
     end: Optional[Key] = None,
 ) -> AsyncIterator[Tuple[Key, SGNodeAPI]]:
     async for node in self.iter_values(start, end):
         yield node.key, node
Beispiel #3
0
 async def iter_keys(
     self,
     start: Key = Key(0),
     end: Optional[Key] = None,
 ) -> AsyncIterator[Key]:
     async for node in self.iter_values(start, end):
         yield node.key
Beispiel #4
0
def content_key_to_graph_key(key: bytes) -> Key:
    return Key(big_endian_to_int(key))
Beispiel #5
0
 def iter_items(
         self,
         start: Key = Key(0),
         end: Optional[Key] = None) -> AsyncIterator[Tuple[Key, SGNodeAPI]]:
     ...
Beispiel #6
0
 def iter_values(self,
                 start: Key = Key(0),
                 end: Optional[Key] = None) -> AsyncIterator[SGNodeAPI]:
     ...
Beispiel #7
0
 def iter_keys(self,
               start: Key = Key(0),
               end: Optional[Key] = None) -> AsyncIterator[Key]:
     ...