Parcourir la source

hashindex: export max load factor to Python-space

Marian Beermann il y a 8 ans
Parent
commit
9fe0140d94
2 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 3 0
      borg/hashindex.pyx
  2. 5 0
      borg/testsuite/hashindex.py

+ 3 - 0
borg/hashindex.pyx

@@ -23,6 +23,8 @@ cdef extern from "_hashindex.c":
     uint32_t _htole32(uint32_t v)
     uint32_t _le32toh(uint32_t v)
 
+    double HASH_MAX_LOAD
+
 
 cdef _NoDefault = object()
 
@@ -54,6 +56,7 @@ cdef class IndexBase:
     cdef HashIndex *index
     cdef int key_size
 
+    MAX_LOAD_FACTOR = HASH_MAX_LOAD
     def __cinit__(self, capacity=0, path=None, key_size=32):
         self.key_size = key_size
         if path:

+ 5 - 0
borg/testsuite/hashindex.py

@@ -276,3 +276,8 @@ def test_nsindex_segment_limit():
     assert H(1) not in idx
     idx[H(2)] = hashindex.MAX_VALUE, 0
     assert H(2) in idx
+
+
+def test_max_load_factor():
+    assert NSIndex.MAX_LOAD_FACTOR < 1
+    assert ChunkIndex.MAX_LOAD_FACTOR < 1