metadata separation
This commit is contained in:
parent
20434aa835
commit
dadd73ad32
@ -1,8 +1,9 @@
|
||||
import abc
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.collection.comparison import *
|
||||
from rainbowadn.core import *
|
||||
from .binarycreation import *
|
||||
from .binarymetadata import *
|
||||
from .binaryprotocolized import *
|
||||
|
||||
__all__ = ('BinaryBalancing',)
|
||||
@ -12,32 +13,16 @@ ActiveKeyType = TypeVar('ActiveKeyType')
|
||||
MetaDataType = TypeVar('MetaDataType')
|
||||
|
||||
|
||||
class BinaryBalancing(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
||||
class BinaryBalancing(
|
||||
BinaryMetadata[ActiveKeyType, MetaDataType, TreeType],
|
||||
Generic[ActiveKeyType, MetaDataType, TreeType],
|
||||
abc.ABC
|
||||
):
|
||||
def __init__(self, comparator_: Comparator[ActiveKeyType], empty_metadata: HashPoint[MetaDataType]):
|
||||
assert isinstance(comparator_, Comparator)
|
||||
assert isinstance(empty_metadata, HashPoint)
|
||||
self.comparator = comparator_
|
||||
self.empty_metadata = empty_metadata
|
||||
|
||||
async def metadata(
|
||||
self,
|
||||
treel: TreeType,
|
||||
treer: TreeType,
|
||||
key: HashPoint[ActiveKeyType],
|
||||
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
||||
) -> HashPoint[MetaDataType]:
|
||||
raise NotImplementedError
|
||||
|
||||
async def verify_metadata(
|
||||
self,
|
||||
treel: TreeType,
|
||||
treer: TreeType,
|
||||
key: HashPoint[ActiveKeyType],
|
||||
metadata: HashPoint[MetaDataType],
|
||||
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
||||
) -> bool:
|
||||
assert_eq(await self.metadata(treel, treer, key, creation), metadata)
|
||||
return True
|
||||
super().__init__(empty_metadata)
|
||||
|
||||
async def balance(
|
||||
self,
|
||||
|
36
rainbowadn/collection/trees/binary/core/binarymetadata.py
Normal file
36
rainbowadn/collection/trees/binary/core/binarymetadata.py
Normal file
@ -0,0 +1,36 @@
|
||||
from typing import Generic, TypeVar
|
||||
|
||||
from rainbowadn.core import *
|
||||
from .binarycreation import *
|
||||
|
||||
__all__ = ('BinaryMetadata',)
|
||||
|
||||
TreeType = TypeVar('TreeType')
|
||||
ActiveKeyType = TypeVar('ActiveKeyType')
|
||||
MetaDataType = TypeVar('MetaDataType')
|
||||
|
||||
|
||||
class BinaryMetadata(Generic[ActiveKeyType, MetaDataType, TreeType]):
|
||||
def __init__(self, empty_metadata: HashPoint[MetaDataType]):
|
||||
assert isinstance(empty_metadata, HashPoint)
|
||||
self.empty_metadata = empty_metadata
|
||||
|
||||
async def metadata(
|
||||
self,
|
||||
treel: TreeType,
|
||||
treer: TreeType,
|
||||
key: HashPoint[ActiveKeyType],
|
||||
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
||||
) -> HashPoint[MetaDataType]:
|
||||
raise NotImplementedError
|
||||
|
||||
async def verify_metadata(
|
||||
self,
|
||||
treel: TreeType,
|
||||
treer: TreeType,
|
||||
key: HashPoint[ActiveKeyType],
|
||||
metadata: HashPoint[MetaDataType],
|
||||
creation: BinaryCreation[ActiveKeyType, MetaDataType, TreeType],
|
||||
) -> bool:
|
||||
assert_eq(await self.metadata(treel, treer, key, creation), metadata)
|
||||
return True
|
Loading…
Reference in New Issue
Block a user