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
5a23e03b
Commit
5a23e03b
authored
Sep 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1a2c3afd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
1 deletion
+122
-1
wcfs/internal/xbtree/blib/rangemap.go
wcfs/internal/xbtree/blib/rangemap.go
+116
-0
wcfs/internal/xbtree/blib/rangeset.go
wcfs/internal/xbtree/blib/rangeset.go
+2
-1
wcfs/internal/xbtree/δbtail.go
wcfs/internal/xbtree/δbtail.go
+4
-0
No files found.
wcfs/internal/xbtree/blib/rangemap.go
0 → 100644
View file @
5a23e03b
// 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
// map [lo,hi) Key ranges to values.
import
(
"fmt"
)
const
traceRangeMap
=
true
const
debugRangeMap
=
true
type
VALUE
=
interface
{}
// RangedMap is Key->VALUE map with adjacent keys mapped to the same value coalesced into Ranges.
//
// Zero value represents empty map.
type
RangedMap
struct
{
// XXX -> BTree
entryv
[]
mapEntry
// lo↑
}
type
mapEntry
struct
{
keycov
KeyRange
value
VALUE
}
// Set changes m to map key k to value v.
func
(
m
*
RangedMap
)
Set
(
k
Key
,
v
VALUE
)
{
m
.
SetRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
},
v
)
}
// Del removes key k.
func
(
m
*
RangedMap
)
Del
(
k
Key
)
{
m
.
DelRange
(
KeyRange
{
Lo
:
k
,
Hi_
:
k
})
}
// Has returns whether key k is present in the map.
func
(
m
*
RangedMap
)
Has
(
k
Key
)
bool
{
_
,
ok
:=
m
.
Get_
(
k
)
return
ok
}
// Get returns value associated with key k.
func
(
m
*
RangedMap
)
Get
(
k
Key
)
VALUE
{
v
,
_
:=
m
.
Get_
(
k
)
return
v
}
// Get_ is comma-ok version of Get.
func
(
m
*
RangedMap
)
Get_
(
k
Key
)
(
VALUE
,
bool
)
{
panic
(
"TODO"
)
// XXX
}
// SetRange changes m to map key range r to value v.
func
(
m
*
RangedMap
)
SetRange
(
r
KeyRange
,
v
VALUE
)
{
panic
(
"TODO"
)
// XXX
}
// DelRange removes range r from the map.
func
(
m
*
RangedMap
)
DelRange
(
r
KeyRange
)
{
panic
(
"TODO"
)
// XXX
}
// XXX HasRange ?
// --------
// verify checks RangedMap for internal consistency:
// - XXX
func
(
m
*
RangedMap
)
verify
()
{
// XXX
}
// Empty returns whether the map is empty.
func
(
m
*
RangedMap
)
Empty
()
bool
{
return
len
(
m
.
entryv
)
==
0
}
// XXX Equal ?
// XXX Clear ?
// XXX AllEntries ?
func
(
m
*
RangedMap
)
String
()
string
{
s
:=
"{"
for
i
,
e
:=
range
m
.
entryv
{
if
i
>
0
{
s
+=
" "
}
s
+=
fmt
.
Sprintf
(
"%s:%v"
,
e
.
keycov
,
e
.
value
)
}
s
+=
"}"
return
s
}
wcfs/internal/xbtree/blib/rangeset.go
View file @
5a23e03b
...
@@ -294,7 +294,7 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) {
...
@@ -294,7 +294,7 @@ func (A *RangedKeySet) DifferenceInplace(B *RangedKeySet) {
// --------
// --------
// verify check RangedKeySet for internal consistency:
// verify check
s
RangedKeySet for internal consistency:
// - ranges must be not overlapping nor adjacent and ↑
// - ranges must be not overlapping nor adjacent and ↑
func
(
S
*
RangedKeySet
)
verify
()
{
func
(
S
*
RangedKeySet
)
verify
()
{
// TODO !debug -> return
// TODO !debug -> return
...
@@ -365,6 +365,7 @@ func (S *RangedKeySet) AllRanges() /*readonly*/[]KeyRange {
...
@@ -365,6 +365,7 @@ func (S *RangedKeySet) AllRanges() /*readonly*/[]KeyRange {
return
S
.
rangev
return
S
.
rangev
}
}
// XXX -> ptr?
func
(
S
RangedKeySet
)
String
()
string
{
func
(
S
RangedKeySet
)
String
()
string
{
s
:=
"{"
s
:=
"{"
for
i
,
r
:=
range
S
.
rangev
{
for
i
,
r
:=
range
S
.
rangev
{
...
...
wcfs/internal/xbtree/δbtail.go
View file @
5a23e03b
...
@@ -160,7 +160,9 @@ type _ΔTtail struct {
...
@@ -160,7 +160,9 @@ type _ΔTtail struct {
// set of nodes that were requested to be tracked in this tree, but for
// set of nodes that were requested to be tracked in this tree, but for
// which vδT was not yet rebuilt
// which vδT was not yet rebuilt
trackNew
blib
.
PPTreeSubSet
trackNew
blib
.
PPTreeSubSet
// XXX + trackNewKeys RangedKeySet (concurrency)
// XXX + trackNewKeys RangedKeySet (concurrency)
// XXX + trackSetKeys RangedKeySet
}
}
// _ΔBroots represents roots-only part of ΔB.
// _ΔBroots represents roots-only part of ΔB.
...
@@ -882,6 +884,8 @@ func (δBtail *ΔBtail) GetAt(root zodb.Oid, key Key, at zodb.Tid) (value Value,
...
@@ -882,6 +884,8 @@ func (δBtail *ΔBtail) GetAt(root zodb.Oid, key Key, at zodb.Tid) (value Value,
rev
=
tail
rev
=
tail
revExact
=
false
revExact
=
false
// XXX need to rebuild only if key was not rebuilt yet
// XXX need to rebuild only for key, not for whole trackNew
err
=
δBtail
.
rebuild1IfNeeded
(
root
)
err
=
δBtail
.
rebuild1IfNeeded
(
root
)
if
err
!=
nil
{
if
err
!=
nil
{
return
value
,
rev
,
valueExact
,
revExact
,
err
return
value
,
rev
,
valueExact
,
revExact
,
err
...
...
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