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
a458126e
Commit
a458126e
authored
Jun 30, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3a573dc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
249 additions
and
5 deletions
+249
-5
wcfs/internal/set/set.go
wcfs/internal/set/set.go
+4
-3
wcfs/internal/set/zset_str.go
wcfs/internal/set/zset_str.go
+167
-0
wcfs/internal/zdata/δftail.go
wcfs/internal/zdata/δftail.go
+2
-2
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+76
-0
No files found.
wcfs/internal/set/set.go
View file @
a458126e
...
...
@@ -20,6 +20,7 @@
package
set
//go:generate ./gen-set set I64 int64 zset_i64.go
//go:generate ./gen-set set Str string zset_str.go
//go:generate ./gen-set set Oid _Oid zset_oid.go
//go:generate ./gen-set set Tid _Tid zset_tid.go
...
...
wcfs/internal/set/zset_str.go
0 → 100644
View file @
a458126e
// Code generated by gen-set Str string; DO NOT EDIT.
// Copyright (C) 2015-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
set
import
(
"fmt"
"sort"
"strings"
)
// SetStr is a set of string.
type
SetStr
map
[
string
]
struct
{}
// Add adds v to the set.
func
(
s
SetStr
)
Add
(
v
string
)
{
s
[
v
]
=
struct
{}{}
}
// Del removes v from the set.
// it is noop if v was not in the set.
func
(
s
SetStr
)
Del
(
v
string
)
{
delete
(
s
,
v
)
}
// Has checks whether the set contains v.
func
(
s
SetStr
)
Has
(
v
string
)
bool
{
_
,
ok
:=
s
[
v
]
return
ok
}
// Update adds t values to s.
func
(
s
SetStr
)
Update
(
t
SetStr
)
{
for
v
:=
range
t
{
s
.
Add
(
v
)
}
}
// Elements returns all elements of set as slice.
func
(
s
SetStr
)
Elements
()
[]
string
{
ev
:=
make
([]
string
,
len
(
s
))
i
:=
0
for
e
:=
range
s
{
ev
[
i
]
=
e
i
++
}
return
ev
}
// Union returns s ∪ t
func
(
s
SetStr
)
Union
(
t
SetStr
)
SetStr
{
// l = max(len(s), len(t))
l
:=
len
(
s
)
if
lt
:=
len
(
t
);
lt
>
l
{
l
=
lt
}
u
:=
make
(
SetStr
,
l
)
for
v
:=
range
s
{
u
.
Add
(
v
)
}
for
v
:=
range
t
{
u
.
Add
(
v
)
}
return
u
}
// Intersection returns s ∩ t
func
(
s
SetStr
)
Intersection
(
t
SetStr
)
SetStr
{
i
:=
SetStr
{}
for
v
:=
range
s
{
if
t
.
Has
(
v
)
{
i
.
Add
(
v
)
}
}
return
i
}
// Difference returns s\t.
func
(
s
SetStr
)
Difference
(
t
SetStr
)
SetStr
{
d
:=
SetStr
{}
for
v
:=
range
s
{
if
!
t
.
Has
(
v
)
{
d
.
Add
(
v
)
}
}
return
d
}
// SymmetricDifference returns s Δ t.
func
(
s
SetStr
)
SymmetricDifference
(
t
SetStr
)
SetStr
{
d
:=
SetStr
{}
for
v
:=
range
s
{
if
!
t
.
Has
(
v
)
{
d
.
Add
(
v
)
}
}
for
v
:=
range
t
{
if
!
s
.
Has
(
v
)
{
d
.
Add
(
v
)
}
}
return
d
}
// Equal returns whether a == b.
func
(
a
SetStr
)
Equal
(
b
SetStr
)
bool
{
if
len
(
a
)
!=
len
(
b
)
{
return
false
}
for
v
:=
range
a
{
_
,
ok
:=
b
[
v
]
if
!
ok
{
return
false
}
}
return
true
}
// Clone returns copy of the set.
func
(
orig
SetStr
)
Clone
()
SetStr
{
klon
:=
make
(
SetStr
,
len
(
orig
))
for
v
:=
range
orig
{
klon
.
Add
(
v
)
}
return
klon
}
// --------
func
(
s
SetStr
)
SortedElements
()
[]
string
{
ev
:=
s
.
Elements
()
sort
.
Slice
(
ev
,
func
(
i
,
j
int
)
bool
{
return
ev
[
i
]
<
ev
[
j
]
})
return
ev
}
func
(
s
SetStr
)
String
()
string
{
ev
:=
s
.
SortedElements
()
strv
:=
make
([]
string
,
len
(
ev
))
for
i
,
v
:=
range
ev
{
strv
[
i
]
=
fmt
.
Sprintf
(
"%v"
,
v
)
}
return
"{"
+
strings
.
Join
(
strv
,
" "
)
+
"}"
}
wcfs/internal/zdata/δftail.go
View file @
a458126e
...
...
@@ -103,8 +103,8 @@ type ΔF struct {
// ΔFile represents a change to one file.
type
ΔFile
struct
{
Rev
zodb
.
Tid
Blocks
SetI64
// changed blocks
Size
bool
// whether file size changed
Blocks
SetI64
// changed blocks
XXX -> ΔBlocks ?
Size
bool
// whether file size changed
XXX -> ΔSize?
}
// zblkInΔFtail is ΔFtail-related volatile data embedded into ZBlk*.
...
...
wcfs/internal/zdata/δftail_test.go
View file @
a458126e
...
...
@@ -21,9 +21,85 @@ package zdata
import
(
"testing"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/set"
)
type
SetStr
=
set
.
SetStr
// ΔFTestEntry represents one entry in ΔFtail tests.
type
ΔFTestEntry
struct
{
δblkTab
map
[
int64
]
string
// change in tree part {} #blk -> ZBlk<oid>
δblkData
SetStr
// change to ZBlk objects
}
func
TestΔFtail
(
t
*
testing
.
T
)
{
// δT is shorthand to create δblkTab.
type
δT
=
map
[
int64
]
string
// δD is shorthand to create δblkData.
δD
:=
func
(
zblkv
...
string
)
SetStr
{
δ
:=
SetStr
{}
for
_
,
zblk
:=
range
zblkv
{
δ
.
Add
(
zblk
)
}
return
δ
}
const
a
,
b
,
c
,
ø
=
"a"
,
"b"
,
"c"
,
"ø"
testv
:=
[]
ΔFTestEntry
{
{
δT
{
1
:
a
,
2
:
b
,
3
:
ø
},
δD
(
a
)},
{
δT
{},
δD
(
c
)},
{
δT
{
2
:
c
},
δD
(
a
,
b
)},
}
vδf
:=
[]
ΔFile
{}
// (rev↑, {}blk) XXX +.Size?
blkTab
:=
map
[
int64
]
string
{}
// #blk -> ZBlk<oid>
Zinblk
:=
map
[
string
]
SetI64
{}
// ZBlk<oid> -> which #blk refer to it
for
_
,
test
:=
range
testv
{
δf
:=
SetI64
{}
for
blk
,
zblk
:=
range
test
.
δblkTab
{
// rebuild blkTab/Zinblk
zprev
,
ok
:=
blkTab
[
blk
]
if
ok
{
delete
(
Zinblk
[
zprev
],
blk
)
}
else
{
zprev
=
ø
}
if
zblk
!=
ø
{
blkTab
[
blk
]
=
zblk
inblk
,
ok
:=
Zinblk
[
zblk
]
if
!
ok
{
inblk
=
SetI64
{}
Zinblk
[
zblk
]
=
inblk
}
inblk
.
Add
(
blk
)
}
// update δf due to change in blkTab
if
zblk
!=
zprev
{
δf
.
Add
(
blk
)
}
}
// update δf due to change in ZBlk data
for
zblk
:=
range
test
.
δblkData
{
for
blk
:=
range
Zinblk
[
zblk
]
{
δf
.
Add
(
blk
)
}
}
vδf
=
append
(
vδf
,
ΔFile
{
Rev
:
zodb
.
InvalidTid
,
// XXX will be set after treegen commit
Blocks
:
δf
,
Size
:
false
/*XXX*/
,
})
}
}
// XXX TestΔFtailRandom(t *testing.T) {
...
...
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