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
baf0c4b6
Commit
baf0c4b6
authored
Feb 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c77264f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
16 deletions
+31
-16
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+24
-10
t/neo/storage/fs1/filestorage_test.go
t/neo/storage/fs1/filestorage_test.go
+6
-5
t/neo/zodb/zodb.go
t/neo/zodb/zodb.go
+1
-1
No files found.
t/neo/storage/fs1/filestorage.go
View file @
baf0c4b6
...
...
@@ -28,6 +28,8 @@ import (
type
FileStorage
struct
{
f
*
os
.
File
// XXX naming -> file ?
index
*
fsIndex
topPos
int64
// position pointing just past last committed transaction
// (= size(f) when no commit is in progress)
}
// IStorage
...
...
@@ -188,8 +190,15 @@ func OpenFileStorage(path string) (*FileStorage, error) {
return
nil
,
err
// XXX err more context ?
}
// TODO read file header
//Read(f, 4) != "FS21" -> invalid header
// check file magic
var
xxx
[
4
]
byte
_
,
err
=
f
.
ReadAt
(
xxx
[
:
],
0
)
if
err
!=
nil
{
return
nil
,
err
// XXX err more context
}
if
string
(
xxx
[
:
])
!=
"FS21"
{
return
nil
,
fmt
.
Errorf
(
"%s: invalid magic %q"
,
path
,
xxx
)
// XXX err?
}
// TODO recreate index if missing / not sane
// TODO verify index sane / topPos matches
...
...
@@ -198,9 +207,7 @@ func OpenFileStorage(path string) (*FileStorage, error) {
panic
(
err
)
// XXX err
}
_
=
topPos
return
&
FileStorage
{
f
:
f
,
index
:
index
},
nil
return
&
FileStorage
{
f
:
f
,
index
:
index
,
topPos
:
topPos
},
nil
}
...
...
@@ -314,11 +321,18 @@ func (fs *FileStorage) StorageName() string {
return
"FileStorage v1"
}
func
(
fs
*
FileStorage
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
if
tidMin
!=
zodb
.
Tid
(
0
)
||
tidMax
!=
zodb
.
TidMax
{
panic
(
"TODO tidMin/tidMax support"
)
}
type
FileStorageIterator
struct
{
txnPos
int64
// current (?) transaction position
tidMin
,
tidMax
zodb
.
Tid
// iteration range
}
func
(
fsi
*
FileStorageIterator
)
NextTxn
(
txnInfo
*
zodb
.
TxnInfo
)
(
dataIter
zodb
.
IStorageRecordIterator
,
stop
bool
,
err
error
)
{
// TODO
return
nil
return
}
func
(
fs
*
FileStorage
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
return
&
FileStorageIterator
{
-
1
,
tidMin
,
tidMax
}
// XXX -1 ok ?
}
t/neo/storage/fs1/filestorage_test.go
View file @
baf0c4b6
...
...
@@ -102,6 +102,7 @@ func TestLoad(t *testing.T) {
}
tidv
=
append
(
tidv
,
zodb
.
TidMax
)
// XXX i -> iMin, j -> iMax ?
for
i
,
tidMin
:=
range
tidv
{
for
j
,
tidMax
:=
range
tidv
{
_
=
j
// XXX
...
...
@@ -114,18 +115,18 @@ func TestLoad(t *testing.T) {
txni
:=
zodb
.
TxnInfo
{}
datai
:=
zodb
.
StorageRecordInformation
{}
// XXX vvv assumes i < j
// FIXME first tidMin and last tidMax
for
k
:=
i
;
;
k
++
{
for
k
:=
0
;
;
k
++
{
dataIter
,
stop
,
err
:=
iter
.
NextTxn
(
&
txni
)
if
stop
||
err
!=
nil
{
break
}
dbe
:=
_1fs_dbEntryv
[
k
]
// XXX vvv assumes i < j
// FIXME first tidMin and last tidMax
dbe
:=
_1fs_dbEntryv
[
i
+
k
]
if
!
reflect
.
DeepEqual
(
txni
,
dbe
.
Header
.
TxnInfo
)
{
t
.
Errorf
(
"iterating
tidMin..tidMac (TODO): step XXX: unexpected txn entry.
\n
have: %v
\n
want: %v"
,
txni
,
dbe
.
Header
.
TxnInfo
)
t
.
Errorf
(
"iterating
%v..%v: step %v: unexpected txn entry:
\n
have: %q
\n
want: %q"
,
tidMin
,
tidMax
,
k
,
txni
,
dbe
.
Header
.
TxnInfo
)
}
for
{
...
...
t/neo/zodb/zodb.go
View file @
baf0c4b6
...
...
@@ -147,7 +147,7 @@ type IStorage interface {
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
Iterate
(
tidMin
,
tidMax
Tid
)
IStorageIterator
// XXX -> Iter()
?
Iterate
(
tidMin
,
tidMax
Tid
)
IStorageIterator
// XXX , error
?
}
type
IStorageIterator
interface
{
...
...
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