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 ...@@ -44,7 +44,6 @@ _TREE_SIZE = 500
using64bits = False using64bits = False
class IFBucketPy(Bucket): class IFBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -53,7 +52,6 @@ class IFBucketPy(Bucket): ...@@ -53,7 +52,6 @@ class IFBucketPy(Bucket):
class IFSetPy(Set): class IFSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -61,7 +59,8 @@ class IFSetPy(Set): ...@@ -61,7 +59,8 @@ class IFSetPy(Set):
class IFBTreePy(BTree): class IFBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -70,7 +69,8 @@ class IFBTreePy(BTree): ...@@ -70,7 +69,8 @@ class IFBTreePy(BTree):
class IFTreeSetPy(TreeSet): class IFTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -45,7 +45,6 @@ using64bits = False ...@@ -45,7 +45,6 @@ using64bits = False
class IIBucketPy(Bucket): class IIBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -54,7 +53,6 @@ class IIBucketPy(Bucket): ...@@ -54,7 +53,6 @@ class IIBucketPy(Bucket):
class IISetPy(Set): class IISetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -62,7 +60,8 @@ class IISetPy(Set): ...@@ -62,7 +60,8 @@ class IISetPy(Set):
class IIBTreePy(BTree): class IIBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -71,7 +70,8 @@ class IIBTreePy(BTree): ...@@ -71,7 +70,8 @@ class IIBTreePy(BTree):
class IITreeSetPy(TreeSet): class IITreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -40,26 +40,26 @@ using64bits = False ...@@ -40,26 +40,26 @@ using64bits = False
class IOBucketPy(Bucket): class IOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default MERGE_WEIGHT = MERGE_WEIGHT_default
class IOSetPy(Set): class IOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
class IOBTreePy(BTree): class IOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default MERGE_WEIGHT = MERGE_WEIGHT_default
class IOTreeSetPy(TreeSet): class IOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
class IOTreeIteratorPy(_TreeIterator): class IOTreeIteratorPy(_TreeIterator):
......
...@@ -45,7 +45,6 @@ using64bits = True ...@@ -45,7 +45,6 @@ using64bits = True
class LFBucketPy(Bucket): class LFBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -54,7 +53,6 @@ class LFBucketPy(Bucket): ...@@ -54,7 +53,6 @@ class LFBucketPy(Bucket):
class LFSetPy(Set): class LFSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -62,7 +60,8 @@ class LFSetPy(Set): ...@@ -62,7 +60,8 @@ class LFSetPy(Set):
class LFBTreePy(BTree): class LFBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -71,7 +70,8 @@ class LFBTreePy(BTree): ...@@ -71,7 +70,8 @@ class LFBTreePy(BTree):
class LFTreeSetPy(TreeSet): class LFTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -45,7 +45,6 @@ using64bits = True ...@@ -45,7 +45,6 @@ using64bits = True
class LLBucketPy(Bucket): class LLBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -54,7 +53,6 @@ class LLBucketPy(Bucket): ...@@ -54,7 +53,6 @@ class LLBucketPy(Bucket):
class LLSetPy(Set): class LLSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -62,7 +60,8 @@ class LLSetPy(Set): ...@@ -62,7 +60,8 @@ class LLSetPy(Set):
class LLBTreePy(BTree): class LLBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -71,7 +70,8 @@ class LLBTreePy(BTree): ...@@ -71,7 +70,8 @@ class LLBTreePy(BTree):
class LLTreeSetPy(TreeSet): class LLTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -40,26 +40,26 @@ using64bits = True ...@@ -40,26 +40,26 @@ using64bits = True
class LOBucketPy(Bucket): class LOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default MERGE_WEIGHT = MERGE_WEIGHT_default
class LOSetPy(Set): class LOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
class LOBTreePy(BTree): class LOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default MERGE_WEIGHT = MERGE_WEIGHT_default
class LOTreeSetPy(TreeSet): class LOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
......
...@@ -43,7 +43,6 @@ _TREE_SIZE = 250 ...@@ -43,7 +43,6 @@ _TREE_SIZE = 250
using64bits = True using64bits = True
class OIBucketPy(Bucket): class OIBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -52,7 +51,6 @@ class OIBucketPy(Bucket): ...@@ -52,7 +51,6 @@ class OIBucketPy(Bucket):
class OISetPy(Set): class OISetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -60,7 +58,8 @@ class OISetPy(Set): ...@@ -60,7 +58,8 @@ class OISetPy(Set):
class OIBTreePy(BTree): class OIBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -69,7 +68,8 @@ class OIBTreePy(BTree): ...@@ -69,7 +68,8 @@ class OIBTreePy(BTree):
class OITreeSetPy(TreeSet): class OITreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -44,7 +44,6 @@ using64bits = True ...@@ -44,7 +44,6 @@ using64bits = True
class OLBucketPy(Bucket): class OLBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -53,7 +52,6 @@ class OLBucketPy(Bucket): ...@@ -53,7 +52,6 @@ class OLBucketPy(Bucket):
class OLSetPy(Set): class OLSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
...@@ -61,7 +59,8 @@ class OLSetPy(Set): ...@@ -61,7 +59,8 @@ class OLSetPy(Set):
class OLBTreePy(BTree): class OLBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
MERGE = MERGE MERGE = MERGE
...@@ -70,7 +69,8 @@ class OLBTreePy(BTree): ...@@ -70,7 +69,8 @@ class OLBTreePy(BTree):
class OLTreeSetPy(TreeSet): class OLTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
MERGE = MERGE MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric MERGE_WEIGHT = MERGE_WEIGHT_numeric
......
...@@ -38,24 +38,24 @@ using64bits = False ...@@ -38,24 +38,24 @@ using64bits = False
class OOBucketPy(Bucket): class OOBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
class OOSetPy(Set): class OOSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
class OOBTreePy(BTree): class OOBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
class OOTreeSetPy(TreeSet): class OOTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
......
...@@ -866,7 +866,11 @@ class _Tree(_Base): ...@@ -866,7 +866,11 @@ class _Tree(_Base):
result = child._set(key, value, ifunset) result = child._set(key, value, ifunset)
grew = result[0] 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) self._grow(child, index)
elif (grew is not None and elif (grew is not None and
child.__class__ is self._bucket_type and child.__class__ is self._bucket_type and
...@@ -880,7 +884,7 @@ class _Tree(_Base): ...@@ -880,7 +884,7 @@ class _Tree(_Base):
self._p_changed = True self._p_changed = True
new_child = child._split() new_child = child._split()
self._data.insert(index+1, _TreeItem(new_child.minKey(), new_child)) 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() self._split_root()
def _split_root(self): def _split_root(self):
......
...@@ -43,7 +43,6 @@ _to_value = _to_bytes(6) ...@@ -43,7 +43,6 @@ _to_value = _to_bytes(6)
class fsBucketPy(Bucket): class fsBucketPy(Bucket):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
...@@ -66,18 +65,19 @@ class fsBucketPy(Bucket): ...@@ -66,18 +65,19 @@ class fsBucketPy(Bucket):
class fsSetPy(Set): class fsSetPy(Set):
MAX_SIZE = _BUCKET_SIZE
_to_key = _to_key _to_key = _to_key
class fsBTreePy(BTree): class fsBTreePy(BTree):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _to_key = _to_key
_to_value = _to_value _to_value = _to_value
class fsTreeSetPy(TreeSet): class fsTreeSetPy(TreeSet):
MAX_SIZE = _TREE_SIZE max_bucket_size = _BUCKET_SIZE
max_btree_size = _TREE_SIZE
_to_key = _to_key _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