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
2eee583e
Commit
2eee583e
authored
Jul 26, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fc80052c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
12 deletions
+17
-12
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+11
-11
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+6
-1
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
2eee583e
...
...
@@ -1028,11 +1028,11 @@ func (fs *FileStorage) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error)
// --- ZODB-level iteration ---
// zIter is combined transaction/data-records iterator as specified by zodb.IStorage
// zIter is combined transaction/data-records iterator as specified by zodb.IStorage
.Iterate
type
zIter
struct
{
iter
Iter
TidStop
zodb
.
Tid
// iterate up to tid <= tidStop | tid >= tidStop depending on .dir
TidStop
zodb
.
Tid
// iterate up to tid <= tidStop | tid >= tidStop depending on
iter
.dir
zFlags
zIterFlags
...
...
@@ -1043,7 +1043,7 @@ type zIter struct {
// here to avoid allocations )
dhLoading
DataHeader
sri
zodb
.
StorageRecordInformation
// ptr to this will be returned by NextData
sri
zodb
.
StorageRecordInformation
// ptr to this will be returned by
.
NextData
dataBuf
[]
byte
}
...
...
@@ -1131,7 +1131,7 @@ func (e *iterStartError) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator,
// Iterate creates zodb-level iterator for tidMin..tidMax range
func
(
fs
*
FileStorage
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
//
fmt.Printf("iterate %v..%v\n", tidMin, tidMax)
fmt
.
Printf
(
"iterate %v..%v
\n
"
,
tidMin
,
tidMax
)
// FIXME case when only 0 or 1 txn present
if
tidMin
<
fs
.
txnhMin
.
Tid
{
tidMin
=
fs
.
txnhMin
.
Tid
...
...
@@ -1140,12 +1140,12 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
tidMax
=
fs
.
txnhMax
.
Tid
}
ziter
:=
&
zIter
{
iter
:
Iter
{}}
// when iterating use IO optimized for sequential access
// XXX -> IterateRaw ?
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
ziter
.
iter
.
R
=
fsSeq
ziter
:=
&
zIter
{
iter
:
Iter
{
R
:
fsSeq
}}
iter
:=
&
ziter
.
iter
if
tidMin
>
tidMax
{
ziter
.
zFlags
|=
zIterEOF
// empty
...
...
@@ -1153,17 +1153,15 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
}
// scan either from file start or end, depending which way it is likely closer, to tidMin
// XXX put iter into ptr to Iter ^^^
iter
:=
&
ziter
.
iter
if
(
tidMin
-
fs
.
txnhMin
.
Tid
)
<
(
fs
.
txnhMax
.
Tid
-
tidMin
)
{
//
fmt.Printf("forward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
fmt
.
Printf
(
"forward %.1f%%
\n
"
,
100
*
float64
(
tidMin
-
fs
.
txnhMin
.
Tid
)
/
float64
(
fs
.
txnhMax
.
Tid
-
fs
.
txnhMin
.
Tid
))
iter
.
Dir
=
IterForward
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMin
)
ziter
.
zFlags
=
zIterPreloaded
ziter
.
TidStop
=
tidMin
-
1
// XXX overflow
}
else
{
//
fmt.Printf("backward %.1f%%\n", 100 * float64(tidMin - fs.txnhMin.Tid) / float64(fs.txnhMax.Tid - fs.txnhMin.Tid))
fmt
.
Printf
(
"backward %.1f%%
\n
"
,
100
*
float64
(
tidMin
-
fs
.
txnhMin
.
Tid
)
/
float64
(
fs
.
txnhMax
.
Tid
-
fs
.
txnhMin
.
Tid
))
iter
.
Dir
=
IterBackward
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMax
)
ziter
.
zFlags
=
zIterPreloaded
...
...
@@ -1203,6 +1201,8 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
return
ziter
}
// --- rebuilding index ---
// computeIndex builds new in-memory index for FileStorage
// XXX naming
func
(
fs
*
FileStorage
)
computeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
2eee583e
...
...
@@ -141,7 +141,12 @@ func TestLoad(t *testing.T) {
// iterate tidMin..tidMax and expect db entries in expectv
func
testIterate
(
t
*
testing
.
T
,
fs
*
FileStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
expectv
[]
dbEntry
)
{
iter
:=
fs
.
Iterate
(
tidMin
,
tidMax
)
fsi
:=
iter
.
(
*
zIter
)
fsi
,
ok
:=
iter
.
(
*
zIter
)
if
!
ok
{
_
,
_
,
err
:=
iter
.
NextTxn
()
t
.
Fatalf
(
"iterating %v..%v: iter type is %T ; want zIter
\n
NextTxn gives: _, _, %v"
,
tidMin
,
tidMax
,
iter
,
err
)
// XXX Errorf
return
}
for
k
:=
0
;
;
k
++
{
txnErrorf
:=
func
(
format
string
,
a
...
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