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
2eee583e
Commit
2eee583e
authored
Jul 26, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fc80052c
Changes
2
Hide 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)
...
@@ -1028,11 +1028,11 @@ func (fs *FileStorage) Load(xid zodb.Xid) (data []byte, tid zodb.Tid, err error)
// --- ZODB-level iteration ---
// --- 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
{
type
zIter
struct
{
iter
Iter
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
zFlags
zIterFlags
...
@@ -1043,7 +1043,7 @@ type zIter struct {
...
@@ -1043,7 +1043,7 @@ type zIter struct {
// here to avoid allocations )
// here to avoid allocations )
dhLoading
DataHeader
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
dataBuf
[]
byte
}
}
...
@@ -1131,7 +1131,7 @@ func (e *iterStartError) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator,
...
@@ -1131,7 +1131,7 @@ func (e *iterStartError) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator,
// Iterate creates zodb-level iterator for tidMin..tidMax range
// Iterate creates zodb-level iterator for tidMin..tidMax range
func
(
fs
*
FileStorage
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
IStorageIterator
{
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
// FIXME case when only 0 or 1 txn present
if
tidMin
<
fs
.
txnhMin
.
Tid
{
if
tidMin
<
fs
.
txnhMin
.
Tid
{
tidMin
=
fs
.
txnhMin
.
Tid
tidMin
=
fs
.
txnhMin
.
Tid
...
@@ -1140,12 +1140,12 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
...
@@ -1140,12 +1140,12 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
tidMax
=
fs
.
txnhMax
.
Tid
tidMax
=
fs
.
txnhMax
.
Tid
}
}
ziter
:=
&
zIter
{
iter
:
Iter
{}}
// when iterating use IO optimized for sequential access
// when iterating use IO optimized for sequential access
// XXX -> IterateRaw ?
// XXX -> IterateRaw ?
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
ziter
.
iter
.
R
=
fsSeq
ziter
:=
&
zIter
{
iter
:
Iter
{
R
:
fsSeq
}}
iter
:=
&
ziter
.
iter
if
tidMin
>
tidMax
{
if
tidMin
>
tidMax
{
ziter
.
zFlags
|=
zIterEOF
// empty
ziter
.
zFlags
|=
zIterEOF
// empty
...
@@ -1153,17 +1153,15 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
...
@@ -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
// 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
)
{
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
.
Dir
=
IterForward
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMin
)
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMin
)
ziter
.
zFlags
=
zIterPreloaded
ziter
.
zFlags
=
zIterPreloaded
ziter
.
TidStop
=
tidMin
-
1
// XXX overflow
ziter
.
TidStop
=
tidMin
-
1
// XXX overflow
}
else
{
}
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
.
Dir
=
IterBackward
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMax
)
iter
.
Txnh
.
CloneFrom
(
&
fs
.
txnhMax
)
ziter
.
zFlags
=
zIterPreloaded
ziter
.
zFlags
=
zIterPreloaded
...
@@ -1203,6 +1201,8 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
...
@@ -1203,6 +1201,8 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
return
ziter
return
ziter
}
}
// --- rebuilding index ---
// computeIndex builds new in-memory index for FileStorage
// computeIndex builds new in-memory index for FileStorage
// XXX naming
// XXX naming
func
(
fs
*
FileStorage
)
computeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
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) {
...
@@ -141,7 +141,12 @@ func TestLoad(t *testing.T) {
// iterate tidMin..tidMax and expect db entries in expectv
// iterate tidMin..tidMax and expect db entries in expectv
func
testIterate
(
t
*
testing
.
T
,
fs
*
FileStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
expectv
[]
dbEntry
)
{
func
testIterate
(
t
*
testing
.
T
,
fs
*
FileStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
expectv
[]
dbEntry
)
{
iter
:=
fs
.
Iterate
(
tidMin
,
tidMax
)
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
++
{
for
k
:=
0
;
;
k
++
{
txnErrorf
:=
func
(
format
string
,
a
...
interface
{})
{
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