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
70a447bf
Commit
70a447bf
authored
Jun 17, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
17bc9b4e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
73 deletions
+19
-73
wcfs/zset_tree.go
wcfs/zset_tree.go
+0
-60
wcfs/δbtail.go
wcfs/δbtail.go
+19
-13
No files found.
wcfs/zset_tree.go
deleted
100644 → 0
View file @
17bc9b4e
// Code generated by gen-set Tree *Tree; DO NOT EDIT.
// Copyright (C) 2015-2020 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
main
// SetTree is a set of *Tree.
type
SetTree
map
[
*
Tree
]
struct
{}
// Add adds v to the set.
func
(
s
SetTree
)
Add
(
v
*
Tree
)
{
s
[
v
]
=
struct
{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func
(
s
SetTree
)
Del
(
v
*
Tree
)
{
delete
(
s
,
v
)
}
// Has checks whether the set contains v.
func
(
s
SetTree
)
Has
(
v
*
Tree
)
bool
{
_
,
ok
:=
s
[
v
]
return
ok
}
// Update adds t values to s.
func
(
s
SetTree
)
Update
(
t
SetTree
)
{
for
v
:=
range
t
{
s
.
Add
(
v
)
}
}
// Elements returns all elements of set as slice.
func
(
s
SetTree
)
Elements
()
[]
*
Tree
{
ev
:=
make
([]
*
Tree
,
len
(
s
))
i
:=
0
for
e
:=
range
s
{
ev
[
i
]
=
e
i
++
}
return
ev
}
wcfs/δbtail.go
View file @
70a447bf
...
@@ -21,7 +21,7 @@ package main
...
@@ -21,7 +21,7 @@ package main
// XXX -> Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
// XXX -> Package xbtree complements package lab.nexedi.com/kirr/neo/go/zodb/btree.
// TODO move -> btree when ΔTail matures.
// TODO move -> btree when ΔTail matures.
//go:generate ./gen-set main Tree *Tree zset_tree.go
//
//
go:generate ./gen-set main Tree *Tree zset_tree.go
////go:generate ./gen-set main Value Value zset_value.go
////go:generate ./gen-set main Value Value zset_value.go
//go:generate ./gen-set main Oid Oid zset_oid.go
//go:generate ./gen-set main Oid Oid zset_oid.go
...
@@ -65,11 +65,11 @@ type SetKey = SetI64
...
@@ -65,11 +65,11 @@ type SetKey = SetI64
//
//
// It covers only changes to keys from tracked subset of BTrees parts.
// It covers only changes to keys from tracked subset of BTrees parts.
// In particular a key that was not explicitly requested to be tracked, even if
// In particular a key that was not explicitly requested to be tracked, even if
// it was change
s
in δZ, is not guaranted to be present in δB.
// it was change
d
in δZ, is not guaranted to be present in δB.
//
//
// ΔBtail provides the following operations:
// ΔBtail provides the following operations:
//
//
// .Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].keys
// .Track(path) - start tracking tree nodes and keys; root=path[0], keys=path[-1].keys
XXX keys not correct - e.g. track missing key
//
//
// .Update(δZ) -> δB - update BTree δ tail given raw ZODB changes
// .Update(δZ) -> δB - update BTree δ tail given raw ZODB changes
// .ForgetPast(revCut) - forget changes past revCut
// .ForgetPast(revCut) - forget changes past revCut
...
@@ -93,18 +93,21 @@ type ΔBtail struct {
...
@@ -93,18 +93,21 @@ type ΔBtail struct {
// includes all changed objects, not only tracked ones.
// includes all changed objects, not only tracked ones.
δZtail
*
zodb
.
ΔTail
δZtail
*
zodb
.
ΔTail
δRtail
[]
ΔRoots
// which BTree were changed; Noted only by keys ∈ tracket subset
// XXX vvv keys keys ∈ tracket -> keys ∈ kadj[tracket] ?
byRoot
map
[
*
Tree
]
*
ΔTtail
// root -> k/v change history; only for keys ∈ tracket subset
// δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset
// byRoot map[*Tree]*ΔTtail // root -> k/v change history; only for keys ∈ tracket subset
byRoot
map
[
zodb
.
Oid
]
*
ΔTtail
// root -> k/v change history; only for keys ∈ tracket subset
// XXX or ask client to provide db on every call?
// XXX or ask client to provide db on every call?
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
db
*
zodb
.
DB
// to open connections to load new/old tree|buckets
// tracked index: BTree|Bucket -> top tree element.
// tracked index: BTree|Bucket -> top tree element.
// XXX allow only single root (else it is "tree corrupt") ?
// XXX allow only single root (else it is "tree corrupt") ?
trackIdx
map
[
zodb
.
Oid
]
SetTree
// oid -> {} roots XXX root -> oid
// XXX as of @head state
trackIdx
map
[
zodb
.
Oid
]
SetOid
// oid -> {} roots
// tracked objects that are not yet taken into account in current δBtail
// tracked objects that are not yet taken into account in current δBtail
trackNew
map
[
zodb
.
Oid
]
struct
{}
// XXX
SetOid
trackNew
SetOid
}
}
// ΔB represents a change in BTrees space.
// ΔB represents a change in BTrees space.
...
@@ -113,11 +116,13 @@ type ΔB struct {
...
@@ -113,11 +116,13 @@ type ΔB struct {
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
Value
// {} root -> {}(key, value)
ByRoot
map
[
zodb
.
Oid
]
map
[
Key
]
Value
// {} root -> {}(key, value)
}
}
/*
// ΔRoots describes which BTrees were change in one revision.
// ΔRoots describes which BTrees were change in one revision.
type ΔRoots struct {
type ΔRoots struct {
Rev zodb.Tid
Rev zodb.Tid
Roots []*Tree // root XXX -> Oid? XXX -> SetTree?
Roots []*Tree // root XXX -> Oid? XXX -> SetTree?
}
}
*/
// ΔTtail represent tail of revisional changes to one BTree.
// ΔTtail represent tail of revisional changes to one BTree.
//
//
...
@@ -145,8 +150,8 @@ type ΔTree struct {
...
@@ -145,8 +150,8 @@ type ΔTree struct {
func
NewΔBtail
(
at0
zodb
.
Tid
)
*
ΔBtail
{
func
NewΔBtail
(
at0
zodb
.
Tid
)
*
ΔBtail
{
return
&
ΔBtail
{
return
&
ΔBtail
{
δZtail
:
zodb
.
NewΔTail
(
at0
),
δZtail
:
zodb
.
NewΔTail
(
at0
),
byRoot
:
make
(
map
[
*
Tree
]
*
ΔTtail
),
byRoot
:
make
(
map
[
zodb
.
Oid
]
*
ΔTtail
),
trackIdx
:
make
(
map
[
zodb
.
Oid
]
Set
Tree
),
trackIdx
:
make
(
map
[
zodb
.
Oid
]
Set
Oid
),
}
}
}
}
...
@@ -190,14 +195,15 @@ func (δBtail *ΔBtail) Track(path []Node, flags TrackFlags) { // XXX Tree|Bucke
...
@@ -190,14 +195,15 @@ func (δBtail *ΔBtail) Track(path []Node, flags TrackFlags) { // XXX Tree|Bucke
if
l
==
0
{
if
l
==
0
{
panic
(
"empty path"
)
panic
(
"empty path"
)
}
}
r
oot
:=
path
[
0
]
.
(
*
Tree
)
treeR
oot
:=
path
[
0
]
.
(
*
Tree
)
// XXX assert Tree Tree ... Tree Bucket
// XXX assert Tree Tree ... Tree Bucket
root
:=
treeRoot
.
POid
()
for
_
,
node
:=
range
path
{
for
_
,
node
:=
range
path
{
oid
:=
node
.
POid
()
oid
:=
node
.
POid
()
nodeRoots
,
ok
:=
δBtail
.
trackIdx
[
oid
]
nodeRoots
,
ok
:=
δBtail
.
trackIdx
[
oid
]
if
!
ok
{
if
!
ok
{
nodeRoots
=
make
(
Set
Tree
)
nodeRoots
=
make
(
Set
Oid
)
δBtail
.
trackIdx
[
oid
]
=
nodeRoots
δBtail
.
trackIdx
[
oid
]
=
nodeRoots
// XXX .trackNew += oid
// XXX .trackNew += oid
}
}
...
@@ -231,7 +237,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) ΔB {
...
@@ -231,7 +237,7 @@ func (δBtail *ΔBtail) Update(δZ *zodb.EventCommit) ΔB {
continue
continue
}
}
for
root
:=
range
roots
{
for
root
:=
range
roots
{
δZByRoot
[
root
.
POid
()]
=
append
(
δZByRoot
[
root
.
POid
()
],
oid
)
δZByRoot
[
root
]
=
append
(
δZByRoot
[
root
],
oid
)
}
}
}
}
...
@@ -296,7 +302,7 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T
...
@@ -296,7 +302,7 @@ func (δΒtail *ΔBtail) Get(ctx context.Context, root *Tree, key Key, at zodb.T
// XXX dirty -> rebuild
// XXX dirty -> rebuild
// XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at
// XXX -> index lastXXXOf(key) | linear scan ↓ looking for change <= at
δTtail
:=
δΒtail
.
byRoot
[
root
]
δTtail
:=
δΒtail
.
byRoot
[
root
.
POid
()
]
if
δTtail
==
nil
{
if
δTtail
==
nil
{
panicf
(
"δBtail: root<%s> not tracked"
,
root
.
POid
())
panicf
(
"δBtail: root<%s> not tracked"
,
root
.
POid
())
}
}
...
...
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