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
042c5eeb
Commit
042c5eeb
authored
Jul 01, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
467ef54e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
54 deletions
+117
-54
wcfs/internal/xbtree/blib/blib.go
wcfs/internal/xbtree/blib/blib.go
+60
-0
wcfs/internal/xbtree/blib/pptreesubset.go
wcfs/internal/xbtree/blib/pptreesubset.go
+1
-1
wcfs/internal/xbtree/blib/pptreesubset_test.go
wcfs/internal/xbtree/blib/pptreesubset_test.go
+1
-1
wcfs/internal/xbtree/blib/rangeset.go
wcfs/internal/xbtree/blib/rangeset.go
+41
-41
wcfs/internal/xbtree/blib/rangeset_test.go
wcfs/internal/xbtree/blib/rangeset_test.go
+1
-1
wcfs/internal/xbtree/xbtree.go
wcfs/internal/xbtree/xbtree.go
+10
-9
wcfs/internal/xbtree/xbtreetest/rtree.go
wcfs/internal/xbtree/xbtreetest/rtree.go
+3
-1
No files found.
wcfs/internal/xbtree/blib/blib.go
0 → 100644
View file @
042c5eeb
// Copyright (C) 2021 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package blib provides utilities related to BTrees.
package
blib
import
(
"fmt"
"math"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
)
// XXX instead of generics
type
Tree
=
btree
.
LOBTree
type
Bucket
=
btree
.
LOBucket
type
Node
=
btree
.
LONode
type
TreeEntry
=
btree
.
LOEntry
type
BucketEntry
=
btree
.
LOBucketEntry
type
Key
=
int64
const
KeyMax
Key
=
math
.
MaxInt64
const
KeyMin
Key
=
math
.
MinInt64
type
setOid
=
set
.
Oid
// kstr formats key as string.
func
kstr
(
k
Key
)
string
{
if
k
==
KeyMin
{
return
"-∞"
}
if
k
==
KeyMax
{
return
"∞"
}
return
fmt
.
Sprintf
(
"%d"
,
k
)
}
func
panicf
(
format
string
,
argv
...
interface
{})
{
panic
(
fmt
.
Sprintf
(
format
,
argv
...
))
}
wcfs/internal/xbtree/pptreesubset.go
→
wcfs/internal/xbtree/
blib/
pptreesubset.go
View file @
042c5eeb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
xbtree
package
blib
// PP-connected subset of tree nodes.
// PP-connected subset of tree nodes.
import
(
import
(
...
...
wcfs/internal/xbtree/pptreesubset_test.go
→
wcfs/internal/xbtree/
blib/
pptreesubset_test.go
View file @
042c5eeb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
xbtree
package
blib
import
(
import
(
"strings"
"strings"
...
...
wcfs/internal/xbtree/rangeset.go
→
wcfs/internal/xbtree/
blib/
rangeset.go
View file @
042c5eeb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
xbtree
package
blib
// set of [lo,hi) Key ranges.
// set of [lo,hi) Key ranges.
import
(
import
(
...
@@ -30,8 +30,8 @@ const debugRangeSet = false
...
@@ -30,8 +30,8 @@ const debugRangeSet = false
// KeyRange represents [lo,hi) Key range.
// KeyRange represents [lo,hi) Key range.
type
KeyRange
struct
{
type
KeyRange
struct
{
l
o
Key
L
o
Key
h
i_
Key
// NOTE _not_ hi) to avoid overflow at ∞; hi = hi_ + 1
H
i_
Key
// NOTE _not_ hi) to avoid overflow at ∞; hi = hi_ + 1
}
}
// RangedKeySet is set of Keys with adjacent keys coalesced into Ranges.
// RangedKeySet is set of Keys with adjacent keys coalesced into Ranges.
...
@@ -47,23 +47,23 @@ type RangedKeySet struct {
...
@@ -47,23 +47,23 @@ type RangedKeySet struct {
// Has returns whether key k belongs to the range.
// Has returns whether key k belongs to the range.
func
(
r
*
KeyRange
)
Has
(
k
Key
)
bool
{
func
(
r
*
KeyRange
)
Has
(
k
Key
)
bool
{
return
(
r
.
lo
<=
k
&&
k
<=
r
.
h
i_
)
return
(
r
.
Lo
<=
k
&&
k
<=
r
.
H
i_
)
}
}
// Add adds key k to the set.
// Add adds key k to the set.
func
(
S
*
RangedKeySet
)
Add
(
k
Key
)
{
func
(
S
*
RangedKeySet
)
Add
(
k
Key
)
{
S
.
AddRange
(
KeyRange
{
lo
:
k
,
h
i_
:
k
})
S
.
AddRange
(
KeyRange
{
Lo
:
k
,
H
i_
:
k
})
}
}
// Del removes key k from the set.
// Del removes key k from the set.
func
(
S
*
RangedKeySet
)
Del
(
k
Key
)
{
func
(
S
*
RangedKeySet
)
Del
(
k
Key
)
{
S
.
DelRange
(
KeyRange
{
lo
:
k
,
h
i_
:
k
})
S
.
DelRange
(
KeyRange
{
Lo
:
k
,
H
i_
:
k
})
}
}
// Has returns whether key k belongs to the set.
// Has returns whether key k belongs to the set.
func
(
S
*
RangedKeySet
)
Has
(
k
Key
)
bool
{
func
(
S
*
RangedKeySet
)
Has
(
k
Key
)
bool
{
return
S
.
HasRange
(
KeyRange
{
lo
:
k
,
h
i_
:
k
})
return
S
.
HasRange
(
KeyRange
{
Lo
:
k
,
H
i_
:
k
})
}
}
...
@@ -79,10 +79,10 @@ func (S *RangedKeySet) AddRange(r KeyRange) {
...
@@ -79,10 +79,10 @@ func (S *RangedKeySet) AddRange(r KeyRange) {
S
.
verify
()
S
.
verify
()
defer
S
.
verify
()
defer
S
.
verify
()
// find first ilo: r.
l
o < [ilo].hi
// find first ilo: r.
L
o < [ilo].hi
l
:=
len
(
S
.
rangev
)
l
:=
len
(
S
.
rangev
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
r
.
lo
<=
S
.
rangev
[
i
]
.
h
i_
return
r
.
Lo
<=
S
.
rangev
[
i
]
.
H
i_
})
})
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
...
@@ -92,58 +92,58 @@ func (S *RangedKeySet) AddRange(r KeyRange) {
...
@@ -92,58 +92,58 @@ func (S *RangedKeySet) AddRange(r KeyRange) {
debugfRSet
(
"
\t
append %s
\t
-> %s
\n
"
,
r
,
S
)
debugfRSet
(
"
\t
append %s
\t
-> %s
\n
"
,
r
,
S
)
}
}
// find last jhi: [jhi].
l
o < r.hi
// find last jhi: [jhi].
L
o < r.hi
jhi
:=
ilo
jhi
:=
ilo
for
;;
jhi
++
{
for
;;
jhi
++
{
if
jhi
==
l
{
if
jhi
==
l
{
break
break
}
}
if
S
.
rangev
[
jhi
]
.
lo
<=
r
.
h
i_
{
if
S
.
rangev
[
jhi
]
.
Lo
<=
r
.
H
i_
{
continue
continue
}
}
break
break
}
}
debugfRSet
(
"
\t
jhi: %d
\n
"
,
jhi
)
debugfRSet
(
"
\t
jhi: %d
\n
"
,
jhi
)
// entries in [ilo:jhi) ∈ [r.
l
o,r.hi) and should be merged into one
// entries in [ilo:jhi) ∈ [r.
L
o,r.hi) and should be merged into one
if
(
jhi
-
ilo
)
>
1
{
if
(
jhi
-
ilo
)
>
1
{
lo
:=
S
.
rangev
[
ilo
]
.
l
o
lo
:=
S
.
rangev
[
ilo
]
.
L
o
hi_
:=
S
.
rangev
[
jhi
-
1
]
.
h
i_
hi_
:=
S
.
rangev
[
jhi
-
1
]
.
H
i_
vReplaceSlice
(
&
S
.
rangev
,
ilo
,
jhi
,
KeyRange
{
lo
,
hi_
})
vReplaceSlice
(
&
S
.
rangev
,
ilo
,
jhi
,
KeyRange
{
lo
,
hi_
})
debugfRSet
(
"
\t
merge S[%d:%d]
\t
-> %s
\n
"
,
ilo
,
jhi
,
S
)
debugfRSet
(
"
\t
merge S[%d:%d]
\t
-> %s
\n
"
,
ilo
,
jhi
,
S
)
}
}
jhi
=
-
1
// no longer valid
jhi
=
-
1
// no longer valid
// if [r.lo,r.hi) was outside of any entry - create new entry
// if [r.lo,r.hi) was outside of any entry - create new entry
if
r
.
hi_
<
S
.
rangev
[
ilo
]
.
l
o
{
if
r
.
Hi_
<
S
.
rangev
[
ilo
]
.
L
o
{
vInsert
(
&
S
.
rangev
,
ilo
,
r
)
vInsert
(
&
S
.
rangev
,
ilo
,
r
)
debugfRSet
(
"
\t
insert %s
\t
-> %s
\n
"
,
r
,
S
)
debugfRSet
(
"
\t
insert %s
\t
-> %s
\n
"
,
r
,
S
)
}
}
// now we have covered entries merged as needed into [ilo]
// now we have covered entries merged as needed into [ilo]
// extend this entry if r coverage is wider
// extend this entry if r coverage is wider
if
r
.
lo
<
S
.
rangev
[
ilo
]
.
l
o
{
if
r
.
Lo
<
S
.
rangev
[
ilo
]
.
L
o
{
S
.
rangev
[
ilo
]
.
lo
=
r
.
l
o
S
.
rangev
[
ilo
]
.
Lo
=
r
.
L
o
debugfRSet
(
"
\t
extend left
\t
-> %s
\n
"
,
S
)
debugfRSet
(
"
\t
extend left
\t
-> %s
\n
"
,
S
)
}
}
if
r
.
hi_
>
S
.
rangev
[
ilo
]
.
h
i_
{
if
r
.
Hi_
>
S
.
rangev
[
ilo
]
.
H
i_
{
S
.
rangev
[
ilo
]
.
hi_
=
r
.
h
i_
S
.
rangev
[
ilo
]
.
Hi_
=
r
.
H
i_
debugfRSet
(
"
\t
extend right
\t
-> %s
\n
"
,
S
)
debugfRSet
(
"
\t
extend right
\t
-> %s
\n
"
,
S
)
}
}
// and check if we should merge it with right/left neighbours
// and check if we should merge it with right/left neighbours
if
ilo
+
1
<
len
(
S
.
rangev
)
{
// right
if
ilo
+
1
<
len
(
S
.
rangev
)
{
// right
if
S
.
rangev
[
ilo
]
.
hi_
+
1
==
S
.
rangev
[
ilo
+
1
]
.
l
o
{
if
S
.
rangev
[
ilo
]
.
Hi_
+
1
==
S
.
rangev
[
ilo
+
1
]
.
L
o
{
vReplaceSlice
(
&
S
.
rangev
,
ilo
,
ilo
+
2
,
vReplaceSlice
(
&
S
.
rangev
,
ilo
,
ilo
+
2
,
KeyRange
{
S
.
rangev
[
ilo
]
.
lo
,
S
.
rangev
[
ilo
+
1
]
.
h
i_
})
KeyRange
{
S
.
rangev
[
ilo
]
.
Lo
,
S
.
rangev
[
ilo
+
1
]
.
H
i_
})
debugfRSet
(
"
\t
merge right
\t
-> %s
\n
"
,
S
)
debugfRSet
(
"
\t
merge right
\t
-> %s
\n
"
,
S
)
}
}
}
}
if
ilo
>
0
{
// left
if
ilo
>
0
{
// left
if
S
.
rangev
[
ilo
-
1
]
.
hi_
+
1
==
S
.
rangev
[
ilo
]
.
l
o
{
if
S
.
rangev
[
ilo
-
1
]
.
Hi_
+
1
==
S
.
rangev
[
ilo
]
.
L
o
{
vReplaceSlice
(
&
S
.
rangev
,
ilo
-
1
,
ilo
+
1
,
vReplaceSlice
(
&
S
.
rangev
,
ilo
-
1
,
ilo
+
1
,
KeyRange
{
S
.
rangev
[
ilo
-
1
]
.
lo
,
S
.
rangev
[
ilo
]
.
h
i_
})
KeyRange
{
S
.
rangev
[
ilo
-
1
]
.
Lo
,
S
.
rangev
[
ilo
]
.
H
i_
})
debugfRSet
(
"
\t
merge left
\t
-> %s
\n
"
,
S
)
debugfRSet
(
"
\t
merge left
\t
-> %s
\n
"
,
S
)
}
}
}
}
...
@@ -163,10 +163,10 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
...
@@ -163,10 +163,10 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
S
.
verify
()
S
.
verify
()
defer
S
.
verify
()
defer
S
.
verify
()
// find first ilo: r.
l
o < [ilo].hi
// find first ilo: r.
L
o < [ilo].hi
l
:=
len
(
S
.
rangev
)
l
:=
len
(
S
.
rangev
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
r
.
lo
<=
S
.
rangev
[
i
]
.
h
i_
return
r
.
Lo
<=
S
.
rangev
[
i
]
.
H
i_
})
})
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
...
@@ -175,13 +175,13 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
...
@@ -175,13 +175,13 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
return
return
}
}
// find last jhi: [jhi].
l
o < r.hi
// find last jhi: [jhi].
L
o < r.hi
jhi
:=
ilo
jhi
:=
ilo
for
;;
jhi
++
{
for
;;
jhi
++
{
if
jhi
==
l
{
if
jhi
==
l
{
break
break
}
}
if
S
.
rangev
[
jhi
]
.
lo
<=
r
.
h
i_
{
if
S
.
rangev
[
jhi
]
.
Lo
<=
r
.
H
i_
{
continue
continue
}
}
break
break
...
@@ -196,19 +196,19 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
...
@@ -196,19 +196,19 @@ func (S *RangedKeySet) DelRange(r KeyRange) {
// [ilo+1:jhi-1] should be deleted
// [ilo+1:jhi-1] should be deleted
// [ilo] and [jhi-1] overlap with [r.lo,r.hi) - they should be deleted, or shrinked,
// [ilo] and [jhi-1] overlap with [r.lo,r.hi) - they should be deleted, or shrinked,
// or split+shrinked if ilo==jhi-1 and r is inside [ilo]
// or split+shrinked if ilo==jhi-1 and r is inside [ilo]
if
jhi
-
ilo
==
1
&&
S
.
rangev
[
ilo
]
.
lo
<
r
.
lo
&&
r
.
hi_
<
S
.
rangev
[
ilo
]
.
h
i_
{
if
jhi
-
ilo
==
1
&&
S
.
rangev
[
ilo
]
.
Lo
<
r
.
Lo
&&
r
.
Hi_
<
S
.
rangev
[
ilo
]
.
H
i_
{
x
:=
S
.
rangev
[
ilo
]
x
:=
S
.
rangev
[
ilo
]
vInsert
(
&
S
.
rangev
,
ilo
,
x
)
vInsert
(
&
S
.
rangev
,
ilo
,
x
)
jhi
++
jhi
++
debugfRSet
(
"
\t
presplit copy %s
\t
-> %s
\n
"
,
x
,
S
)
debugfRSet
(
"
\t
presplit copy %s
\t
-> %s
\n
"
,
x
,
S
)
}
}
if
S
.
rangev
[
ilo
]
.
lo
<
r
.
l
o
{
// shrink left
if
S
.
rangev
[
ilo
]
.
Lo
<
r
.
L
o
{
// shrink left
S
.
rangev
[
ilo
]
=
KeyRange
{
S
.
rangev
[
ilo
]
.
lo
,
r
.
l
o
-
1
}
S
.
rangev
[
ilo
]
=
KeyRange
{
S
.
rangev
[
ilo
]
.
Lo
,
r
.
L
o
-
1
}
ilo
++
ilo
++
debugfRSet
(
"
\t
shrink [%d] left
\t
-> %s
\n
"
,
ilo
,
S
)
debugfRSet
(
"
\t
shrink [%d] left
\t
-> %s
\n
"
,
ilo
,
S
)
}
}
if
r
.
hi_
<
S
.
rangev
[
jhi
-
1
]
.
h
i_
{
// shrink right
if
r
.
Hi_
<
S
.
rangev
[
jhi
-
1
]
.
H
i_
{
// shrink right
S
.
rangev
[
jhi
-
1
]
=
KeyRange
{
r
.
hi_
+
1
,
S
.
rangev
[
jhi
-
1
]
.
h
i_
}
S
.
rangev
[
jhi
-
1
]
=
KeyRange
{
r
.
Hi_
+
1
,
S
.
rangev
[
jhi
-
1
]
.
H
i_
}
jhi
--
jhi
--
debugfRSet
(
"
\t
shrink [%d] right
\t
-> %s
\n
"
,
jhi
-
1
,
S
)
debugfRSet
(
"
\t
shrink [%d] right
\t
-> %s
\n
"
,
jhi
-
1
,
S
)
}
}
...
@@ -237,7 +237,7 @@ func (S *RangedKeySet) HasRange(r KeyRange) (yes bool) {
...
@@ -237,7 +237,7 @@ func (S *RangedKeySet) HasRange(r KeyRange) (yes bool) {
// find first ilo: r.lo < [ilo].hi
// find first ilo: r.lo < [ilo].hi
l
:=
len
(
S
.
rangev
)
l
:=
len
(
S
.
rangev
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
return
r
.
lo
<=
S
.
rangev
[
i
]
.
h
i_
return
r
.
Lo
<=
S
.
rangev
[
i
]
.
H
i_
})
})
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
debugfRSet
(
"
\t
ilo: %d
\n
"
,
ilo
)
...
@@ -246,7 +246,7 @@ func (S *RangedKeySet) HasRange(r KeyRange) (yes bool) {
...
@@ -246,7 +246,7 @@ func (S *RangedKeySet) HasRange(r KeyRange) (yes bool) {
}
}
// all keys from r are in S if r ∈ [ilo]
// all keys from r are in S if r ∈ [ilo]
return
(
S
.
rangev
[
ilo
]
.
lo
<=
r
.
lo
&&
r
.
hi_
<=
S
.
rangev
[
ilo
]
.
h
i_
)
return
(
S
.
rangev
[
ilo
]
.
Lo
<=
r
.
Lo
&&
r
.
Hi_
<=
S
.
rangev
[
ilo
]
.
H
i_
)
}
}
...
@@ -317,13 +317,13 @@ func (S *RangedKeySet) verify() {
...
@@ -317,13 +317,13 @@ func (S *RangedKeySet) verify() {
hi_Prev
:=
KeyMin
hi_Prev
:=
KeyMin
for
i
,
r
:=
range
S
.
rangev
{
for
i
,
r
:=
range
S
.
rangev
{
hiPrev
:=
hi_Prev
+
1
hiPrev
:=
hi_Prev
+
1
if
i
>
0
&&
!
(
hiPrev
<
r
.
l
o
)
{
// NOTE not ≤ - adjacent ranges must be merged
if
i
>
0
&&
!
(
hiPrev
<
r
.
L
o
)
{
// NOTE not ≤ - adjacent ranges must be merged
badf
(
"[%d]: !(hiPrev < r.lo)"
,
i
)
badf
(
"[%d]: !(hiPrev < r.lo)"
,
i
)
}
}
if
!
(
r
.
lo
<=
r
.
h
i_
)
{
if
!
(
r
.
Lo
<=
r
.
H
i_
)
{
badf
(
"[%d]: !(r.lo <= r.hi_)"
,
i
)
badf
(
"[%d]: !(r.lo <= r.hi_)"
,
i
)
}
}
hi_Prev
=
r
.
h
i_
hi_Prev
=
r
.
H
i_
}
}
}
}
...
@@ -378,12 +378,12 @@ func (S RangedKeySet) String() string {
...
@@ -378,12 +378,12 @@ func (S RangedKeySet) String() string {
func
(
r
KeyRange
)
String
()
string
{
func
(
r
KeyRange
)
String
()
string
{
var
shi
string
var
shi
string
if
r
.
h
i_
==
KeyMax
{
if
r
.
H
i_
==
KeyMax
{
shi
=
kstr
(
r
.
h
i_
)
// ∞
shi
=
kstr
(
r
.
H
i_
)
// ∞
}
else
{
}
else
{
shi
=
fmt
.
Sprintf
(
"%d"
,
r
.
h
i_
+
1
)
shi
=
fmt
.
Sprintf
(
"%d"
,
r
.
H
i_
+
1
)
}
}
return
fmt
.
Sprintf
(
"[%s,%s)"
,
kstr
(
r
.
l
o
),
shi
)
return
fmt
.
Sprintf
(
"[%s,%s)"
,
kstr
(
r
.
L
o
),
shi
)
}
}
...
...
wcfs/internal/xbtree/rangeset_test.go
→
wcfs/internal/xbtree/
blib/
rangeset_test.go
View file @
042c5eeb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
package
xbtree
package
blib
import
(
import
(
"testing"
"testing"
...
...
wcfs/internal/xbtree/xbtree.go
View file @
042c5eeb
...
@@ -11,19 +11,20 @@ import (
...
@@ -11,19 +11,20 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/blib"
)
)
// XXX instead of generics
// XXX instead of generics
type
Tree
=
b
tree
.
LOB
Tree
type
Tree
=
b
lib
.
Tree
type
Bucket
=
b
tree
.
LO
Bucket
type
Bucket
=
b
lib
.
Bucket
type
Node
=
b
tree
.
LO
Node
type
Node
=
b
lib
.
Node
type
TreeEntry
=
b
tree
.
LO
Entry
type
TreeEntry
=
b
lib
.
Tree
Entry
type
BucketEntry
=
b
tree
.
LO
BucketEntry
type
BucketEntry
=
b
lib
.
BucketEntry
type
Key
=
int64
type
Key
=
blib
.
Key
const
KeyMax
Key
=
math
.
MaxInt64
const
KeyMax
=
blib
.
KeyMax
const
KeyMin
Key
=
math
.
MinInt64
const
KeyMin
=
blib
.
KeyMin
// value is assumed to be persistent reference.
// value is assumed to be persistent reference.
// deletion is represented as VDEL.
// deletion is represented as VDEL.
...
...
wcfs/internal/xbtree/xbtreetest/rtree.go
View file @
042c5eeb
...
@@ -24,6 +24,8 @@ import (
...
@@ -24,6 +24,8 @@ import (
"sort"
"sort"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/blib"
)
)
// RTree represents Tree node covering [lo, hi_] key range in its parent tree.
// RTree represents Tree node covering [lo, hi_] key range in its parent tree.
...
@@ -102,5 +104,5 @@ func (xkv RBucketSet) Flatten() map[Key]string {
...
@@ -102,5 +104,5 @@ func (xkv RBucketSet) Flatten() map[Key]string {
}
}
func
(
b
*
RBucket
)
String
()
string
{
func
(
b
*
RBucket
)
String
()
string
{
return
fmt
.
Sprintf
(
"%sB%s{%s}"
,
KeyRange
{
b
.
lo
,
b
.
hi_
},
b
.
oid
,
kvtxt
(
b
.
kv
))
return
fmt
.
Sprintf
(
"%sB%s{%s}"
,
blib
.
KeyRange
{
b
.
lo
,
b
.
hi_
},
b
.
oid
,
kvtxt
(
b
.
kv
))
}
}
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