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
07b8e592
Commit
07b8e592
authored
Jul 21, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
edee1820
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+1
-1
go/zodb/storage/fs1/index.go
go/zodb/storage/fs1/index.go
+22
-9
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
07b8e592
...
...
@@ -41,7 +41,7 @@ import (
// organized as transactional log.
type
FileStorage
struct
{
file
*
os
.
File
index
*
fs
Index
// oid -> data record position in transaction which last changed oid
index
*
Index
// oid -> data record position in transaction which last changed oid
// transaction headers for min/max transactions committed
// XXX keep loaded with LoadNoStrings ?
...
...
go/zodb/storage/fs1/index.go
View file @
07b8e592
...
...
@@ -43,14 +43,14 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/xio"
)
//
fs
Index is Oid -> Data record position mapping used to associate Oid with
// Index is Oid -> Data record position mapping used to associate Oid with
// Data record in latest transaction which changed it.
type
fs
Index
struct
{
type
Index
struct
{
*
fsb
.
Tree
}
func
fsIndexNew
()
*
fs
Index
{
return
&
fs
Index
{
fsb
.
TreeNew
()}
func
IndexNew
()
*
Index
{
return
&
Index
{
fsb
.
TreeNew
()}
}
...
...
@@ -86,7 +86,7 @@ func (e *IndexSaveError) Error() string {
}
// Save saves index to a writer
func
(
fsi
*
fs
Index
)
Save
(
topPos
int64
,
w
io
.
Writer
)
error
{
func
(
fsi
*
Index
)
Save
(
topPos
int64
,
w
io
.
Writer
)
error
{
var
err
error
{
...
...
@@ -163,7 +163,7 @@ out:
}
// SaveFile saves index to a file
func
(
fsi
*
fs
Index
)
SaveFile
(
topPos
int64
,
path
string
)
(
err
error
)
{
func
(
fsi
*
Index
)
SaveFile
(
topPos
int64
,
path
string
)
(
err
error
)
{
f
,
err
:=
os
.
Create
(
path
)
if
err
!=
nil
{
return
&
IndexSaveError
{
err
}
...
...
@@ -217,7 +217,7 @@ func xint64(xv interface{}) (v int64, ok bool) {
}
// LoadIndex loads index from a reader
func
LoadIndex
(
r
io
.
Reader
)
(
topPos
int64
,
fsi
*
fs
Index
,
err
error
)
{
func
LoadIndex
(
r
io
.
Reader
)
(
topPos
int64
,
fsi
*
Index
,
err
error
)
{
var
picklePos
int64
{
...
...
@@ -239,7 +239,7 @@ func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) {
goto
out
}
fsi
=
fs
IndexNew
()
fsi
=
IndexNew
()
var
oidb
[
8
]
byte
loop
:
...
...
@@ -326,7 +326,7 @@ out:
}
// LoadIndexFile loads index from a file @ path
func
LoadIndexFile
(
path
string
)
(
topPos
int64
,
fsi
*
fs
Index
,
err
error
)
{
func
LoadIndexFile
(
path
string
)
(
topPos
int64
,
fsi
*
Index
,
err
error
)
{
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
0
,
nil
,
&
IndexLoadError
{
path
,
-
1
,
err
}
...
...
@@ -343,3 +343,16 @@ func LoadIndexFile(path string) (topPos int64, fsi *fsIndex, err error) {
// NOTE no explicit bufferring needed - ogórek and LoadIndex use bufio.Reader internally
return
LoadIndex
(
f
)
}
// ----------------------------------------
// ComputeIndex builds new in-memory index for a file @ path
func
Reindex
(
ctx
context
.
Context
,
path
string
)
(
*
Index
,
error
)
{
fs
,
err
:=
open
(
path
)
// XXX open read-only
if
err
!=
nil
{
return
nil
,
err
}
defer
fs
.
Close
()
// XXX err?
// TODO iterate - compute
}
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