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
a6bac322
Commit
a6bac322
authored
Sep 27, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7829c494
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
463 additions
and
26 deletions
+463
-26
wcfs/internal/xbtree/blib/gen-rangemap
wcfs/internal/xbtree/blib/gen-rangemap
+11
-10
wcfs/internal/xbtree/blib/rangemap.go.in
wcfs/internal/xbtree/blib/rangemap.go.in
+11
-14
wcfs/internal/xbtree/blib/rangeset.go
wcfs/internal/xbtree/blib/rangeset.go
+5
-2
wcfs/internal/xbtree/blib/zrangemap_void.go
wcfs/internal/xbtree/blib/zrangemap_void.go
+436
-0
No files found.
wcfs/internal/xbtree/blib/gen-rangemap
View file @
a6bac322
#!/bin/bash -e
# rangemap.go.in -> specialized with concrete types
# gen-rangemap
KIND
VALUE out
# gen-rangemap
TYPE
VALUE out
# Copyright (C) 2018-2021 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
...
...
@@ -21,7 +21,7 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
KIND
=
$1
TYPE
=
$1
VALUE
=
$2
out
=
$3
...
...
@@ -30,7 +30,7 @@ Value=${VALUE^}
input
=
$(
dirname
$0
)
/rangemap.go.in
echo
"// Code generated by gen-rangemap; DO NOT EDIT."
>
$out
echo
"// Code generated by gen-rangemap
$TYPE
$VALUE
; DO NOT EDIT."
>
$out
echo
>>
$out
sed
\
...
...
@@ -38,11 +38,12 @@ sed \
-e
"s/<KIND>/
$KIND
/g"
\
-e
"s/VALUE/
$VALUE
/g"
\
-e
"s/<Value>/
$Value
/g"
\
-e
"s/
\b
Node
\b
/
${
KIND
}
Node/g"
\
-e
"s/
\b
BTree
\b
/
${
KIND
}
BTree/g"
\
-e
"s/
\b
Entry
\b
/
${
KIND
}
Entry/g"
\
-e
"s/
\b
Bucket
\b
/
${
KIND
}
Bucket/g"
\
-e
"s/
\b
BucketEntry
\b
/
${
KIND
}
BucketEntry/g"
\
-e
"s/
\b
btreeState
\b
/
${
kind
}
btreeState/g"
\
-e
"s/
\b
bucketState
\b
/
${
kind
}
bucketState/g"
\
-e
"s/
\b
RangedMap
\b
/
${
TYPE
}
/g"
\
-e
"s/
\b
RangedMapEntry
\b
/
${
TYPE
}
Entry/g"
\
-e
"s/
\b
vInsert
\b
/vInsert_
${
TYPE
}
/g"
\
-e
"s/
\b
vDeleteSlice
\b
/vDeleteSlice_
${
TYPE
}
/g"
\
-e
"s/
\b
vReplaceSlice
\b
/vReplaceSlice_
${
TYPE
}
/g"
\
-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
wcfs/internal/xbtree/blib/rangemap.go.in
View file @
a6bac322
...
...
@@ -35,11 +35,11 @@ type RangedMap struct {
//
TODO
rework
to
use
BTree
lo
->
hi_
instead
if
in
practice
in
treediff
,
//
and
other
usage
places
,
N
(
ranges
)
turns
out
to
be
not
small
//
(
i
.
e
.
performance
turns
out
to
be
not
acceptable
)
entryv
[]
RangeMapEntry
//
lo
↑
entryv
[]
Range
d
MapEntry
//
lo
↑
}
//
RangeMapEntry
represents
one
entry
in
RangedMap
.
type
RangeMapEntry
struct
{
//
Range
d
MapEntry
represents
one
entry
in
RangedMap
.
type
Range
d
MapEntry
struct
{
KeyRange
Value
VALUE
}
...
...
@@ -102,12 +102,9 @@ func (M *RangedMap) Get_(k Key) (v VALUE, ok bool) {
return
e
.
value
,
true
}
//
SetRange
changes
M
to
map
key
range
r
to
value
v
.
func
(
M
*
RangedMap
)
SetRange
(
r
KeyRange
,
v
VALUE
)
{
e
:=
m
apEntry
{
r
,
v
}
e
:=
RangedM
apEntry
{
r
,
v
}
if
traceRangeMap
{
fmt
.
Printf
(
"
\n\n
SetRange:
\n
"
)
fmt
.
Printf
(
" M: %s
\n
"
,
M
)
...
...
@@ -370,10 +367,10 @@ func (M *RangedMap) Clear() {
M
.
entryv
=
nil
}
//
All
Entri
es
returns
slice
of
all
key
ranges
in
the
set
.
//
All
Rang
es
returns
slice
of
all
key
ranges
in
the
set
.
//
//
TODO
->
iter
?
func
(
M
*
RangedKeySet
)
All
Entries
()
/*
readonly
*/[]
Range
MapEntry
{
func
(
M
*
RangedKeySet
)
All
Ranges
()
/*
readonly
*/[]
Ranged
MapEntry
{
return
M
.
entryv
}
...
...
@@ -390,7 +387,7 @@ func (M RangedMap) String() string {
return
s
}
func
(
e
*
m
apEntry
)
String
()
string
{
func
(
e
*
RangedM
apEntry
)
String
()
string
{
s
:=
e
.
keycov
.
String
()
v
:=
fmt
.
Sprintf
(
"%v"
,
e
.
value
)
if
v
!= "" { // omit ":<v>" in the case of set
...
...
@@ -411,16 +408,16 @@ func debugfRMap(format string, argv ...interface{}) {
//
----
slice
ops
----
//
vInsert
inserts
e
into
*
pv
[
i
].
func
vInsert
(
pv
*[]
Range
MapEntry
,
i
int
,
e
Range
MapEntry
)
{
func
vInsert
(
pv
*[]
Range
dMapEntry
,
i
int
,
e
Ranged
MapEntry
)
{
v
:=
*
pv
v
=
append
(
v
,
RangeMapEntry
{})
v
=
append
(
v
,
Range
d
MapEntry
{})
copy
(
v
[
i
+
1
:],
v
[
i
:])
v
[
i
]
=
e
*
pv
=
v
}
//
vDeleteSlice
deletes
*
pv
[
lo
:
hi
].
func
vDeleteSlice
(
pv
*[]
RangeMapEntry
,
lo
,
hi
int
)
{
func
vDeleteSlice
(
pv
*[]
Range
d
MapEntry
,
lo
,
hi
int
)
{
v
:=
*
pv
n
:=
copy
(
v
[
lo
:],
v
[
hi
:])
v
=
v
[:
lo
+
n
]
...
...
@@ -428,7 +425,7 @@ func vDeleteSlice(pv *[]RangeMapEntry, lo,hi int) {
}
//
vReplaceSlice
replaces
*
pv
[
lo
:
hi
]
with
e
.
func
vReplaceSlice
(
pv
*[]
Range
MapEntry
,
lo
,
hi
int
,
e
Range
MapEntry
)
{
func
vReplaceSlice
(
pv
*[]
Range
dMapEntry
,
lo
,
hi
int
,
e
Ranged
MapEntry
)
{
v
:=
*
pv
n
:=
copy
(
v
[
lo
+
1
:],
v
[
hi
:])
v
[
lo
]
=
e
...
...
wcfs/internal/xbtree/blib/rangeset.go
View file @
a6bac322
...
...
@@ -20,16 +20,19 @@
package
blib
// set of [lo,hi) Key ranges.
//go:generate
gen-rangemap void struct{}
zrangemap_void.go
//go:generate
./gen-rangemap _RangedMap_void void
zrangemap_void.go
// RangedKeySet is set of Keys with adjacent keys coalesced into Ranges.
//
// Zero value represents empty set.
type
RangedKeySet
struct
{
m
_Ranged
Key
Map_void
// XXX naming
m
_RangedMap_void
// XXX naming
}
// void is used as value type for RangedMap to be used as set.
type
void
struct
{}
func
(
_
void
)
String
()
string
{
return
""
}
// Union returns RangedKeySet(A.keys | B.keys).
...
...
wcfs/internal/xbtree/blib/zrangemap_void.go
0 → 100644
View file @
a6bac322
This diff is collapsed.
Click to expand it.
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