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
c5b00c4b
Commit
c5b00c4b
authored
Jul 27, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
40e2fe99
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+18
-5
go/zodb/storage/fs1/index.go
go/zodb/storage/fs1/index.go
+1
-3
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
c5b00c4b
...
...
@@ -1258,16 +1258,18 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
// computeIndex builds new in-memory index for FileStorage
// XXX naming
// XXX in case of error return partially built index? (index has .TopPos until which it covers the data)
func
(
fs
*
FileStorage
)
computeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s: reindex"
,
fs
.
file
.
Name
())
index
=
IndexNew
()
index
.
TopPos
=
txnValidFrom
//
similar to Iterate but we know we start from the beginning and do
//
not want to load actual data - only data headers.
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
//
XXX another way to compute index: iterate backwards - then
//
1. index entry for oid is ready right after we see oid the first time
// 2. we can be sure we build the whole index if we saw all oids
fsSeq
:=
xbufio
.
NewSeqReaderAt
(
fs
.
file
)
it
:=
Iterate
(
fsSeq
,
index
.
TopPos
,
IterForward
)
loop
:
...
...
@@ -1312,6 +1314,7 @@ loop:
// loadIndex loads on-disk index to RAM
func
(
fs
*
FileStorage
)
loadIndex
()
error
{
// XXX lock?
defer
xerr
.
Contextf
(
&
err
,
"%s: index load"
,
fs
.
file
.
Name
())
index
,
err
:=
LoadIndexFile
(
fs
.
file
.
Name
()
+
".index"
)
if
err
!=
nil
{
...
...
@@ -1329,10 +1332,20 @@ func (fs *FileStorage) loadIndex() error {
}
// saveIndex flushes in-RAM index to disk
func
(
fs
*
FileStorage
)
saveIndex
()
error
{
func
(
fs
*
FileStorage
)
saveIndex
()
(
err
error
)
{
// XXX lock?
defer
xerr
.
Contextf
(
&
err
,
"%s: index save"
,
fs
.
file
.
Name
())
idxname
:=
fs
.
file
.
Name
()
+
".index"
idxtmp
:=
idxname
+
".index_tmp"
err
:=
fs
.
index
.
SaveFile
(
idxtmp
)
if
err
!=
nil
{
return
err
}
// XXX fsync here?
err
:=
fs
.
index
.
SaveFile
(
fs
.
file
.
Name
()
+
".index"
)
err
=
os
.
Rename
(
idxtmp
,
idxname
)
return
err
}
...
...
go/zodb/storage/fs1/index.go
View file @
c5b00c4b
...
...
@@ -180,9 +180,7 @@ func (fsi *Index) SaveFile(path string) (err error) {
}
}()
err
=
fsi
.
Save
(
f
)
return
return
fsi
.
Save
(
f
)
}
// IndexLoadError is the error type returned by index load routines
...
...
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