Skip to content

Commit

Permalink
use abcs plus implementation notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamman committed Nov 3, 2023
1 parent c3f8764 commit 0864187
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 211 deletions.
10 changes: 10 additions & 0 deletions zarr/v3/abc/codec.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Notes:
# 1. These are missing methods described in the spec. I expected to see these method definitions:
# def compute_encoded_representation_type(self, decoded_representation_type):
# def encode(self, decoded_value):
# def decode(self, encoded_value, decoded_representation_type):
# def partial_decode(self, input_handle, decoded_representation_type, decoded_regions):
# def compute_encoded_size(self, input_size):
# 2. Understand why array metadata is included on all codecs


from __future__ import annotations

from abc import abstractmethod, ABC
Expand Down
14 changes: 7 additions & 7 deletions zarr/v3/abc/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Store(ABC):

class ReadStore(Store):
@abstractmethod
def get(self, key: str) -> bytes:
async def get(self, key: str) -> bytes:
"""Retrieve the value associated with a given key.
Parameters
Expand All @@ -23,7 +23,7 @@ def get(self, key: str) -> bytes:
...

@abstractmethod
def get_partial_values(self, key_ranges: List[Tuple[str, int]]) -> bytes:
async def get_partial_values(self, key_ranges: List[Tuple[str, int]]) -> bytes:
"""Retrieve possibly partial values from given key_ranges.
Parameters
Expand All @@ -41,7 +41,7 @@ def get_partial_values(self, key_ranges: List[Tuple[str, int]]) -> bytes:

class WriteStore(ReadStore):
@abstractmethod
def set(self, key: str, value: bytes) -> None:
async def set(self, key: str, value: bytes) -> None:
"""Store a (key, value) pair.
Parameters
Expand All @@ -52,7 +52,7 @@ def set(self, key: str, value: bytes) -> None:
...

@abstractmethod
def set_partial_values(self, key_start_values: List[Tuple[str, int, bytes]]) -> None:
async def set_partial_values(self, key_start_values: List[Tuple[str, int, bytes]]) -> None:
"""Store values at a given key, starting at byte range_start.
Parameters
Expand All @@ -67,7 +67,7 @@ def set_partial_values(self, key_start_values: List[Tuple[str, int, bytes]]) ->

class ListMixin:
@abstractmethod
def list(self) -> List[str]:
async def list(self) -> List[str]:
"""Retrieve all keys in the store.
Returns
Expand All @@ -77,7 +77,7 @@ def list(self) -> List[str]:
...

@abstractmethod
def list_prefix(self, prefix: str) -> List[str]:
async def list_prefix(self, prefix: str) -> List[str]:
"""Retrieve all keys in the store.
Parameters
Expand All @@ -91,7 +91,7 @@ def list_prefix(self, prefix: str) -> List[str]:
...

@abstractmethod
def list_dir(self, prefix: str) -> List[str]:
async def list_dir(self, prefix: str) -> List[str]:
"""
Retrieve all keys and prefixes with a given prefix and which do not contain the character
“/” after the given prefix.
Expand Down
Loading

0 comments on commit 0864187

Please sign in to comment.