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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
9cbf4ac2
Commit
9cbf4ac2
authored
Feb 14, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
78391c92
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
11 deletions
+88
-11
t/neo/neo.go
t/neo/neo.go
+0
-2
t/neo/storage/fs1/index.go
t/neo/storage/fs1/index.go
+4
-7
t/neo/storage/fs1/index_test.go
t/neo/storage/fs1/index_test.go
+81
-1
t/neo/zodb/zodb.go
t/neo/zodb/zodb.go
+3
-1
No files found.
t/neo/neo.go
View file @
9cbf4ac2
...
@@ -13,8 +13,6 @@ const (
...
@@ -13,8 +13,6 @@ const (
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_TID
zodb
.
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
INVALID_OID
zodb
.
Oid
=
1
<<
64
-
1
// // XXX vvv move to ZODB ?
ZERO_OID
zodb
.
Oid
=
0
// XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8
// OID_LEN = 8
// TID_LEN = 8
// TID_LEN = 8
)
)
t/neo/storage/fs1/index.go
View file @
9cbf4ac2
...
@@ -45,22 +45,19 @@ func fsIndexNew() *fsIndex {
...
@@ -45,22 +45,19 @@ func fsIndexNew() *fsIndex {
}
}
// TODO Encode (__getstate__) ?
// TODO Decode (__setstate__) ?
// NOTE Get/Set/... are taken as-is from fsb.Tree
// NOTE Get/Set/... are taken as-is from fsb.Tree
// on-disk index format
// on-disk index format
// (changed in 2010 in https://github.com/zopefoundation/ZODB/commit/1bb14faf)
// (changed in 2010 in https://github.com/zopefoundation/ZODB/commit/1bb14faf)
//
//
// topPos position pointing just past the last committed transaction
// topPos position pointing just past the last committed transaction
// (oid[:6],
v.toString) # ._data[oid]-> v (fsBucket().toString()
)
// (oid[:6],
fsBucket
)
// (oid[:6],
v.toString
)
// (oid[:6],
fsBucket
)
// ...
// ...
// None
// None
//
//
//
//
// fsBucket
.toString()
:
// fsBucket:
// oid[6:8]oid[6:8]oid[6:8]...pos[0:6]pos[0:6]pos[0:6]...
// oid[6:8]oid[6:8]oid[6:8]...pos[0:6]pos[0:6]pos[0:6]...
...
@@ -103,7 +100,7 @@ func (fsi *fsIndex) Save(topPos int64, w io.Writer) error {
...
@@ -103,7 +100,7 @@ func (fsi *fsIndex) Save(topPos int64, w io.Writer) error {
oid
,
pos
,
errStop
:=
e
.
Next
()
oid
,
pos
,
errStop
:=
e
.
Next
()
oidPrefix
:=
oid
&
oidPrefixMask
oidPrefix
:=
oid
&
oidPrefixMask
if
oidPrefix
!=
oidPrefixCur
{
if
oidPrefix
!=
oidPrefixCur
||
errStop
!=
nil
{
// emit (oid[:6], oid[6:8]oid[6:8]...pos[0:6]pos[0:6]...)
// emit (oid[:6], oid[6:8]oid[6:8]...pos[0:6]pos[0:6]...)
binary
.
BigEndian
.
PutUint64
(
oidb
[
:
],
uint64
(
oid
))
binary
.
BigEndian
.
PutUint64
(
oidb
[
:
],
uint64
(
oid
))
t
[
0
]
=
oidb
[
0
:
6
]
t
[
0
]
=
oidb
[
0
:
6
]
...
...
t/neo/storage/fs1/index_test.go
View file @
9cbf4ac2
...
@@ -3,12 +3,92 @@
...
@@ -3,12 +3,92 @@
package
fs1
package
fs1
import
(
import
(
"sort"
"testing"
"testing"
"../../zodb"
)
)
type
indexEntry
struct
{
oid
zodb
.
Oid
pos
int64
}
type
byOid
[]
indexEntry
func
(
p
byOid
)
Len
()
int
{
return
len
(
p
)
}
func
(
p
byOid
)
Swap
(
i
,
j
int
)
{
p
[
i
],
p
[
j
]
=
p
[
j
],
p
[
i
]
}
func
(
p
byOid
)
Less
(
i
,
j
int
)
bool
{
return
p
[
i
]
.
oid
<
p
[
j
]
.
oid
}
func
TestIndexLookup
(
t
*
testing
.
T
)
{
func
TestIndexLookup
(
t
*
testing
.
T
)
{
// the lookup is tested in cznic.b itself
// the lookup is tested in cznic.b itself
// here we only lightly excersize it
// here we only lightly exercise it
fsi
:=
fsIndexNew
()
if
fsi
.
Len
()
!=
0
{
t
.
Errorf
(
"index created non empty"
)
}
tt
:=
[
...
]
indexEntry
{
{
0x0000000000000000
,
111
},
{
0x0000000000000001
,
222
},
{
0x000000000000ffff
,
333
},
{
0x0000000000001234
,
444
},
{
0x0000000000010002
,
555
},
{
0x0000000000010001
,
665
},
{
0xffffffffffffffff
,
777
},
{
0xfffffffffffffff0
,
888
},
{
0x8000000000000000
,
999
},
{
0xa000000000000000
,
0x7fffffffffffffff
},
}
// set
for
_
,
entry
:=
range
tt
{
fsi
.
Set
(
entry
.
oid
,
entry
.
pos
)
}
// get
for
_
,
entry
:=
range
tt
{
pos
,
ok
:=
fsi
.
Get
(
entry
.
oid
)
if
!
(
pos
==
entry
.
pos
&&
ok
==
true
)
{
t
.
Errorf
(
"fsi[%x] -> got (%x, %v) ; want (%x, true)"
,
entry
.
oid
,
pos
,
ok
,
entry
.
pos
)
}
// try non-existing entries too
oid
:=
entry
.
oid
^
(
1
<<
32
)
pos
,
ok
=
fsi
.
Get
(
oid
)
if
!
(
pos
==
0
&&
ok
==
false
)
{
t
.
Errorf
(
"fsi[%x] -> got (%x, %v) ; want (0, false)"
,
oid
,
pos
,
ok
)
}
}
// iter
e
,
err
:=
fsi
.
SeekFirst
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sort
.
Sort
(
byOid
(
tt
[
:
]))
i
:=
0
for
;;
i
++
{
oid
,
pos
,
errStop
:=
e
.
Next
()
if
errStop
!=
nil
{
break
}
entry
:=
indexEntry
{
oid
,
pos
}
entryOk
:=
tt
[
i
]
if
entry
!=
entryOk
{
t
.
Errorf
(
"iter step %d: got %v ; want %v"
,
i
,
entry
,
entryOk
)
}
}
if
i
!=
len
(
tt
)
{
t
.
Errorf
(
"iter ended at step %v ; want %v"
,
i
,
len
(
tt
))
}
}
}
...
...
t/neo/zodb/zodb.go
View file @
9cbf4ac2
...
@@ -17,10 +17,12 @@ type Xid struct {
...
@@ -17,10 +17,12 @@ type Xid struct {
*/
*/
const
(
const
(
Tid0
Tid
=
0
Tid0
Tid
=
0
// XXX or simply Tid(0) ?
TidMax
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
TidMax
Tid
=
1
<<
63
-
1
// 0x7fffffffffffffff
// ZODB defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
// ZODB defines maxtid to be max signed int64 since baee84a6 (Jun 7 2016)
// (XXX in neo: SQLite does not accept numbers above 2^63-1)
// (XXX in neo: SQLite does not accept numbers above 2^63-1)
Oid0
Oid
=
0
)
)
// ----------------------------------------
// ----------------------------------------
...
...
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