Last active
May 8, 2021 16:33
-
-
Save samueleresca/96c54636ecfca06e5bb551d8c03f6c8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Original code available at: https://github.com/mwhittaker/quoracle | |
""" | |
class Node(Expr[T]): | |
def __init__(self, | |
x: T, | |
capacity: Optional[float] = None, | |
read_capacity: Optional[float] = None, | |
write_capacity: Optional[float] = None, | |
latency: datetime.timedelta = None) -> None: | |
self.x = x | |
# A user either specifies capacity or (read_capacity and | |
# write_capacity), but not both. | |
if (capacity is None and | |
read_capacity is None and | |
write_capacity is None): | |
self.read_capacity = 1.0 | |
self.write_capacity = 1.0 | |
elif (capacity is not None and | |
read_capacity is None and | |
write_capacity is None): | |
self.read_capacity = capacity | |
self.write_capacity = capacity | |
elif (capacity is None and | |
read_capacity is not None and | |
write_capacity is not None): | |
self.read_capacity = read_capacity | |
self.write_capacity = write_capacity | |
else: | |
raise ValueError('You must specify capacity or (read_capacity ' | |
'and write_capacity)') | |
if latency is None: | |
self.latency = datetime.timedelta(seconds=1) | |
else: | |
self.latency = latency |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment