virtuals-binary-codec 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {virtuals_binary_codec-0.1.0/src/virtuals_binary_codec.egg-info → virtuals_binary_codec-0.1.2}/PKG-INFO +1 -1
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/pyproject.toml +1 -1
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/binary_codec.pyi +4 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/binary_codec.pyx +26 -3
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2/src/virtuals_binary_codec.egg-info}/PKG-INFO +1 -1
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/LICENSE +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/MANIFEST.in +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/README.md +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/setup.cfg +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/setup.py +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/__init__.py +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/exceptions.py +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec.egg-info/SOURCES.txt +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec.egg-info/dependency_links.txt +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec.egg-info/not-zip-safe +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec.egg-info/requires.txt +0 -0
- {virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec.egg-info/top_level.txt +0 -0
|
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
|
|
|
10
10
|
# ============================================================================
|
|
11
11
|
[project]
|
|
12
12
|
name = "virtuals-binary-codec"
|
|
13
|
-
version = "0.1.
|
|
13
|
+
version = "0.1.2"
|
|
14
14
|
description = "Cython-optimized binary key codec for Virtuals."
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
license = "Apache-2.0"
|
|
@@ -12,3 +12,7 @@ class BinaryKeyCodec:
|
|
|
12
12
|
def decode(self, encoded: bytes) -> tuple[str | int, ...]:
|
|
13
13
|
"""Decode binary data back to original tuple key."""
|
|
14
14
|
...
|
|
15
|
+
|
|
16
|
+
def upper_bound_of_prefix(self, key: tuple[str | int, ...]) -> bytes:
|
|
17
|
+
r"""Bytes strictly greater than every child key of ``key`` (``encode(key) + b"\xff"``)."""
|
|
18
|
+
...
|
|
@@ -132,6 +132,11 @@ cdef class BinaryKeyCodec:
|
|
|
132
132
|
- Null bytes in content: 0x00 -> 0x00 0xFF (escaped)
|
|
133
133
|
- Terminator is bare 0x00 (not escaped)
|
|
134
134
|
- This ensures shorter strings sort before longer strings with same prefix
|
|
135
|
+
|
|
136
|
+
Empty strings:
|
|
137
|
+
- "" encodes as 0x02 0x00 and sorts before every other string
|
|
138
|
+
- Unambiguous: a terminator is followed by a type marker (0x01/0x02) or
|
|
139
|
+
the end of the key, never by the escape byte 0xFF
|
|
135
140
|
"""
|
|
136
141
|
|
|
137
142
|
def encode(self, tuple key):
|
|
@@ -180,9 +185,9 @@ cdef class BinaryKeyCodec:
|
|
|
180
185
|
str_data = <const unsigned char*>PyBytes_AS_STRING(str_bytes)
|
|
181
186
|
str_len = PyBytes_GET_SIZE(str_bytes)
|
|
182
187
|
|
|
183
|
-
# Check string length
|
|
184
|
-
|
|
185
|
-
|
|
188
|
+
# Check string length bound. The empty string is legal: it
|
|
189
|
+
# encodes as TYPE_STR + TERMINATOR and sorts before every
|
|
190
|
+
# other string.
|
|
186
191
|
if str_len > MAX_STRING_LENGTH:
|
|
187
192
|
raise EncodeError(
|
|
188
193
|
f"String at index {i} too long: {str_len} bytes "
|
|
@@ -241,6 +246,24 @@ cdef class BinaryKeyCodec:
|
|
|
241
246
|
|
|
242
247
|
return result
|
|
243
248
|
|
|
249
|
+
def upper_bound_of_prefix(self, tuple key):
|
|
250
|
+
"""Encoded bytes strictly greater than every child key of ``key``.
|
|
251
|
+
|
|
252
|
+
Appends ``0xFF`` to ``encode(key)``. The trailing 0xFF sorts strictly
|
|
253
|
+
above every valid segment type marker (``TYPE_INT=0x01``, ``TYPE_STR=0x02``),
|
|
254
|
+
so any child key of the form ``key + (segment,)`` compares less than
|
|
255
|
+
the returned bytes. Used by container-side reverse scans to seed
|
|
256
|
+
``StorageScanOptions.start`` with an inclusive upper bound of the
|
|
257
|
+
child prefix range.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
key: Tuple containing strings and/or integers
|
|
261
|
+
|
|
262
|
+
Returns:
|
|
263
|
+
Binary bytes that sort strictly greater than every child key of ``key``
|
|
264
|
+
"""
|
|
265
|
+
return self.encode(key) + b"\xff"
|
|
266
|
+
|
|
244
267
|
def decode(self, bytes encoded):
|
|
245
268
|
"""Decode binary data back to original tuple key.
|
|
246
269
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/__init__.py
RENAMED
|
File without changes
|
{virtuals_binary_codec-0.1.0 → virtuals_binary_codec-0.1.2}/src/virtuals_binary_codec/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|