Esempio n. 1
0
 def test_block_uid_to_key(self):
     for i in range(100):
         block_uid = BlockUid(random.randint(1, pow(2, 32) - 1), random.randint(1, pow(2, 32) - 1))
         key = block_uid.storage_object_to_path()
         block_uid_2 = BlockUid.storage_path_to_object(key)
         self.assertEqual(block_uid, block_uid_2)
         self.assertEqual(block_uid.left, block_uid_2.left)
         self.assertEqual(block_uid.right, block_uid_2.right)
Esempio n. 2
0
 def list_blocks(self) -> Iterable[BlockUid]:
     keys = self._list_objects(BlockUid.storage_prefix())
     for key in keys:
         assert isinstance(key, str)
         if key.endswith(self._META_SUFFIX):
             continue
         try:
             yield cast(BlockUid, BlockUid.storage_path_to_object(key))
         except (RuntimeError, ValueError):
             # Ignore any keys which don't match our pattern to account for stray objects/files
             pass
Esempio n. 3
0
 def list_blocks(self) -> List[BlockUid]:
     keys = self._list_objects(BlockUid.storage_prefix())
     block_uids: List[BlockUid] = []
     for key in keys:
         if key.endswith(self._META_SUFFIX):
             continue
         try:
             block_uids.append(
                 cast(BlockUid, BlockUid.storage_path_to_object(key)))
         except (RuntimeError, ValueError):
             # Ignore any keys which don't match our pattern to account for stray objects/files
             pass
     return block_uids