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
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 (
...
@@ -41,7 +41,7 @@ import (
// organized as transactional log.
// organized as transactional log.
type
FileStorage
struct
{
type
FileStorage
struct
{
file
*
os
.
File
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
// transaction headers for min/max transactions committed
// XXX keep loaded with LoadNoStrings ?
// XXX keep loaded with LoadNoStrings ?
...
...
go/zodb/storage/fs1/index.go
View file @
07b8e592
...
@@ -43,14 +43,14 @@ import (
...
@@ -43,14 +43,14 @@ import (
"lab.nexedi.com/kirr/neo/go/xcommon/xio"
"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.
// Data record in latest transaction which changed it.
type
fs
Index
struct
{
type
Index
struct
{
*
fsb
.
Tree
*
fsb
.
Tree
}
}
func
fsIndexNew
()
*
fs
Index
{
func
IndexNew
()
*
Index
{
return
&
fs
Index
{
fsb
.
TreeNew
()}
return
&
Index
{
fsb
.
TreeNew
()}
}
}
...
@@ -86,7 +86,7 @@ func (e *IndexSaveError) Error() string {
...
@@ -86,7 +86,7 @@ func (e *IndexSaveError) Error() string {
}
}
// Save saves index to a writer
// 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
var
err
error
{
{
...
@@ -163,7 +163,7 @@ out:
...
@@ -163,7 +163,7 @@ out:
}
}
// SaveFile saves index to a file
// 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
)
f
,
err
:=
os
.
Create
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
&
IndexSaveError
{
err
}
return
&
IndexSaveError
{
err
}
...
@@ -217,7 +217,7 @@ func xint64(xv interface{}) (v int64, ok bool) {
...
@@ -217,7 +217,7 @@ func xint64(xv interface{}) (v int64, ok bool) {
}
}
// LoadIndex loads index from a reader
// 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
var
picklePos
int64
{
{
...
@@ -239,7 +239,7 @@ func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) {
...
@@ -239,7 +239,7 @@ func LoadIndex(r io.Reader) (topPos int64, fsi *fsIndex, err error) {
goto
out
goto
out
}
}
fsi
=
fs
IndexNew
()
fsi
=
IndexNew
()
var
oidb
[
8
]
byte
var
oidb
[
8
]
byte
loop
:
loop
:
...
@@ -326,7 +326,7 @@ out:
...
@@ -326,7 +326,7 @@ out:
}
}
// LoadIndexFile loads index from a file @ path
// 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
)
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
nil
,
&
IndexLoadError
{
path
,
-
1
,
err
}
return
0
,
nil
,
&
IndexLoadError
{
path
,
-
1
,
err
}
...
@@ -343,3 +343,16 @@ func LoadIndexFile(path string) (topPos int64, fsi *fsIndex, err error) {
...
@@ -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
// NOTE no explicit bufferring needed - ogórek and LoadIndex use bufio.Reader internally
return
LoadIndex
(
f
)
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