Commit d1f27435 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 846e08c0
...@@ -506,7 +506,12 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets): ...@@ -506,7 +506,12 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets):
# (klo, khi, keyv, maxdepth, maxsplit)) # (klo, khi, keyv, maxdepth, maxsplit))
for nsplit in range(0, maxsplit+1): for nsplit in range(0, maxsplit+1):
for ksplitv in _iterSplitByN(klo, khi, nsplit): if not allowEmptyBuckets:
iksplitv = _iterSplitKeyvByN(klo, khi, keyv, nsplit)
else:
iksplitv = _iterSplitByN(klo, khi, nsplit)
for ksplitv in iksplitv:
# ksplitv = [klo, s1, s2, ..., sN, khi] # ksplitv = [klo, s1, s2, ..., sN, khi]
#print('ksplitv: %r' % ksplitv) #print('ksplitv: %r' % ksplitv)
...@@ -514,8 +519,8 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets): ...@@ -514,8 +519,8 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets):
children = [] children = []
for (xlo, xhi) in zip(ksplitv[:-1], ksplitv[1:]): # (klo, s1), (s1, s2), ..., (sN, khi) for (xlo, xhi) in zip(ksplitv[:-1], ksplitv[1:]): # (klo, s1), (s1, s2), ..., (sN, khi)
bkeyv = _keyvSliceBy(keyv, xlo, xhi) bkeyv = _keyvSliceBy(keyv, xlo, xhi)
if len(bkeyv) == 0 and (not allowEmptyBuckets): if not allowEmptyBuckets:
break assert len(bkeyv) > 0
children.append(Bucket(*bkeyv)) children.append(Bucket(*bkeyv))
else: else:
yield Tree(ksplitv[1:-1], *children) # (s1, s2, ..., sN) yield Tree(ksplitv[1:-1], *children) # (s1, s2, ..., sN)
...@@ -526,8 +531,8 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets): ...@@ -526,8 +531,8 @@ def _allStructs(klo, khi, keyv, maxdepth, maxsplit, allowEmptyBuckets):
ichildrenv = [] # of _allStructs for each child link ichildrenv = [] # of _allStructs for each child link
for (xlo, xhi) in zip(ksplitv[:-1], ksplitv[1:]): # (klo, s1), (s1, s2), ..., (sN, khi) for (xlo, xhi) in zip(ksplitv[:-1], ksplitv[1:]): # (klo, s1), (s1, s2), ..., (sN, khi)
ckeyv = _keyvSliceBy(keyv, xlo, xhi) ckeyv = _keyvSliceBy(keyv, xlo, xhi)
if len(ckeyv) == 0 and (not allowEmptyBuckets): if not allowEmptyBuckets:
break assert len(ckeyv) > 0
ichildrenv.append( _allStructs( ichildrenv.append( _allStructs(
xlo, xhi, ckeyv, maxdepth - 1, maxsplit, allowEmptyBuckets)) xlo, xhi, ckeyv, maxdepth - 1, maxsplit, allowEmptyBuckets))
else: else:
......
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