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
9feea1a4
Commit
9feea1a4
authored
Jul 09, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3c40e38d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
36 deletions
+68
-36
wcfs/internal/xbtree/xbtreetest/treeenv.go
wcfs/internal/xbtree/xbtreetest/treeenv.go
+40
-30
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+28
-6
No files found.
wcfs/internal/xbtree/xbtreetest/treeenv.go
View file @
9feea1a4
...
...
@@ -56,8 +56,13 @@ type Commit struct {
ΔZ
*
zodb
.
EventCommit
// raw ZODB changes; δZ.tid == at
Xkv
RBucketSet
// full tree state as of @at
Δxkv
map
[
Key
]
Δstring
// full tree-diff against parent
ZBlkDataTab
map
[
zodb
.
Oid
]
string
// full snapshot of all ZBlk data @at
// δzblkData map[zodb.Oid]Δstring // full diff for zblkData against parent XXX ?
ZBlkTab
map
[
zodb
.
Oid
]
ZBlkInfo
// full snapshot of all ZBlk name/data @at
}
// ZBlkInfo describes one ZBlk object.
type
ZBlkInfo
struct
{
Name
string
// this ZBlk comes under root['treegen/values'][Name]
Data
string
}
// NewT creates new T.
...
...
@@ -97,7 +102,7 @@ func NewT(t *testing.T) *T {
Prev
:
nil
,
At
:
head
,
Xkv
:
xGetTree
(
tt
.
DB
,
head
,
tt
.
Root
()),
ZBlk
DataTab
:
xGetBlkData
Tab
(
tt
.
DB
,
head
),
ZBlk
Tab
:
xGetBlk
Tab
(
tt
.
DB
,
head
),
ΔZ
:
nil
,
Δxkv
:
nil
,
}
...
...
@@ -182,7 +187,7 @@ func (t *T) CommitTree(tree string) *Commit {
At
:
δZ
.
Tid
,
ΔZ
:
δZ
,
Xkv
:
xkv
,
ZBlk
DataTab
:
xGetBlkData
Tab
(
t
.
DB
,
δZ
.
Tid
),
ZBlk
Tab
:
xGetBlk
Tab
(
t
.
DB
,
δZ
.
Tid
),
}
tprev
:=
t
.
Head
()
...
...
@@ -194,14 +199,14 @@ func (t *T) CommitTree(tree string) *Commit {
return
ttree
}
// xGetBlk
Data
Tab loads all ZBlk from db@at.
// xGetBlkTab loads all ZBlk from db@at.
//
// it returns {} oid -> blkdata.
func
xGetBlk
DataTab
(
db
*
zodb
.
DB
,
at
zodb
.
Tid
)
map
[
zodb
.
Oid
]
string
{
defer
exc
.
Contextf
(
"%s: @%s: get blk
data
tab"
,
db
.
Storage
()
.
URL
(),
at
)
func
xGetBlk
Tab
(
db
*
zodb
.
DB
,
at
zodb
.
Tid
)
map
[
zodb
.
Oid
]
ZBlkInfo
{
defer
exc
.
Contextf
(
"%s: @%s: get blktab"
,
db
.
Storage
()
.
URL
(),
at
)
X
:=
exc
.
Raiseif
blk
DataTab
:=
map
[
zodb
.
Oid
]
string
{}
blk
Tab
:=
map
[
zodb
.
Oid
]
ZBlkInfo
{}
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
...
...
@@ -228,18 +233,23 @@ func xGetBlkDataTab(db *zodb.DB, at zodb.Tid) map[zodb.Oid]string {
err
=
zblkdir
.
PActivate
(
ctx
);
X
(
err
)
defer
zblkdir
.
PDeactivate
()
for
k
,
xzblk
:=
range
zblkdir
.
Data
{
for
xname
,
xzblk
:=
range
zblkdir
.
Data
{
name
,
ok
:=
xname
.
(
string
)
if
!
ok
{
exc
.
Raisef
(
"root['treegen/values']: key [%q]: expected str, got %T"
,
xname
,
xname
)
}
zblk
,
ok
:=
xzblk
.
(
zodb
.
IPersistent
)
if
!
ok
{
exc
.
Raisef
(
"root['treegen/values'][%q]: expected IPersistent, got %s"
,
k
,
xzodb
.
TypeOf
(
xzblk
))
exc
.
Raisef
(
"root['treegen/values'][%q]: expected IPersistent, got %s"
,
name
,
xzodb
.
TypeOf
(
xzblk
))
}
oid
:=
zblk
.
POid
()
data
:=
xzgetBlkData
(
ctx
,
zconn
,
oid
)
blk
DataTab
[
oid
]
=
data
blk
Tab
[
oid
]
=
ZBlkInfo
{
name
,
data
}
}
return
blk
Data
Tab
return
blkTab
}
// XGetBlkData loads blk data for ZBlk<oid> @t.at
...
...
@@ -249,11 +259,11 @@ func (t *Commit) XGetBlkData(oid zodb.Oid) string {
if
oid
==
VDEL
{
return
DEL
}
data
,
ok
:=
t
.
ZBlkData
Tab
[
oid
]
zblki
,
ok
:=
t
.
ZBlk
Tab
[
oid
]
if
!
ok
{
exc
.
Raisef
(
"getBlkData ZBlk<%s> @%s: no such ZBlk"
,
oid
,
t
.
At
)
}
return
d
ata
return
zblki
.
D
ata
}
...
...
wcfs/internal/zdata/δftail_test.go
View file @
9feea1a4
...
...
@@ -82,6 +82,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
err
=
zroot
.
PActivate
(
ctx
);
X
(
err
)
defer
zroot
.
PDeactivate
()
zfile
:=
zroot
.
Data
[
"treegen/file"
]
.
(
*
ZBigFile
)
zfileOid
:=
zfile
.
POid
()
err
=
zfile
.
PActivate
(
ctx
);
X
(
err
)
defer
zfile
.
PDeactivate
()
if
treeOid
:=
zfile
.
blktab
.
POid
();
treeOid
!=
t
.
Root
()
{
...
...
@@ -103,9 +104,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
Zinblk
:=
map
[
string
]
setI64
{}
// ZBlk<name> -> which #blk refer to it
// initialize dataTab from root['treegen/values']
for
/*oid*/
_
,
zblk
:=
range
t
.
Head
()
.
ZBlkDataTab
{
// treegen initializes values[x] = ZBlk(x)
dataTab
[
zblk
]
=
zblk
for
/*oid*/
_
,
zblki
:=
range
t
.
Head
()
.
ZBlkTab
{
dataTab
[
zblki
.
Name
]
=
zblki
.
Data
}
...
...
@@ -186,7 +186,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
δfilesOK
:=
setOid
{}
if
δfok
!=
nil
{
δfilesOK
.
Add
(
zfile
.
POid
()
)
δfilesOK
.
Add
(
zfile
Oid
)
}
if
!
δfiles
.
Equal
(
δfilesOK
)
{
t
.
Errorf
(
"wrong δF.ByFile:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
...
...
@@ -198,9 +198,31 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
// verify δf
δf
:=
δF
.
ByFile
[
zfile
.
POid
()
]
δf
:=
δF
.
ByFile
[
zfile
Oid
]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"wrong δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// verify δftail.trackSetZBlk
trackZinblk
:=
map
[
string
]
setI64
{}
for
oid
,
zt
:=
range
δftail
.
trackSetZBlk
{
zblki
:=
commit
.
ZBlkTab
[
oid
]
for
foid
,
blocks
:=
range
zt
.
infile
{
if
foid
!=
zfileOid
{
t
.
Errorf
(
".trackSetZBlk: zblk %s points to unexpected file %s"
,
zblki
.
Name
,
foid
)
continue
}
inblk
,
ok
:=
trackZinblk
[
zblki
.
Name
]
if
!
ok
{
inblk
=
setI64
{}
trackZinblk
[
zblki
.
Name
]
=
inblk
}
inblk
.
Update
(
blocks
)
}
}
if
!
reflect
.
DeepEqual
(
trackZinblk
,
Zinblk
)
{
t
.
Errorf
(
".trackSetZBlk:
\n
~have: %v
\n
want: %v"
,
trackZinblk
,
Zinblk
)
}
// XXX ForgePast configure threshold
...
...
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