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
58f94ed4
Commit
58f94ed4
authored
Sep 30, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Fix RangedMap to be usable from outide of blib package
parent
6ae828b3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
16 deletions
+42
-16
wcfs/internal/xbtree/blib/gen-rangemap
wcfs/internal/xbtree/blib/gen-rangemap
+18
-1
wcfs/internal/xbtree/zrangemap_rebuildjob.go
wcfs/internal/xbtree/zrangemap_rebuildjob.go
+18
-15
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+6
-0
No files found.
wcfs/internal/xbtree/blib/gen-rangemap
View file @
58f94ed4
...
...
@@ -26,10 +26,27 @@ VALUE=$2
out
=
$3
input
=
$(
dirname
$0
)
/rangemap.go.in
blib
=
$(
cd
$(
dirname
$0
)
&&
go list
)
# fullpath for blib package
curr
=
$(
go list
)
# ----//---- current package
pkgname
=
$(
go list
-f
{{
.Name
}}
)
# name of current package
echo
"// Code generated by gen-rangemap
$TYPE
$VALUE
; DO NOT EDIT."
>
$out
echo
>>
$out
# fiximports adjusts rangemap.go code to work outside of blib packages.
fiximports
()
{
if
[
"
$curr
"
==
"
$blib
"
]
;
then
cat
return
fi
sed
\
-e
"/package blib/a
\\\\
nimport
\"
$blib
\"\\
n"
\
-e
"s/package blib/package
$pkgname
/g"
\
-e
's/\([^\w.]\)KeyRange\b/\1blib.KeyRange/g'
\
-e
's/\bKStr\b/blib.KStr/g'
}
sed
\
-e
"s/VALUE/
$VALUE
/g"
\
-e
"s/
\b
RangedMap
\b
/
${
TYPE
}
/g"
\
...
...
@@ -40,4 +57,4 @@ sed \
-e
"s/
\b
traceRangeMap
\b
/trace
${
TYPE
}
/g"
\
-e
"s/
\b
debugRangeMap
\b
/debug
${
TYPE
}
/g"
\
-e
"s/
\b
debugfRMap
\b
/debugf
${
TYPE
}
/g"
\
$input
>>
$out
$input
|fiximports
>>
$out
wcfs/internal/xbtree/zrangemap_rebuildjob.go
View file @
58f94ed4
...
...
@@ -19,7 +19,10 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package
blib
package
xbtree
import
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/blib"
// map [lo,hi) Key ranges to values.
import
(
...
...
@@ -43,7 +46,7 @@ type _RangedMap_RebuildJob struct {
// _RangedMap_RebuildJobEntry represents one entry in _RangedMap_RebuildJob.
type
_RangedMap_RebuildJobEntry
struct
{
Value
_RebuildJob
KeyRange
blib
.
KeyRange
}
...
...
@@ -55,12 +58,12 @@ func (M *_RangedMap_RebuildJob) Get(k Key) _RebuildJob {
// Set changes M to map key k to value v.
func
(
M
*
_RangedMap_RebuildJob
)
Set
(
k
Key
,
v
_RebuildJob
)
{
M
.
SetRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
},
v
)
M
.
SetRange
(
blib
.
KeyRange
{
Lo
:
k
,
Hi_
:
k
},
v
)
}
// Del removes key k.
func
(
M
*
_RangedMap_RebuildJob
)
Del
(
k
Key
)
{
M
.
DelRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
M
.
DelRange
(
blib
.
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
}
// Has returns whether key k is present in the map.
...
...
@@ -76,7 +79,7 @@ func (M *_RangedMap_RebuildJob) Get_(k Key) (v _RebuildJob, ok bool) {
if
trace_RangedMap_RebuildJob
{
fmt
.
Printf
(
"
\n\n
Get_:
\n
"
)
fmt
.
Printf
(
" M: %s
\n
"
,
M
)
fmt
.
Printf
(
" k: %s
\n
"
,
KStr
(
k
))
fmt
.
Printf
(
" k: %s
\n
"
,
blib
.
KStr
(
k
))
defer
func
()
{
fmt
.
Printf
(
"->·: %v, %t
\n
"
,
v
,
ok
)
}()
...
...
@@ -105,7 +108,7 @@ func (M *_RangedMap_RebuildJob) Get_(k Key) (v _RebuildJob, ok bool) {
}
// SetRange changes M to map key range r to value v.
func
(
M
*
_RangedMap_RebuildJob
)
SetRange
(
r
KeyRange
,
v
_RebuildJob
)
{
func
(
M
*
_RangedMap_RebuildJob
)
SetRange
(
r
blib
.
KeyRange
,
v
_RebuildJob
)
{
e
:=
_RangedMap_RebuildJobEntry
{
v
,
r
}
if
trace_RangedMap_RebuildJob
{
fmt
.
Printf
(
"
\n\n
SetRange:
\n
"
)
...
...
@@ -134,7 +137,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
right
:=
M
.
entryv
[
i
+
1
]
if
(
x
.
Hi_
+
1
==
right
.
Lo
)
&&
(
v
==
right
.
Value
)
{
vReplaceSlice__RangedMap_RebuildJob
(
&
M
.
entryv
,
i
,
i
+
2
,
_RangedMap_RebuildJobEntry
{
v
,
KeyRange
{
x
.
Lo
,
right
.
Hi_
}})
_RangedMap_RebuildJobEntry
{
v
,
blib
.
KeyRange
{
x
.
Lo
,
right
.
Hi_
}})
debugf_RangedMap_RebuildJob
(
"
\t
merge right
\t
-> %s
\n
"
,
M
)
}
}
...
...
@@ -144,7 +147,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
x
:=
M
.
entryv
[
i
]
if
(
left
.
Hi_
+
1
==
x
.
Lo
)
&&
(
left
.
Value
==
v
)
{
vReplaceSlice__RangedMap_RebuildJob
(
&
M
.
entryv
,
i
-
1
,
i
+
1
,
_RangedMap_RebuildJobEntry
{
v
,
KeyRange
{
left
.
Lo
,
x
.
Hi_
}})
_RangedMap_RebuildJobEntry
{
v
,
blib
.
KeyRange
{
left
.
Lo
,
x
.
Hi_
}})
debugf_RangedMap_RebuildJob
(
"
\t
merge left
\t
-> %s
\n
"
,
M
)
}
}
...
...
@@ -182,7 +185,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
if (jhi - ilo) > 1 {
lo := S.rangev[ilo].Lo
hi_ := S.rangev[jhi-1].Hi_
vReplaceSlice__RangedMap_RebuildJob(&S.rangev, ilo,jhi, KeyRange{lo,hi_})
vReplaceSlice__RangedMap_RebuildJob(&S.rangev, ilo,jhi,
blib.
KeyRange{lo,hi_})
debugfRSet("\tmerge S[%d:%d]\t-> %s\n", ilo, jhi, S)
}
jhi = -1 // no longer valid
...
...
@@ -208,7 +211,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
if ilo+1 < len(S.rangev) { // right
if S.rangev[ilo].Hi_+1 == S.rangev[ilo+1].Lo {
vReplaceSlice__RangedMap_RebuildJob(&S.rangev, ilo,ilo+2,
KeyRange{S.rangev[ilo].Lo, S.rangev[ilo+1].Hi_})
blib.
KeyRange{S.rangev[ilo].Lo, S.rangev[ilo+1].Hi_})
debugfRSet("\tmerge right\t-> %s\n", S)
}
}
...
...
@@ -216,7 +219,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
if ilo > 0 { // left
if S.rangev[ilo-1].Hi_+1 == S.rangev[ilo].Lo {
vReplaceSlice__RangedMap_RebuildJob(&S.rangev, ilo-1,ilo+1,
KeyRange{S.rangev[ilo-1].Lo, S.rangev[ilo].Hi_})
blib.
KeyRange{S.rangev[ilo-1].Lo, S.rangev[ilo].Hi_})
debugfRSet("\tmerge left\t-> %s\n", S)
}
}
...
...
@@ -226,7 +229,7 @@ func (M *_RangedMap_RebuildJob) SetRange(r KeyRange, v _RebuildJob) {
}
// DelRange removes range r from the map.
func
(
M
*
_RangedMap_RebuildJob
)
DelRange
(
r
KeyRange
)
{
func
(
M
*
_RangedMap_RebuildJob
)
DelRange
(
r
blib
.
KeyRange
)
{
if
trace_RangedMap_RebuildJob
{
fmt
.
Printf
(
"
\n\n
DelRange:
\n
"
)
fmt
.
Printf
(
" M: %s
\n
"
,
M
)
...
...
@@ -248,7 +251,7 @@ func (M *_RangedMap_RebuildJob) DelRange(r KeyRange) {
// should be inserted/appended if needed.
//
// r must be !empty.
func
(
M
*
_RangedMap_RebuildJob
)
delRange
(
r
KeyRange
)
(
i
int
)
{
func
(
M
*
_RangedMap_RebuildJob
)
delRange
(
r
blib
.
KeyRange
)
(
i
int
)
{
// find first ilo: r.Lo < [ilo].hi
l
:=
len
(
M
.
entryv
)
ilo
:=
sort
.
Search
(
l
,
func
(
i
int
)
bool
{
...
...
@@ -309,7 +312,7 @@ func (M *_RangedMap_RebuildJob) delRange(r KeyRange) (i int) {
}
// HasRange returns whether all keys from range r belong to the map.
func
(
M
*
_RangedMap_RebuildJob
)
HasRange
(
r
KeyRange
)
(
yes
bool
)
{
func
(
M
*
_RangedMap_RebuildJob
)
HasRange
(
r
blib
.
KeyRange
)
(
yes
bool
)
{
if
trace_RangedMap_RebuildJob
{
fmt
.
Printf
(
"
\n\n
HasRange:
\n
"
)
fmt
.
Printf
(
" M: %s
\n
"
,
M
)
...
...
@@ -340,7 +343,7 @@ func (M *_RangedMap_RebuildJob) HasRange(r KeyRange) (yes bool) {
lo
:=
r
.
Lo
for
{
e
:=
M
.
entryv
[
ilo
]
debugf_RangedMap_RebuildJob
(
"
\t
e: %s
\t
tocheck: %s
\n
"
,
e
,
KeyRange
{
lo
,
r
.
Hi_
})
debugf_RangedMap_RebuildJob
(
"
\t
e: %s
\t
tocheck: %s
\n
"
,
e
,
blib
.
KeyRange
{
lo
,
r
.
Hi_
})
if
lo
<
e
.
Lo
{
return
false
// hole in coverage
...
...
wcfs/internal/xbtree/δbtail.go
View file @
58f94ed4
...
...
@@ -189,6 +189,12 @@ type ΔTree struct {
}
// XXX place
type
_RebuildJob
struct
{
// XXX
}
// NewΔBtail creates new empty ΔBtail object.
//
// Initial tracked set is empty.
...
...
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