Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
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
Show 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 (
...
@@ -28,6 +28,8 @@ import (
type
FileStorage
struct
{
type
FileStorage
struct
{
f
*
os
.
File
// XXX naming -> file ?
f
*
os
.
File
// XXX naming -> file ?
index
*
fsIndex
index
*
fsIndex
topPos
int64
// position pointing just past last committed transaction
// (= size(f) when no commit is in progress)
}
}
// IStorage
// IStorage
...
@@ -188,8 +190,15 @@ func OpenFileStorage(path string) (*FileStorage, error) {
...
@@ -188,8 +190,15 @@ func OpenFileStorage(path string) (*FileStorage, error) {
return
nil
,
err
// XXX err more context ?
return
nil
,
err
// XXX err more context ?
}
}
// TODO read file header
// check file magic
//Read(f, 4) != "FS21" -> invalid header
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 recreate index if missing / not sane
// TODO verify index sane / topPos matches
// TODO verify index sane / topPos matches
...
@@ -198,9 +207,7 @@ func OpenFileStorage(path string) (*FileStorage, error) {
...
@@ -198,9 +207,7 @@ func OpenFileStorage(path string) (*FileStorage, error) {
panic
(
err
)
// XXX err
panic
(
err
)
// XXX err
}
}
_
=
topPos
return
&
FileStorage
{
f
:
f
,
index
:
index
,
topPos
:
topPos
},
nil
return
&
FileStorage
{
f
:
f
,
index
:
index
},
nil
}
}
...
@@ -314,11 +321,18 @@ func (fs *FileStorage) StorageName() string {
...
@@ -314,11 +321,18 @@ func (fs *FileStorage) StorageName() string {
return
"FileStorage v1"
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
// 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) {
...
@@ -102,6 +102,7 @@ func TestLoad(t *testing.T) {
}
}
tidv
=
append
(
tidv
,
zodb
.
TidMax
)
tidv
=
append
(
tidv
,
zodb
.
TidMax
)
// XXX i -> iMin, j -> iMax ?
for
i
,
tidMin
:=
range
tidv
{
for
i
,
tidMin
:=
range
tidv
{
for
j
,
tidMax
:=
range
tidv
{
for
j
,
tidMax
:=
range
tidv
{
_
=
j
// XXX
_
=
j
// XXX
...
@@ -114,18 +115,18 @@ func TestLoad(t *testing.T) {
...
@@ -114,18 +115,18 @@ func TestLoad(t *testing.T) {
txni
:=
zodb
.
TxnInfo
{}
txni
:=
zodb
.
TxnInfo
{}
datai
:=
zodb
.
StorageRecordInformation
{}
datai
:=
zodb
.
StorageRecordInformation
{}
// XXX vvv assumes i < j
for
k
:=
0
;
;
k
++
{
// FIXME first tidMin and last tidMax
for
k
:=
i
;
;
k
++
{
dataIter
,
stop
,
err
:=
iter
.
NextTxn
(
&
txni
)
dataIter
,
stop
,
err
:=
iter
.
NextTxn
(
&
txni
)
if
stop
||
err
!=
nil
{
if
stop
||
err
!=
nil
{
break
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
)
{
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
{
for
{
...
...
t/neo/zodb/zodb.go
View file @
baf0c4b6
...
@@ -147,7 +147,7 @@ type IStorage interface {
...
@@ -147,7 +147,7 @@ type IStorage interface {
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
// tpc_abort(txn)
Iterate
(
tidMin
,
tidMax
Tid
)
IStorageIterator
// XXX -> Iter()
?
Iterate
(
tidMin
,
tidMax
Tid
)
IStorageIterator
// XXX , error
?
}
}
type
IStorageIterator
interface
{
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