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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
459b6060
Commit
459b6060
authored
Jul 21, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bbe228d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+10
-8
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+19
-0
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
459b6060
...
...
@@ -1046,17 +1046,19 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
return
&
Iter
}
// ComputeIndex builds new in-memory index for FileStorage
func
(
fs
*
FileStorage
)
ComputeIndex
(
ctx
context
.
Context
,
path
string
)
(
topPos
int64
,
index
*
Index
,
err
error
)
{
topPos
=
txnValidFrom
// ComputeIndex from scratch builds new in-memory index for FileStorage
// XXX naming
func
(
fs
*
FileStorage
)
ComputeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
// XXX handle ctx cancel
index
=
IndexNew
()
index
.
TopPos
=
txnValidFrom
// similar to Iterate but we know we start from the beginning and do
// not load actual data - only data headers.
// not
want to
load actual data - only data headers.
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
// pre-setup txnh so that txnh.LoadNext starts loading from the beginning of file
txnh
:=
&
TxnHeader
{
Pos
:
0
,
Len
:
t
opPos
,
TxnInfo
:
zodb
.
TxnInfo
{
Tid
:
0
}}
txnh
:=
&
TxnHeader
{
Pos
:
0
,
Len
:
index
.
T
opPos
,
TxnInfo
:
zodb
.
TxnInfo
{
Tid
:
0
}}
dh
:=
&
DataHeader
{}
loop
:
...
...
@@ -1067,7 +1069,7 @@ loop:
break
}
t
opPos
=
txnh
.
Pos
+
txnh
.
Len
index
.
T
opPos
=
txnh
.
Pos
+
txnh
.
Len
// first data iteration will go to first data record
dh
.
Pos
=
txnh
.
DataPos
()
...
...
@@ -1088,7 +1090,7 @@ loop:
}
if
err
!=
nil
{
return
0
,
nil
,
err
return
nil
,
err
}
return
topPos
,
index
,
nil
return
index
,
nil
}
go/zodb/storage/fs1/filestorage_test.go
View file @
459b6060
...
...
@@ -277,6 +277,25 @@ func TestIterate(t *testing.T) {
testIterate
(
t
,
fs
,
0
,
zodb
.
TidMax
,
_1fs_dbEntryv
[
:
])
}
func
TestComputeIndex
(
t
*
testing
.
T
)
{
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
// TODO open ro
defer
exc
.
XRun
(
fs
.
Close
)
index
,
err
:=
fs
.
ComputeIndex
(
context
.
TODO
())
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
indexOk
,
err
:=
LoadIndexFile
(
"testdata/1.fs.index"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
index
.
Equal
(
indexOk
)
{
t
.
Fatal
(
"computed index differ from expected"
)
}
}
func
BenchmarkIterate
(
b
*
testing
.
B
)
{
fs
:=
xfsopen
(
b
,
"testdata/1.fs"
)
// TODO open ro
defer
exc
.
XRun
(
fs
.
Close
)
...
...
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