Spaces:
Running
Running
Download python/sincekit.py from pgg-engineering/sincekit: direct link, hf CLI and curl.
- Browser
- Download file 955 Bytes
-
https://huggingface.co/spaces/pgg-engineering/sincekit/resolve/main/python/sincekit.py
- Command line
-
hf download hf://spaces/pgg-engineering/sincekit/python/sincekit.py
-
curl -L -o sincekit.py https://huggingface.co/spaces/pgg-engineering/sincekit/resolve/main/python/sincekit.py
955 Bytes
| """In-process latest-state changefeed, backed by the native SinceKit index.""" | |
| from collections import namedtuple | |
| import _sincekit | |
| BatchPlan = namedtuple("BatchPlan", ["revision", "rows", "prefix_lengths"]) | |
| class Index: | |
| """A fixed-capacity index of dense integer slots.""" | |
| __slots__ = ("_index",) | |
| def __init__(self, capacity): | |
| self._index = _sincekit.create(capacity) | |
| def capacity(self): | |
| return _sincekit.capacity(self._index) | |
| def revision(self): | |
| return _sincekit.revision(self._index) | |
| def write_many(self, changes): | |
| """Publish (slot_id, deleted_bool) pairs in order and return the revision.""" | |
| return _sincekit.write_many(self._index, tuple(changes)) | |
| def since_many(self, cursors): | |
| """Return an immutable plan with shared rows and a prefix length per cursor.""" | |
| return BatchPlan(*_sincekit.since_many(self._index, tuple(cursors))) | |