Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
8cde7ef9
Commit
8cde7ef9
authored
Feb 16, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
55f5a80c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
1 deletion
+121
-1
t/neo/storage/fs1/fsb/fsbtree_util.go
t/neo/storage/fs1/fsb/fsbtree_util.go
+97
-0
t/neo/storage/fs1/fsb/gen-fsbtree
t/neo/storage/fs1/fsb/gen-fsbtree
+23
-0
t/neo/storage/fs1/index_test.go
t/neo/storage/fs1/index_test.go
+1
-1
No files found.
t/neo/storage/fs1/fsb/fsbtree_util.go
0 → 100644
View file @
8cde7ef9
// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from github.com/cznic/b bcff30a)
// ---- 8< ----
package
fsb
import
(
"bytes"
"github.com/cznic/strutil"
// XXX better to not depend on it
)
func
isNil
(
p
interface
{})
bool
{
switch
x
:=
p
.
(
type
)
{
case
*
x
:
if
x
==
nil
{
return
true
}
case
*
d
:
if
x
==
nil
{
return
true
}
}
return
false
}
func
(
t
*
Tree
)
dump
()
string
{
var
buf
bytes
.
Buffer
f
:=
strutil
.
IndentFormatter
(
&
buf
,
"
\t
"
)
num
:=
map
[
interface
{}]
int
{}
visited
:=
map
[
interface
{}]
bool
{}
handle
:=
func
(
p
interface
{})
int
{
if
isNil
(
p
)
{
return
0
}
if
n
,
ok
:=
num
[
p
];
ok
{
return
n
}
n
:=
len
(
num
)
+
1
num
[
p
]
=
n
return
n
}
var
pagedump
func
(
interface
{},
string
)
pagedump
=
func
(
p
interface
{},
pref
string
)
{
if
isNil
(
p
)
||
visited
[
p
]
{
return
}
visited
[
p
]
=
true
switch
x
:=
p
.
(
type
)
{
case
*
x
:
h
:=
handle
(
p
)
n
:=
0
for
i
,
v
:=
range
x
.
x
{
if
v
.
ch
!=
nil
||
true
{
n
=
i
+
1
}
}
f
.
Format
(
"%sX#%d(%p) n %d:%d {"
,
pref
,
h
,
x
,
x
.
c
,
n
)
a
:=
[]
interface
{}{}
for
i
,
v
:=
range
x
.
x
[
:
n
]
{
a
=
append
(
a
,
v
.
ch
)
if
i
!=
0
{
f
.
Format
(
" "
)
}
f
.
Format
(
"(C#%d K %v)"
,
handle
(
v
.
ch
),
v
.
k
)
}
f
.
Format
(
"}
\n
"
)
for
_
,
p
:=
range
a
{
pagedump
(
p
,
pref
+
". "
)
}
case
*
d
:
h
:=
handle
(
p
)
n
:=
0
for
i
,
v
:=
range
x
.
d
{
if
true
||
(
true
||
&
v
!=
nil
)
{
n
=
i
+
1
}
}
f
.
Format
(
"%sD#%d(%p) P#%d N#%d n %d:%d {"
,
pref
,
h
,
x
,
handle
(
x
.
p
),
handle
(
x
.
n
),
x
.
c
,
n
)
for
i
,
v
:=
range
x
.
d
[
:
n
]
{
if
i
!=
0
{
f
.
Format
(
" "
)
}
f
.
Format
(
"%v:%v"
,
v
.
k
,
v
.
v
)
}
f
.
Format
(
"}
\n
"
)
}
}
pagedump
(
t
.
r
,
""
)
s
:=
buf
.
String
()
if
s
!=
""
{
s
=
s
[
:
len
(
s
)
-
1
]
}
return
s
}
t/neo/storage/fs1/fsb/gen-fsbtree
View file @
8cde7ef9
...
@@ -26,3 +26,26 @@ make -s -C $Bdir generic |sed \
...
@@ -26,3 +26,26 @@ make -s -C $Bdir generic |sed \
-
e
's/func (p \*btTpool) get(cmp Cmp)/func (p *btTpool) get()/g'
\
-
e
's/func (p \*btTpool) get(cmp Cmp)/func (p *btTpool) get()/g'
\
-
e
'/x\.cmp = cmp$/d'
\
-
e
'/x\.cmp = cmp$/d'
\
>>$
out
>>$
out
#
also
extract
dump
()
routine
out
=
fsbtree_util
.
go
echo
"// DO NOT EDIT - AUTOGENERATED (by gen-fsbtree from $b $Brev)"
>$
out
echo
"// ---- 8< ----"
>>$
out
cat
>>$
out
<<
EOF
package
fsb
import
(
"bytes"
"github.com/cznic/strutil"
//
XXX
better
to
not
depend
on
it
)
EOF
echo
>>$
out
sed
-
n
\
-
e
'/^func isNil(/,/^}/p'
\
-
e
'/^func.* dump()/,/^}/ {
s/v\.k != nil/true/g
s/v\.v != nil/(true || \&v != nil)/g
p
}'
\
\
$
Bdir
/
all_test
.
go
\
>>$
out
t/neo/storage/fs1/index_test.go
View file @
8cde7ef9
...
@@ -161,7 +161,7 @@ func TestIndexSaveLoad(t *testing.T) {
...
@@ -161,7 +161,7 @@ func TestIndexSaveLoad(t *testing.T) {
// XXX is it ok to compare trees via reflect.DeepEqual ?
// XXX is it ok to compare trees via reflect.DeepEqual ?
if
!
treeEqual
(
fsi2
.
Tree
,
fsi
.
Tree
)
{
if
!
treeEqual
(
fsi2
.
Tree
,
fsi
.
Tree
)
{
t
.
Errorf
(
"index load: trees mismatch: %v ; want %v"
,
fsi2
.
Tree
,
fsi
.
Tree
)
t
.
Errorf
(
"index load: trees mismatch: %v ; want %v"
,
fsi2
.
Tree
.
dump
(),
fsi
.
Tree
.
dump
()
)
}
}
...
...
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