Commit 2d950128 authored by Jim Fulton's avatar Jim Fulton

Updated the Python implementation to match the C implementation.

Untested. I'll let travis take the first crack. Man, I need to
figure out tox.

Also, I'm not happy with the config variable names I originally
picked.  I'll fix those after the tests pass.
parent e621d8cc
......@@ -44,7 +44,6 @@ _TREE_SIZE = 500
using64bits = False
class IFBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -53,7 +52,6 @@ class IFBucketPy(Bucket):
class IFSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -61,7 +59,8 @@ class IFSetPy(Set):
class IFBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -70,7 +69,8 @@ class IFBTreePy(BTree):
class IFTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -45,7 +45,6 @@ using64bits = False
class IIBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -54,7 +53,6 @@ class IIBucketPy(Bucket):
class IISetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -62,7 +60,8 @@ class IISetPy(Set):
class IIBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -71,7 +70,8 @@ class IIBTreePy(BTree):
class IITreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -40,26 +40,26 @@ using64bits = False
class IOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
class IOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
class IOTreeIteratorPy(_TreeIterator):
......
......@@ -45,7 +45,6 @@ using64bits = True
class LFBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -54,7 +53,6 @@ class LFBucketPy(Bucket):
class LFSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -62,7 +60,8 @@ class LFSetPy(Set):
class LFBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -71,7 +70,8 @@ class LFBTreePy(BTree):
class LFTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -45,7 +45,6 @@ using64bits = True
class LLBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -54,7 +53,6 @@ class LLBucketPy(Bucket):
class LLSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -62,7 +60,8 @@ class LLSetPy(Set):
class LLBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -71,7 +70,8 @@ class LLBTreePy(BTree):
class LLTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -40,26 +40,26 @@ using64bits = True
class LOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
class LOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
......
......@@ -43,7 +43,6 @@ _TREE_SIZE = 250
using64bits = True
class OIBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -52,7 +51,6 @@ class OIBucketPy(Bucket):
class OISetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -60,7 +58,8 @@ class OISetPy(Set):
class OIBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -69,7 +68,8 @@ class OIBTreePy(BTree):
class OITreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -44,7 +44,6 @@ using64bits = True
class OLBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -53,7 +52,6 @@ class OLBucketPy(Bucket):
class OLSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......@@ -61,7 +59,8 @@ class OLSetPy(Set):
class OLBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
......@@ -70,7 +69,8 @@ class OLBTreePy(BTree):
class OLTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
......@@ -38,24 +38,24 @@ using64bits = False
class OOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
class OOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
class OOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
class OOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
......
......@@ -866,7 +866,11 @@ class _Tree(_Base):
result = child._set(key, value, ifunset)
grew = result[0]
if grew and child.size > child.MAX_SIZE:
if child.__class__ is self.__class__:
max_size = self.max_btree_size
else:
max_size = self.max_bucket_size
if grew and child.size > max_size:
self._grow(child, index)
elif (grew is not None and
child.__class__ is self._bucket_type and
......@@ -880,7 +884,7 @@ class _Tree(_Base):
self._p_changed = True
new_child = child._split()
self._data.insert(index+1, _TreeItem(new_child.minKey(), new_child))
if len(self._data) > self.MAX_SIZE * 2:
if len(self._data) > self.max_btree_size * 2:
self._split_root()
def _split_root(self):
......
......@@ -43,7 +43,6 @@ _to_value = _to_bytes(6)
class fsBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
_to_value = _to_value
......@@ -66,18 +65,19 @@ class fsBucketPy(Bucket):
class fsSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key
class fsBTreePy(BTree):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
class fsTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE
max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment