Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
8672b6d8
Commit
8672b6d8
authored
Jul 01, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3c69ff8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
41 deletions
+35
-41
wcfs/internal/xbtree/treediff.go
wcfs/internal/xbtree/treediff.go
+32
-38
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+3
-3
No files found.
wcfs/internal/xbtree/treediff.go
View file @
8672b6d8
...
...
@@ -172,7 +172,7 @@ func δZConnectTracked(δZv []zodb.Oid, T blib.PPTreeSubSet) (δZTC setOid, δto
// nodeInRange represents a Node coming under [lo, hi_] key range in its tree.
type
nodeInRange
struct
{
prefix
[]
zodb
.
Oid
// path to this node goes via this objects
lo
,
hi_
Key
// [lo, hi_] NOTE _not_ hi) not to overflow at ∞ XXX -> keycov KeyRange?
keycov
blib
.
KeyRange
node
Node
done
bool
// whether this node was already taken into account while computing diff
}
...
...
@@ -210,14 +210,14 @@ func (rs rangeSplit) Get(k Key) *nodeInRange {
// Get_ returns node covering key k.
func
(
rs
rangeSplit
)
Get_
(
k
Key
)
(
rnode
*
nodeInRange
,
ok
bool
)
{
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
k
<=
rs
[
i
]
.
h
i_
return
k
<=
rs
[
i
]
.
keycov
.
H
i_
})
if
i
==
len
(
rs
)
{
return
nil
,
false
// key not covered
}
rn
:=
rs
[
i
]
if
!
(
rn
.
lo
<=
k
&&
k
<=
rn
.
hi_
)
{
if
!
rn
.
keycov
.
Has
(
k
)
{
panicf
(
"BUG: get(%v) -> %s; coverage: %s"
,
k
,
rn
,
rs
)
}
...
...
@@ -234,7 +234,7 @@ func (rs rangeSplit) Get_(k Key) (rnode *nodeInRange, ok bool) {
func
(
prs
*
rangeSplit
)
Expand
(
rnode
*
nodeInRange
)
(
children
rangeSplit
)
{
rs
:=
*
prs
i
:=
sort
.
Search
(
len
(
rs
),
func
(
i
int
)
bool
{
return
rnode
.
hi_
<=
rs
[
i
]
.
h
i_
return
rnode
.
keycov
.
Hi_
<=
rs
[
i
]
.
keycov
.
H
i_
})
if
i
==
len
(
rs
)
||
rs
[
i
]
!=
rnode
{
panicf
(
"%s not in rangeSplit; coverage: %s"
,
rnode
,
rs
)
...
...
@@ -248,19 +248,18 @@ func (prs *rangeSplit) Expand(rnode *nodeInRange) (children rangeSplit) {
treev
:=
tree
.
Entryv
()
children
=
make
(
rangeSplit
,
0
,
len
(
treev
)
+
1
)
for
i
:=
range
treev
{
lo
:=
rnode
.
l
o
lo
:=
rnode
.
keycov
.
L
o
if
i
>
0
{
lo
=
treev
[
i
]
.
Key
()
}
hi_
:=
rnode
.
h
i_
hi_
:=
rnode
.
keycov
.
H
i_
if
i
<
len
(
treev
)
-
1
{
hi_
=
treev
[
i
+
1
]
.
Key
()
-
1
// NOTE -1 because it is hi_] not hi)
}
children
=
append
(
children
,
&
nodeInRange
{
prefix
:
rnode
.
Path
(),
lo
:
lo
,
hi_
:
hi_
,
keycov
:
blib
.
KeyRange
{
lo
,
hi_
},
node
:
treev
[
i
]
.
Child
(),
})
}
...
...
@@ -558,9 +557,10 @@ ABcov:
}
// initial split ranges for A and B
ABcov
:=
blib
.
KeyRange
{
ABlo
,
ABhi_
}
prefix
:=
ABpath
[
:
len
(
ABpath
)
-
1
]
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
A
}
// [-∞, ∞)
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
lo
:
ABlo
,
hi_
:
ABhi_
,
node
:
B
}
// [-∞, ∞)
atop
:=
&
nodeInRange
{
prefix
:
prefix
,
keycov
:
ABcov
,
node
:
A
}
btop
:=
&
nodeInRange
{
prefix
:
prefix
,
keycov
:
ABcov
,
node
:
B
}
Av
:=
rangeSplit
{
atop
}
// nodes expanded from A
Bv
:=
rangeSplit
{
btop
}
// nodes expanded from B
...
...
@@ -621,23 +621,21 @@ ABcov:
// a is bucket -> δ-
δA
,
err
:=
diffB
(
ctx
,
a
,
nil
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
ar
:=
blib
.
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtkeycovADel
.
AddRange
(
ar
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ar
,
ra
.
Path
())
δtkeycovADel
.
AddRange
(
ra
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ra
.
keycov
,
ra
.
Path
())
// Bkqueue <- ra.range
Bktodo
(
ar
)
Bktodo
(
ra
.
keycov
)
ra
.
done
=
true
case
*
Tree
:
// empty tree - queue holes covered by it
if
len
(
a
.
Entryv
())
==
0
{
ar
:=
blib
.
KeyRange
{
ra
.
lo
,
ra
.
hi_
}
δtrack
.
Del
.
AddPath
(
ra
.
Path
())
δtkeycovADel
.
AddRange
(
ar
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ar
,
ra
.
Path
())
Bktodo
(
ar
)
δtkeycovADel
.
AddRange
(
ra
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
ra
.
keycov
,
ra
.
Path
())
Bktodo
(
ra
.
keycov
)
continue
}
...
...
@@ -660,8 +658,8 @@ ABcov:
bc
,
found
:=
BnodeIdx
[
acOid
]
if
!
found
{
for
{
blo
:=
Bv
.
Get
(
ac
.
l
o
)
bhi_
:=
Bv
.
Get
(
ac
.
h
i_
)
blo
:=
Bv
.
Get
(
ac
.
keycov
.
L
o
)
bhi_
:=
Bv
.
Get
(
ac
.
keycov
.
H
i_
)
if
blo
!=
bhi_
{
break
}
...
...
@@ -692,9 +690,7 @@ ABcov:
}
if
found
{
// ac can be skipped if key coverage stays the same
ar
:=
blib
.
KeyRange
{
ac
.
lo
,
ac
.
hi_
}
br
:=
blib
.
KeyRange
{
bc
.
lo
,
bc
.
hi_
}
if
ar
==
br
{
if
ac
.
keycov
==
bc
.
keycov
{
// adjust trackSet since path to the node could have changed
apath
:=
ac
.
Path
()
bpath
:=
bc
.
Path
()
...
...
@@ -759,23 +755,22 @@ ABcov:
// δ <- δB
err
=
δMerge
(
δ
,
δB
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
br
:=
blib
.
KeyRange
{
b
.
lo
,
b
.
hi_
}
δtrack
.
Add
.
AddPath
(
b
.
Path
())
δtkeycovBAdd
.
AddRange
(
b
r
)
debugfDiff
(
" δtrack + %s %v
\n
"
,
b
r
,
b
.
Path
())
δtkeycovBAdd
.
AddRange
(
b
.
keycov
)
debugfDiff
(
" δtrack + %s %v
\n
"
,
b
.
keycov
,
b
.
Path
())
// Akqueue <- δB
Bkdone
.
AddRange
(
b
r
)
Aktodo
(
b
r
)
Bkdone
.
AddRange
(
b
.
keycov
)
Aktodo
(
b
.
keycov
)
b
.
done
=
true
}
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
b
.
h
i_
{
if
r
.
Hi_
<=
b
.
keycov
.
H
i_
{
break
}
lo
=
b
.
h
i_
+
1
lo
=
b
.
keycov
.
H
i_
+
1
}
}
Bkqueue
.
Clear
()
...
...
@@ -799,27 +794,26 @@ ABcov:
err
=
δMerge
(
δ
,
δA
);
/*X*/
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
δtrack
.
Del
.
AddPath
(
a
.
Path
())
// NOTE adjust δtkeycovADel only if a was originally tracked
ar
:=
blib
.
KeyRange
{
a
.
lo
,
a
.
hi_
}
_
,
tracked
:=
trackSet
[
a
.
node
.
POid
()]
if
tracked
{
δtkeycovADel
.
AddRange
(
a
r
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
a
r
,
a
.
Path
())
δtkeycovADel
.
AddRange
(
a
.
keycov
)
debugfDiff
(
" δtrack - %s %v
\n
"
,
a
.
keycov
,
a
.
Path
())
}
else
{
debugfDiff
(
" δtrack - [) %v
\n
"
,
a
.
Path
())
}
// Bkqueue <- a.range
Akdone
.
AddRange
(
a
r
)
Bktodo
(
a
r
)
Akdone
.
AddRange
(
a
.
keycov
)
Bktodo
(
a
.
keycov
)
a
.
done
=
true
}
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
a
.
h
i_
{
if
r
.
Hi_
<=
a
.
keycov
.
H
i_
{
break
}
lo
=
a
.
h
i_
+
1
lo
=
a
.
keycov
.
H
i_
+
1
}
}
Akqueue
.
Clear
()
...
...
@@ -1010,7 +1004,7 @@ func xidOf(obj zodb.IPersistent) string {
func
(
rn
*
nodeInRange
)
String
()
string
{
done
:=
" "
;
if
rn
.
done
{
done
=
"*"
}
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
blib
.
KeyRange
{
rn
.
lo
,
rn
.
hi_
}
,
vnode
(
rn
.
node
))
return
fmt
.
Sprintf
(
"%s%s%s"
,
done
,
rn
.
keycov
,
vnode
(
rn
.
node
))
}
// push pushes element to node stack.
...
...
wcfs/internal/xbtree/δbtail.go
View file @
8672b6d8
...
...
@@ -428,7 +428,7 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
}
tree
:=
xtree
.
(
*
Tree
)
// must succeed XXX better explicit panic?
top
:=
&
nodeInRange
{
prefix
:
nil
,
lo
:
KeyMin
,
hi_
:
KeyMax
,
node
:
tree
}
top
:=
&
nodeInRange
{
prefix
:
nil
,
keycov
:
blib
.
KeyRange
{
KeyMin
,
KeyMax
}
,
node
:
tree
}
V
:=
rangeSplit
{
top
}
for
_
,
r
:=
range
δtkeycov
.
AllRanges
()
{
lo
:=
r
.
Lo
...
...
@@ -437,10 +437,10 @@ func widenTrackNew(trackNew blib.PPTreeSubSet, δtkeycov *blib.RangedKeySet, roo
trackNew
.
AddPath
(
b
.
Path
())
// continue with next right bucket until r coverage is complete
if
r
.
Hi_
<=
b
.
h
i_
{
if
r
.
Hi_
<=
b
.
keycov
.
H
i_
{
break
}
lo
=
b
.
h
i_
+
1
lo
=
b
.
keycov
.
H
i_
+
1
}
}
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment