Compare commits
3 Commits
v0.0.3
...
738de01cb4
Author | SHA1 | Date | |
---|---|---|---|
738de01cb4 | |||
325cab6a95 | |||
0b2821941a |
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.18)
|
cmake_minimum_required(VERSION 3.18)
|
||||||
project(
|
project(
|
||||||
conflict-set
|
conflict-set
|
||||||
VERSION 0.0.3
|
VERSION 0.0.4
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
"A data structure for optimistic concurrency control on ranges of bitwise-lexicographically-ordered keys."
|
"A data structure for optimistic concurrency control on ranges of bitwise-lexicographically-ordered keys."
|
||||||
HOMEPAGE_URL "https://git.weaselab.dev/weaselab/conflict-set"
|
HOMEPAGE_URL "https://git.weaselab.dev/weaselab/conflict-set"
|
||||||
|
@@ -58,6 +58,9 @@ _lib.ConflictSet_setOldestVersion.argtypes = (ctypes.c_void_p, ctypes.c_int64)
|
|||||||
|
|
||||||
_lib.ConflictSet_destroy.argtypes = (ctypes.c_void_p,)
|
_lib.ConflictSet_destroy.argtypes = (ctypes.c_void_p,)
|
||||||
|
|
||||||
|
_lib.ConflictSet_getBytes.argtypes = (ctypes.c_void_p,)
|
||||||
|
_lib.ConflictSet_getBytes.restype = ctypes.c_int64
|
||||||
|
|
||||||
|
|
||||||
class Result(enum.Enum):
|
class Result(enum.Enum):
|
||||||
COMMIT = 0
|
COMMIT = 0
|
||||||
@@ -106,6 +109,9 @@ class ConflictSet:
|
|||||||
def setOldestVersion(self, version: int) -> None:
|
def setOldestVersion(self, version: int) -> None:
|
||||||
_lib.ConflictSet_setOldestVersion(self.p, version)
|
_lib.ConflictSet_setOldestVersion(self.p, version)
|
||||||
|
|
||||||
|
def getBytes(self) -> int:
|
||||||
|
return _lib.ConflictSet_getBytes(self.p)
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ SRC_DIR="${0%/*}"
|
|||||||
BUILD_ARM="$(mktemp -d -t conflict-set-arm)"
|
BUILD_ARM="$(mktemp -d -t conflict-set-arm)"
|
||||||
BUILD_X86="$(mktemp -d -t conflict-set-x86)"
|
BUILD_X86="$(mktemp -d -t conflict-set-x86)"
|
||||||
|
|
||||||
cmake_args=(-DCMAKE_CXX_FLAGS=-DNVALGRIND -DCPACK_PACKAGING_INSTALL_PREFIX=/usr/local)
|
cmake_args=(-DCMAKE_CXX_FLAGS=-DNVALGRIND -DCPACK_PACKAGING_INSTALL_PREFIX=/usr/local -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0)
|
||||||
|
|
||||||
cmake -S"$SRC_DIR" -B"$BUILD_ARM" -DCMAKE_OSX_ARCHITECTURES=arm64 "${cmake_args[@]}"
|
cmake -S"$SRC_DIR" -B"$BUILD_ARM" -DCMAKE_OSX_ARCHITECTURES=arm64 "${cmake_args[@]}"
|
||||||
cmake --build "$BUILD_ARM" --target conflict-set --target conflict-set-static
|
cmake --build "$BUILD_ARM" --target conflict-set --target conflict-set-static
|
||||||
|
@@ -3,7 +3,10 @@ from conflict_set import *
|
|||||||
|
|
||||||
def test_conflict_set():
|
def test_conflict_set():
|
||||||
with ConflictSet() as cs:
|
with ConflictSet() as cs:
|
||||||
cs.addWrites(1, write(b""))
|
before = cs.getBytes()
|
||||||
assert cs.check(read(0, b"")) == [Result.CONFLICT]
|
key = b"a key"
|
||||||
|
cs.addWrites(1, write(key))
|
||||||
|
assert cs.getBytes() - before > 0
|
||||||
|
assert cs.check(read(0, key)) == [Result.CONFLICT]
|
||||||
cs.setOldestVersion(1)
|
cs.setOldestVersion(1)
|
||||||
assert cs.check(read(0, b"")) == [Result.TOO_OLD]
|
assert cs.check(read(0, key)) == [Result.TOO_OLD]
|
||||||
|
Reference in New Issue
Block a user