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
f2eb6a5b
Commit
f2eb6a5b
authored
Sep 12, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e6d7a736
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
38 deletions
+37
-38
go/neo/client/client.go
go/neo/client/client.go
+1
-1
go/zodb/buffer.go
go/zodb/buffer.go
+1
-1
go/zodb/buffer_test.go
go/zodb/buffer_test.go
+12
-9
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+11
-17
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+1
-1
go/zodb/zodb.go
go/zodb/zodb.go
+6
-4
go/zodb/zodbtools/catobj.go
go/zodb/zodbtools/catobj.go
+1
-1
go/zodb/zodbtools/dump.go
go/zodb/zodbtools/dump.go
+4
-4
No files found.
go/neo/client/client.go
View file @
f2eb6a5b
...
@@ -472,7 +472,7 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data *zodb.Buf, serial
...
@@ -472,7 +472,7 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data *zodb.Buf, serial
return
data
,
resp
.
Serial
,
nil
return
data
,
resp
.
Serial
,
nil
}
}
func
(
c
*
Client
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
I
Storage
Iterator
{
func
(
c
*
Client
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
I
Txn
Iterator
{
// see notes in ../NOTES:"On iteration"
// see notes in ../NOTES:"On iteration"
panic
(
"TODO"
)
panic
(
"TODO"
)
}
}
...
...
go/zodb/buffer.go
View file @
f2eb6a5b
...
@@ -40,7 +40,7 @@ type Buf struct {
...
@@ -40,7 +40,7 @@ type Buf struct {
const
order0
=
4
// buf sizes start from 2^4 (=16)
const
order0
=
4
// buf sizes start from 2^4 (=16)
var
bufPoolv
=
[
1
4
]
sync
.
Pool
{}
// buf size stop at 2^(4+14-1) (=128K
)
var
bufPoolv
=
[
1
9
]
sync
.
Pool
{}
// buf size stop at 2^(4+19-1) (=4M
)
func
init
()
{
func
init
()
{
...
...
go/zodb/buffer_test.go
View file @
f2eb6a5b
...
@@ -30,8 +30,7 @@ func sliceDataPtr(b []byte) unsafe.Pointer {
...
@@ -30,8 +30,7 @@ func sliceDataPtr(b []byte) unsafe.Pointer {
}
}
func
TestBufAllocFree
(
t
*
testing
.
T
)
{
func
TestBufAllocFree
(
t
*
testing
.
T
)
{
for
i
:=
uint
(
0
);
i
<
20
;
i
++
{
for
i
:=
uint
(
0
);
i
<
25
;
i
++
{
//if i < 7 { continue }
size
:=
1
<<
i
-
1
size
:=
1
<<
i
-
1
xcap
:=
1
<<
i
xcap
:=
1
<<
i
buf
:=
BufAlloc
(
size
)
buf
:=
BufAlloc
(
size
)
...
@@ -49,18 +48,22 @@ func TestBufAllocFree(t *testing.T) {
...
@@ -49,18 +48,22 @@ func TestBufAllocFree(t *testing.T) {
t
.
Errorf
(
"%v: cap=%v ; want %v"
,
i
,
cap
(
buf
.
Data
),
xcap
)
t
.
Errorf
(
"%v: cap=%v ; want %v"
,
i
,
cap
(
buf
.
Data
),
xcap
)
}
}
// this allocations are not from pool - memory won't be reused
if
int
(
i
)
>=
order0
+
len
(
bufPoolv
)
{
continue
}
// free and allocate another buf -> it must be it
// free and allocate another buf -> it must be it
data
:=
buf
.
Data
data
:=
buf
.
Data
buf
.
Free
()
buf
.
Free
()
buf2
:=
BufAlloc
(
size
)
buf2
:=
BufAlloc
(
size
)
if
!
(
buf2
==
buf
&&
sliceDataPtr
(
buf2
.
Data
)
==
sliceDataPtr
(
data
))
{
// from pool -> it must be the same
t
.
Errorf
(
"%v: buffer not reused on free/realloc"
,
i
)
if
int
(
i
)
<
order0
+
len
(
bufPoolv
)
{
if
!
(
buf2
==
buf
&&
sliceDataPtr
(
buf2
.
Data
)
==
sliceDataPtr
(
data
))
{
t
.
Errorf
(
"%v: buffer not reused on free/realloc"
,
i
)
}
// not from pool - memory won't be reused
}
else
{
if
buf2
==
buf
||
sliceDataPtr
(
buf2
.
Data
)
==
sliceDataPtr
(
data
)
{
t
.
Errorf
(
"%v: buffer reused but should not"
,
i
)
}
}
}
}
}
}
}
go/zodb/storage/fs1/filestorage.go
View file @
f2eb6a5b
...
@@ -313,7 +313,7 @@ type zIter struct {
...
@@ -313,7 +313,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
datai
zodb
.
DataInfo
// ptr to this will be returned by .NextData
dataBuf
*
zodb
.
Buf
dataBuf
*
zodb
.
Buf
}
}
...
@@ -324,7 +324,7 @@ const (
...
@@ -324,7 +324,7 @@ const (
)
)
// NextTxn iterates to next/previous transaction record according to iteration direction
// NextTxn iterates to next/previous transaction record according to iteration direction
func
(
zi
*
zIter
)
NextTxn
()
(
*
zodb
.
TxnInfo
,
zodb
.
I
StorageRecord
Iterator
,
error
)
{
func
(
zi
*
zIter
)
NextTxn
()
(
*
zodb
.
TxnInfo
,
zodb
.
I
Data
Iterator
,
error
)
{
switch
{
switch
{
case
zi
.
zFlags
&
zIterEOF
!=
0
:
case
zi
.
zFlags
&
zIterEOF
!=
0
:
//println("already eof")
//println("already eof")
...
@@ -356,14 +356,14 @@ func (zi *zIter) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator, error) {
...
@@ -356,14 +356,14 @@ func (zi *zIter) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator, error) {
}
}
// NextData iterates to next data record and loads data content
// NextData iterates to next data record and loads data content
func
(
zi
*
zIter
)
NextData
()
(
*
zodb
.
StorageRecordInformation
,
error
)
{
func
(
zi
*
zIter
)
NextData
()
(
*
zodb
.
DataInfo
,
error
)
{
err
:=
zi
.
iter
.
NextData
()
err
:=
zi
.
iter
.
NextData
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX recheck
return
nil
,
err
// XXX recheck
}
}
zi
.
sr
i
.
Oid
=
zi
.
iter
.
Datah
.
Oid
zi
.
data
i
.
Oid
=
zi
.
iter
.
Datah
.
Oid
zi
.
sr
i
.
Tid
=
zi
.
iter
.
Datah
.
Tid
zi
.
data
i
.
Tid
=
zi
.
iter
.
Datah
.
Tid
// NOTE dh.LoadData() changes dh state while going through backpointers -
// NOTE dh.LoadData() changes dh state while going through backpointers -
// - need to use separate dh because of this
// - need to use separate dh because of this
...
@@ -372,20 +372,14 @@ func (zi *zIter) NextData() (*zodb.StorageRecordInformation, error) {
...
@@ -372,20 +372,14 @@ func (zi *zIter) NextData() (*zodb.StorageRecordInformation, error) {
zi
.
dataBuf
.
Free
()
zi
.
dataBuf
.
Free
()
zi
.
dataBuf
=
nil
zi
.
dataBuf
=
nil
}
}
// zi.sri.Data = zi.dataBuf
zi
.
dataBuf
,
err
=
zi
.
dhLoading
.
LoadData
(
zi
.
iter
.
R
)
zi
.
dataBuf
,
err
=
zi
.
dhLoading
.
LoadData
(
zi
.
iter
.
R
)
//, &zi.sri.Data)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX recheck
return
nil
,
err
// XXX recheck
}
}
// // if memory was reallocated - use it next time
zi
.
datai
.
Data
=
zi
.
dataBuf
.
Data
// if cap(zi.sri.Data) > cap(zi.dataBuf) {
zi
.
datai
.
DataTid
=
zi
.
dhLoading
.
Tid
// zi.dataBuf = zi.sri.Data
return
&
zi
.
datai
,
nil
// }
zi
.
sri
.
Data
=
zi
.
dataBuf
.
Data
zi
.
sri
.
DataTid
=
zi
.
dhLoading
.
Tid
return
&
zi
.
sri
,
nil
}
}
...
@@ -400,7 +394,7 @@ type iterStartError struct {
...
@@ -400,7 +394,7 @@ type iterStartError struct {
err
error
err
error
}
}
func
(
e
*
iterStartError
)
NextTxn
()
(
*
zodb
.
TxnInfo
,
zodb
.
I
StorageRecord
Iterator
,
error
)
{
func
(
e
*
iterStartError
)
NextTxn
()
(
*
zodb
.
TxnInfo
,
zodb
.
I
Data
Iterator
,
error
)
{
return
nil
,
nil
,
e
.
err
return
nil
,
nil
,
e
.
err
}
}
...
@@ -483,7 +477,7 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er
...
@@ -483,7 +477,7 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er
}
}
// 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
.
I
Storage
Iterator
{
func
(
fs
*
FileStorage
)
Iterate
(
tidMin
,
tidMax
zodb
.
Tid
)
zodb
.
I
Txn
Iterator
{
//fmt.Printf("iterate %v..%v\n", tidMin, tidMax)
//fmt.Printf("iterate %v..%v\n", tidMin, tidMax)
// when iterating use IO optimized for sequential access
// when iterating use IO optimized for sequential access
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
f2eb6a5b
...
@@ -218,7 +218,7 @@ func testIterate(t *testing.T, fs *FileStorage, tidMin, tidMax zodb.Tid, expectv
...
@@ -218,7 +218,7 @@ func testIterate(t *testing.T, fs *FileStorage, tidMin, tidMax zodb.Tid, expectv
// assert datai pointes to where we expect - this will allow us
// assert datai pointes to where we expect - this will allow us
// not only to check oid/tid/data but also to check whole data header.
// not only to check oid/tid/data but also to check whole data header.
if
datai
!=
&
fsi
.
sr
i
{
if
datai
!=
&
fsi
.
data
i
{
t
.
Fatal
(
"unexpected datai pointer"
)
t
.
Fatal
(
"unexpected datai pointer"
)
}
}
...
...
go/zodb/zodb.go
View file @
f2eb6a5b
...
@@ -53,8 +53,11 @@ const TidMax Tid = 1<<63 - 1 // 0x7fffffffffffffff
...
@@ -53,8 +53,11 @@ const TidMax Tid = 1<<63 - 1 // 0x7fffffffffffffff
// See also: Xid.
// See also: Xid.
type
Oid
uint64
type
Oid
uint64
// TxnMeta is metadata information about one transaction.
// TxnInfo is metadata information about one transaction.
type
TxnMeta
struct
{
//
// XXX naming -> TxnMeta?
// XXX +TxnInfo = TxnMeta + []DataInfo ?
type
TxnInfo
struct
{
Tid
Tid
Tid
Tid
Status
TxnStatus
Status
TxnStatus
User
[]
byte
User
[]
byte
...
@@ -62,7 +65,6 @@ type TxnMeta struct {
...
@@ -62,7 +65,6 @@ type TxnMeta struct {
Extension
[]
byte
Extension
[]
byte
}
}
// XXX +TxnInfo = TxnMeta + []DataInfo ?
// DataInfo represents information about one data record.
// DataInfo represents information about one data record.
type
DataInfo
struct
{
type
DataInfo
struct
{
...
@@ -185,7 +187,7 @@ type ITxnIterator interface {
...
@@ -185,7 +187,7 @@ type ITxnIterator interface {
// 2. iterator over transaction's data records.
// 2. iterator over transaction's data records.
// transaction metadata stays valid until next call to NextTxn().
// transaction metadata stays valid until next call to NextTxn().
// end of iteration is indicated with io.EOF
// end of iteration is indicated with io.EOF
NextTxn
()
(
*
Txn
Meta
,
IDataIterator
,
error
)
// XXX ctx
NextTxn
()
(
*
Txn
Info
,
IDataIterator
,
error
)
// XXX ctx
}
}
// IDataIterator is the interface to iterate data records.
// IDataIterator is the interface to iterate data records.
...
...
go/zodb/zodbtools/catobj.go
View file @
f2eb6a5b
...
@@ -46,7 +46,7 @@ func Catobj(ctx context.Context, w io.Writer, stor zodb.IStorage, xid zodb.Xid)
...
@@ -46,7 +46,7 @@ func Catobj(ctx context.Context, w io.Writer, stor zodb.IStorage, xid zodb.Xid)
// Dumpobj dumps content of one ZODB object with zodbdump-like header
// Dumpobj dumps content of one ZODB object with zodbdump-like header
func
Dumpobj
(
ctx
context
.
Context
,
w
io
.
Writer
,
stor
zodb
.
IStorage
,
xid
zodb
.
Xid
,
hashOnly
bool
)
error
{
func
Dumpobj
(
ctx
context
.
Context
,
w
io
.
Writer
,
stor
zodb
.
IStorage
,
xid
zodb
.
Xid
,
hashOnly
bool
)
error
{
var
objInfo
zodb
.
StorageRecordInformation
var
objInfo
zodb
.
DataInfo
buf
,
tid
,
err
:=
stor
.
Load
(
ctx
,
xid
)
buf
,
tid
,
err
:=
stor
.
Load
(
ctx
,
xid
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
go/zodb/zodbtools/dump.go
View file @
f2eb6a5b
...
@@ -67,7 +67,7 @@ var _LF = []byte{'\n'}
...
@@ -67,7 +67,7 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record
// DumpData dumps one data record
// XXX naming -> DumpObj ?
// XXX naming -> DumpObj ?
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
StorageRecordInformation
)
error
{
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
DataInfo
)
error
{
buf
:=
&
d
.
buf
buf
:=
&
d
.
buf
buf
.
Reset
()
buf
.
Reset
()
...
@@ -121,8 +121,8 @@ out:
...
@@ -121,8 +121,8 @@ out:
}
}
// DumpTxn dumps one transaction record
// DumpTxn dumps one transaction record
func
(
d
*
dumper
)
DumpTxn
(
txni
*
zodb
.
TxnInfo
,
dataIter
zodb
.
I
StorageRecord
Iterator
)
error
{
func
(
d
*
dumper
)
DumpTxn
(
txni
*
zodb
.
TxnInfo
,
dataIter
zodb
.
I
Data
Iterator
)
error
{
var
datai
*
zodb
.
StorageRecordInformation
var
datai
*
zodb
.
DataInfo
// LF in-between txn records
// LF in-between txn records
vskip
:=
"
\n
"
vskip
:=
"
\n
"
...
@@ -168,7 +168,7 @@ out:
...
@@ -168,7 +168,7 @@ out:
// Dump dumps transaction records in between tidMin..tidMax
// Dump dumps transaction records in between tidMin..tidMax
func
(
d
*
dumper
)
Dump
(
stor
zodb
.
IStorage
,
tidMin
,
tidMax
zodb
.
Tid
)
error
{
func
(
d
*
dumper
)
Dump
(
stor
zodb
.
IStorage
,
tidMin
,
tidMax
zodb
.
Tid
)
error
{
var
txni
*
zodb
.
TxnInfo
var
txni
*
zodb
.
TxnInfo
var
dataIter
zodb
.
I
StorageRecord
Iterator
var
dataIter
zodb
.
I
Data
Iterator
var
err
error
var
err
error
iter
:=
stor
.
Iterate
(
tidMin
,
tidMax
)
iter
:=
stor
.
Iterate
(
tidMin
,
tidMax
)
...
...
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