Pārlūkot izejas kodu

ChunkIndex: remove .incref method

Thomas Waldmann 9 mēneši atpakaļ
vecāks
revīzija
ddf6812703

+ 0 - 1
src/borg/hashindex.pyi

@@ -38,7 +38,6 @@ class ChunkKeyIterator:
 
 class ChunkIndex(IndexBase):
     def add(self, key: bytes, refs: int, size: int) -> None: ...
-    def incref(self, key: bytes) -> CIE: ...
     def iteritems(self, marker: bytes = ...) -> Iterator: ...
     def merge(self, other_index) -> None: ...
     def stats_against(self, master_index) -> Tuple: ...

+ 0 - 13
src/borg/hashindex.pyx

@@ -394,19 +394,6 @@ cdef class ChunkIndex(IndexBase):
             assert _le32toh(data[0]) <= _MAX_VALUE, "invalid reference count"
         return data != NULL
 
-    def incref(self, key):
-        """Increase refcount for 'key', return (refcount, size)"""
-        assert len(key) == self.key_size
-        data = <uint32_t *>hashindex_get(self.index, <unsigned char *>key)
-        if not data:
-            raise KeyError(key)
-        cdef uint32_t refcount = _le32toh(data[0])
-        assert refcount <= _MAX_VALUE, "invalid reference count"
-        if refcount != _MAX_VALUE:
-            refcount += 1
-        data[0] = _htole32(refcount)
-        return refcount, _le32toh(data[1])
-
     def iteritems(self, marker=None):
         cdef const unsigned char *key
         iter = ChunkKeyIterator(self.key_size)

+ 1 - 1
src/borg/selftest.py

@@ -33,7 +33,7 @@ SELFTEST_CASES = [
     ChunkerTestCase,
 ]
 
-SELFTEST_COUNT = 28
+SELFTEST_COUNT = 25
 
 
 class SelfTestResult(TestResult):

+ 0 - 26
src/borg/testsuite/hashindex.py

@@ -189,16 +189,6 @@ class HashIndexSizeTestCase(BaseTestCase):
 
 
 class HashIndexRefcountingTestCase(BaseTestCase):
-    def test_chunkindex_limit(self):
-        idx = ChunkIndex()
-        idx[H(1)] = ChunkIndex.MAX_VALUE - 1, 1
-
-        # 5 is arbitrary, any number of incref/decrefs shouldn't move it once it's limited
-        for i in range(5):
-            # first incref to move it to the limit
-            refcount, *_ = idx.incref(H(1))
-            assert refcount == ChunkIndex.MAX_VALUE
-
     def _merge(self, refcounta, refcountb):
         def merge(refcount1, refcount2):
             idx1 = ChunkIndex()
@@ -242,20 +232,6 @@ class HashIndexRefcountingTestCase(BaseTestCase):
         idx1.add(H(1), 1, 2)
         assert idx1[H(1)] == (6, 2)
 
-    def test_incref_limit(self):
-        idx1 = ChunkIndex()
-        idx1[H(1)] = ChunkIndex.MAX_VALUE, 6
-        idx1.incref(H(1))
-        refcount, *_ = idx1[H(1)]
-        assert refcount == ChunkIndex.MAX_VALUE
-
-    def test_incref(self):
-        idx1 = ChunkIndex()
-        idx1.add(H(1), 5, 6)
-        assert idx1[H(1)] == (5, 6)
-        idx1.incref(H(1))
-        assert idx1[H(1)] == (6, 6)
-
     def test_setitem_raises(self):
         idx1 = ChunkIndex()
         with self.assert_raises(AssertionError):
@@ -263,8 +239,6 @@ class HashIndexRefcountingTestCase(BaseTestCase):
 
     def test_keyerror(self):
         idx = ChunkIndex()
-        with self.assert_raises(KeyError):
-            idx.incref(H(1))
         with self.assert_raises(KeyError):
             idx[H(1)]
         with self.assert_raises(OverflowError):