summaryrefslogtreecommitdiff
path: root/larch
diff options
context:
space:
mode:
authorAntoine Brenner <brenner+obnam@gymglish.com>2013-01-16 22:58:35 +0100
committerAntoine Brenner <brenner+obnam@gymglish.com>2013-01-16 22:58:35 +0100
commit42d9d6c7d048580e06cab7003db5fdd61a0a3f11 (patch)
tree6fe572dc8904d0b487755ccadeae08db557da01c /larch
parent206fb1529bf3bef9c51e9c47dd5b3fa053c485ba (diff)
parent76fdb08a8660fc2abe7caecbd2ffca98c9ff06f5 (diff)
downloadlarch-42d9d6c7d048580e06cab7003db5fdd61a0a3f11.tar.gz
Repair non-working example.py and speed-test
The introduction of the allow_writes parameter in larch/forest.py:open_forest() broke example.py and speed-test. Just adding the parameter to the open_forest calls was not enough to fix the issue. This patch fixes the issue by adding the allow_writes parameter where it is needed beyond the open_forest calls. Most notably, this patch changes the __init__ signature of the abstract base class larch.NodeStore from __init__(self, node_size, codec) to __init__(self, allow_writes, node_size, codec) This mimicks the current signatures of NodeStoreDisk and NodeStoreMemory, which include the use of allow_writes as first parameter, and which seem required to actually create a forest anyway since forest.py creates node_store instances with allow_writes as first parameter in open_forest
Diffstat (limited to 'larch')
-rw-r--r--larch/forest_tests.py2
-rw-r--r--larch/nodestore.py3
-rw-r--r--larch/nodestore_disk.py2
-rw-r--r--larch/nodestore_memory.py4
-rw-r--r--larch/nodestore_memory_tests.py2
-rw-r--r--larch/tree_tests.py6
6 files changed, 10 insertions, 9 deletions
diff --git a/larch/forest_tests.py b/larch/forest_tests.py
index 9a786bd..a7c9677 100644
--- a/larch/forest_tests.py
+++ b/larch/forest_tests.py
@@ -26,7 +26,7 @@ class ForestTests(unittest.TestCase):
def setUp(self):
self.codec = larch.NodeCodec(3)
- self.ns = larch.NodeStoreMemory(64, self.codec)
+ self.ns = larch.NodeStoreMemory(allow_writes=True, node_size=64, codec=self.codec)
self.forest = larch.Forest(self.ns)
def test_new_node_ids_grow(self):
diff --git a/larch/nodestore.py b/larch/nodestore.py
index 929450a..dd9b536 100644
--- a/larch/nodestore.py
+++ b/larch/nodestore.py
@@ -98,7 +98,8 @@ class NodeStore(object): # pragma: no cover
'''
- def __init__(self, node_size, codec):
+ def __init__(self, allow_writes, node_size, codec):
+ self.allow_writes = allow_writes
self.node_size = node_size
self.codec = codec
self.max_value_size = (node_size / 2) - codec.leaf_header.size
diff --git a/larch/nodestore_disk.py b/larch/nodestore_disk.py
index 197a411..3cb8ee7 100644
--- a/larch/nodestore_disk.py
+++ b/larch/nodestore_disk.py
@@ -117,7 +117,7 @@ class NodeStoreDisk(larch.NodeStore):
if format is not None:
tracing.trace('forcing format_base: %s', format)
self.format_base = format
- larch.NodeStore.__init__(self, node_size, codec)
+ larch.NodeStore.__init__(self, allow_writes=allow_writes, node_size=node_size, codec=codec)
self.dirname = dirname
self.metadata_name = os.path.join(dirname, 'metadata')
self.metadata = None
diff --git a/larch/nodestore_memory.py b/larch/nodestore_memory.py
index 510ce5e..f0598be 100644
--- a/larch/nodestore_memory.py
+++ b/larch/nodestore_memory.py
@@ -26,8 +26,8 @@ class NodeStoreMemory(larch.NodeStore):
'''
- def __init__(self, node_size, codec):
- larch.NodeStore.__init__(self, node_size, codec)
+ def __init__(self,allow_writes, node_size, codec):
+ larch.NodeStore.__init__(self, allow_writes=allow_writes, node_size=node_size, codec=codec)
self.nodes = dict()
self.refcounts = dict()
self.metadata = dict()
diff --git a/larch/nodestore_memory_tests.py b/larch/nodestore_memory_tests.py
index eecb905..8c210db 100644
--- a/larch/nodestore_memory_tests.py
+++ b/larch/nodestore_memory_tests.py
@@ -25,5 +25,5 @@ class NodeStoreMemoryTests(unittest.TestCase, larch.NodeStoreTests):
def setUp(self):
self.node_size = 4096
self.codec = larch.NodeCodec(self.key_bytes)
- self.ns = nodestore_memory.NodeStoreMemory(self.node_size, self.codec)
+ self.ns = nodestore_memory.NodeStoreMemory(allow_writes=True, node_size=self.node_size, codec=self.codec)
diff --git a/larch/tree_tests.py b/larch/tree_tests.py
index 86895f0..8a4a4e9 100644
--- a/larch/tree_tests.py
+++ b/larch/tree_tests.py
@@ -67,7 +67,7 @@ class BTreeTests(unittest.TestCase):
# We use a small node size so that all code paths are traversed
# during testing. Use coverage.py to make sure they do.
self.codec = larch.NodeCodec(3)
- self.ns = DummyNodeStore(64, self.codec)
+ self.ns = DummyNodeStore(allow_writes=True, node_size=64, codec=self.codec)
self.forest = DummyForest()
self.tree = larch.BTree(self.forest, self.ns, None)
self.dump = False
@@ -549,7 +549,7 @@ class BTreeDecrementTests(unittest.TestCase):
# We use a small node size so that all code paths are traversed
# during testing. Use coverage.py to make sure they do.
self.codec = larch.NodeCodec(3)
- self.ns = DummyNodeStore(64, self.codec)
+ self.ns = DummyNodeStore(allow_writes=True, node_size=64, codec=self.codec)
self.forest = DummyForest()
self.tree = larch.BTree(self.forest, self.ns, None)
self.tree.insert('foo', 'bar')
@@ -574,7 +574,7 @@ class BTreeDecrementTests(unittest.TestCase):
class BTreeBalanceTests(unittest.TestCase):
def setUp(self):
- ns = DummyNodeStore(4096, larch.NodeCodec(2))
+ ns = DummyNodeStore(allow_writes=True, node_size=4096, codec=larch.NodeCodec(2))
forest = DummyForest()
self.tree = larch.BTree(forest, ns, None)
self.keys = ['%02d' % i for i in range(10)]