From: Kirill Smelkov <[email protected]>

Cc: [email protected]
Signed-off-by: Kirill Smelkov <[email protected]>
---
 lib/tdb/pytdb.c                |    9 +++++++++
 lib/tdb/python/tests/simple.py |    6 ++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 7ed95a8..0ea6053 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -431,6 +431,13 @@ static PyObject *obj_clear(PyTdbObject *self)
        Py_RETURN_NONE;
 }
 
+static PyObject *obj_repack(PyTdbObject *self)
+{
+       int ret = tdb_repack(self->ctx);
+       PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
+       Py_RETURN_NONE;
+}
+
 static PyObject *obj_enable_seqnum(PyTdbObject *self)
 {
        tdb_enable_seqnum(self->ctx);
@@ -500,6 +507,8 @@ static PyMethodDef tdb_object_methods[] = {
        { "iterkeys", (PyCFunction)tdb_object_iter, METH_NOARGS, "S.iterkeys() 
-> iterator" },
        { "clear", (PyCFunction)obj_clear, METH_NOARGS, "S.clear() -> None\n"
                "Wipe the entire database." },
+       { "repack", (PyCFunction)obj_repack, METH_NOARGS, "S.repack() -> None\n"
+               "Repack the entire database." },
        { "enable_seqnum", (PyCFunction)obj_enable_seqnum, METH_NOARGS,
                "S.enable_seqnum() -> None" },
        { "increment_seqnum_nonblock", 
(PyCFunction)obj_increment_seqnum_nonblock, METH_NOARGS,
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 576baca..4fe5008 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -183,6 +183,12 @@ class SimpleTdbTests(TestCase):
         self.tdb.clear()
         self.assertEquals(0, len(list(self.tdb)))
 
+    def test_repack(self):
+        self.tdb["foo"] = "abc"
+        self.tdb["bar"] = "def"
+        del self.tdb["foo"]
+        self.tdb.repack()
+
     def test_seqnum(self):
         self.tdb.enable_seqnum()
         seq1 = self.tdb.seqnum
-- 
1.7.3.1.50.g1e633



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to