From 9fe0140d94dcb7bc65f02cb400ea6a294b0a2ac7 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Wed, 7 Sep 2016 16:08:07 +0200 Subject: [PATCH] hashindex: export max load factor to Python-space --- borg/hashindex.pyx | 3 +++ borg/testsuite/hashindex.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/borg/hashindex.pyx b/borg/hashindex.pyx index 59741ad6e..ce1dac047 100644 --- a/borg/hashindex.pyx +++ b/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: diff --git a/borg/testsuite/hashindex.py b/borg/testsuite/hashindex.py index 75cd80227..4a6bd4432 100644 --- a/borg/testsuite/hashindex.py +++ b/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