Skip to content

Commit bc63927

Browse files
committed
more chunking renames
1 parent ddb8925 commit bc63927

4 files changed

Lines changed: 21 additions & 19 deletions

File tree

prime_backup/config/backup_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BackupConfig(Serializable):
4747
chunking_enabled: bool = False
4848
chunking_rules: List[ChunkingRule] = [
4949
ChunkingRule(
50-
algorithm=ChunkMethod.cdc_32k,
50+
algorithm=ChunkMethod.fastcdc_32k,
5151
file_size_threshold=100 * 1048576,
5252
patterns=[
5353
'**/*.db'

prime_backup/types/chunk_method.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
from typing import Optional, IO, TYPE_CHECKING
44

55
from prime_backup.types.chunker import Chunker
6-
from prime_backup.types.chunker_definition import ChunkerDefinition, CDCChunkerDefinition, FixedSizeChunkerDefinition
6+
from prime_backup.types.chunker_definition import ChunkerDefinition, FastCDCChunkerDefinition, FixedSizeChunkerDefinition
77
from prime_backup.utils.path_like import PathLike
88

99

1010
class ChunkMethod(enum.Enum):
11-
# Content-Defined Chunking (CDC)
12-
cdc_32k = CDCChunkerDefinition(avg_size=32 * 1024, min_size=8 * 1024, max_size=256 * 1024)
13-
cdc_128k = CDCChunkerDefinition(avg_size=128 * 1024, min_size=64 * 1024, max_size=1024 * 1024)
14-
cdc = cdc_32k
11+
# Content-Defined Chunking with FastCDC
12+
fastcdc_32k = FastCDCChunkerDefinition(avg_size=32 * 1024, min_size=8 * 1024, max_size=256 * 1024)
13+
fastcdc_128k = FastCDCChunkerDefinition(avg_size=128 * 1024, min_size=64 * 1024, max_size=1024 * 1024)
1514

1615
# Fixed-Size Chunking
1716
fixed_4k = FixedSizeChunkerDefinition(4 * 1024)
1817
fixed_32k = FixedSizeChunkerDefinition(32 * 1024)
1918
fixed_128k = FixedSizeChunkerDefinition(128 * 1024)
2019

20+
# Common Alias
21+
cdc = fastcdc_32k
22+
2123
if TYPE_CHECKING:
2224
value: ChunkerDefinition
2325

prime_backup/types/chunker.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,17 @@ def get_read_file_size(self) -> int:
8282
return self.__file_size_sum
8383

8484

85-
# ======================== CDC Chunker ========================
85+
# ======================== FastCDC Chunker ========================
8686

8787
@dataclasses.dataclass(frozen=True)
88-
class CDCChunkerConfig:
88+
class FastCDCChunkerConfig:
8989
avg_size: int
9090
min_size: int
9191
max_size: int
9292

9393

9494
class _CDCChunker(Chunker, ABC):
95-
def __init__(self, cfg: CDCChunkerConfig, need_entire_file_hash: bool):
95+
def __init__(self, cfg: FastCDCChunkerConfig, need_entire_file_hash: bool):
9696
super().__init__(need_entire_file_hash)
9797
self.cfg = cfg
9898

@@ -107,8 +107,8 @@ def _create_cdc_engine(self) -> 'pyfastcdc.FastCDC':
107107
)
108108

109109

110-
class CDCFileChunker(_CDCChunker):
111-
def __init__(self, cfg: CDCChunkerConfig, file_path: Path, need_entire_file_hash: bool = False):
110+
class FastCDCFileChunker(_CDCChunker):
111+
def __init__(self, cfg: FastCDCChunkerConfig, file_path: Path, need_entire_file_hash: bool = False):
112112
super().__init__(cfg, need_entire_file_hash)
113113
self.file_path = file_path
114114

@@ -119,8 +119,8 @@ def _iter_raw_chunks(self) -> Iterable[_RawChunk]:
119119
yield _RawChunk(offset=c.offset, length=c.length, data=c.data)
120120

121121

122-
class CDCStreamChunker(_CDCChunker):
123-
def __init__(self, cfg: CDCChunkerConfig, stream: 'pyfastcdc.BinaryStreamReader', need_entire_file_hash: bool = False):
122+
class FastCDCStreamChunker(_CDCChunker):
123+
def __init__(self, cfg: FastCDCChunkerConfig, stream: 'pyfastcdc.BinaryStreamReader', need_entire_file_hash: bool = False):
124124
super().__init__(cfg, need_entire_file_hash)
125125
self.stream = stream
126126

prime_backup/types/chunker_definition.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from typing_extensions import override
77

8-
from prime_backup.types.chunker import Chunker, CDCFileChunker, CDCStreamChunker, FixedSizeFileChunker, FixedSizeStreamChunker, CDCChunkerConfig
8+
from prime_backup.types.chunker import Chunker, FastCDCFileChunker, FastCDCStreamChunker, FixedSizeFileChunker, FixedSizeStreamChunker, FastCDCChunkerConfig
99

1010

1111
class ChunkerDefinition(ABC):
@@ -19,22 +19,22 @@ def create_stream_chunker(self, stream, need_entire_file_hash: bool) -> Chunker:
1919

2020

2121
@dataclasses.dataclass(frozen=True)
22-
class CDCChunkerDefinition(ChunkerDefinition):
22+
class FastCDCChunkerDefinition(ChunkerDefinition):
2323
avg_size: int
2424
min_size: int
2525
max_size: int
26-
_config: CDCChunkerConfig = dataclasses.field(init=False, repr=False, compare=False)
26+
_config: FastCDCChunkerConfig = dataclasses.field(init=False, repr=False, compare=False)
2727

2828
def __post_init__(self):
29-
object.__setattr__(self, '_config', CDCChunkerConfig(self.avg_size, self.min_size, self.max_size))
29+
object.__setattr__(self, '_config', FastCDCChunkerConfig(self.avg_size, self.min_size, self.max_size))
3030

3131
@override
3232
def create_file_chunker(self, file_path: Path, need_entire_file_hash: bool) -> Chunker:
33-
return CDCFileChunker(self._config, file_path, need_entire_file_hash)
33+
return FastCDCFileChunker(self._config, file_path, need_entire_file_hash)
3434

3535
@override
3636
def create_stream_chunker(self, stream: IO[bytes], need_entire_file_hash: bool) -> Chunker:
37-
return CDCStreamChunker(self._config, stream, need_entire_file_hash)
37+
return FastCDCStreamChunker(self._config, stream, need_entire_file_hash)
3838

3939

4040
@dataclasses.dataclass(frozen=True)

0 commit comments

Comments
 (0)