Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 4
0
def content_key_to_graph_key(key: bytes) -> Key:
    return Key(big_endian_to_int(key))
Ejemplo n.º 5
0
 def iter_items(
         self,
         start: Key = Key(0),
         end: Optional[Key] = None) -> AsyncIterator[Tuple[Key, SGNodeAPI]]:
     ...
Ejemplo n.º 6
0
 def iter_values(self,
                 start: Key = Key(0),
                 end: Optional[Key] = None) -> AsyncIterator[SGNodeAPI]:
     ...
Ejemplo n.º 7
0
 def iter_keys(self,
               start: Key = Key(0),
               end: Optional[Key] = None) -> AsyncIterator[Key]:
     ...