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
f2eb6a5b
Commit
f2eb6a5b
authored
Sep 12, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e6d7a736
Changes
8
Show 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
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"
panic
(
"TODO"
)
}
...
...
go/zodb/buffer.go
View file @
f2eb6a5b
...
...
@@ -40,7 +40,7 @@ type Buf struct {
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
()
{
...
...
go/zodb/buffer_test.go
View file @
f2eb6a5b
...
...
@@ -30,8 +30,7 @@ func sliceDataPtr(b []byte) unsafe.Pointer {
}
func
TestBufAllocFree
(
t
*
testing
.
T
)
{
for
i
:=
uint
(
0
);
i
<
20
;
i
++
{
//if i < 7 { continue }
for
i
:=
uint
(
0
);
i
<
25
;
i
++
{
size
:=
1
<<
i
-
1
xcap
:=
1
<<
i
buf
:=
BufAlloc
(
size
)
...
...
@@ -49,18 +48,22 @@ func TestBufAllocFree(t *testing.T) {
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
data
:=
buf
.
Data
buf
.
Free
()
buf2
:=
BufAlloc
(
size
)
// from pool -> it must be the same
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 {
// here to avoid allocations )
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
}
...
...
@@ -324,7 +324,7 @@ const (
)
// 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
{
case
zi
.
zFlags
&
zIterEOF
!=
0
:
//println("already eof")
...
...
@@ -356,14 +356,14 @@ func (zi *zIter) NextTxn() (*zodb.TxnInfo, zodb.IStorageRecordIterator, error) {
}
// 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
()
if
err
!=
nil
{
return
nil
,
err
// XXX recheck
}
zi
.
sr
i
.
Oid
=
zi
.
iter
.
Datah
.
Oid
zi
.
sr
i
.
Tid
=
zi
.
iter
.
Datah
.
Tid
zi
.
data
i
.
Oid
=
zi
.
iter
.
Datah
.
Oid
zi
.
data
i
.
Tid
=
zi
.
iter
.
Datah
.
Tid
// NOTE dh.LoadData() changes dh state while going through backpointers -
// - need to use separate dh because of this
...
...
@@ -372,20 +372,14 @@ func (zi *zIter) NextData() (*zodb.StorageRecordInformation, error) {
zi
.
dataBuf
.
Free
()
zi
.
dataBuf
=
nil
}
// zi.sri.Data = zi.dataBuf
zi
.
dataBuf
,
err
=
zi
.
dhLoading
.
LoadData
(
zi
.
iter
.
R
)
//, &zi.sri.Data)
zi
.
dataBuf
,
err
=
zi
.
dhLoading
.
LoadData
(
zi
.
iter
.
R
)
if
err
!=
nil
{
return
nil
,
err
// XXX recheck
}
// // if memory was reallocated - use it next time
// if cap(zi.sri.Data) > cap(zi.dataBuf) {
// zi.dataBuf = zi.sri.Data
// }
zi
.
sri
.
Data
=
zi
.
dataBuf
.
Data
zi
.
sri
.
DataTid
=
zi
.
dhLoading
.
Tid
return
&
zi
.
sri
,
nil
zi
.
datai
.
Data
=
zi
.
dataBuf
.
Data
zi
.
datai
.
DataTid
=
zi
.
dhLoading
.
Tid
return
&
zi
.
datai
,
nil
}
...
...
@@ -400,7 +394,7 @@ type iterStartError struct {
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
}
...
...
@@ -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
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)
// 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
// 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.
if
datai
!=
&
fsi
.
sr
i
{
if
datai
!=
&
fsi
.
data
i
{
t
.
Fatal
(
"unexpected datai pointer"
)
}
...
...
go/zodb/zodb.go
View file @
f2eb6a5b
...
...
@@ -53,8 +53,11 @@ const TidMax Tid = 1<<63 - 1 // 0x7fffffffffffffff
// See also: Xid.
type
Oid
uint64
// TxnMeta is metadata information about one transaction.
type
TxnMeta
struct
{
// TxnInfo is metadata information about one transaction.
//
// XXX naming -> TxnMeta?
// XXX +TxnInfo = TxnMeta + []DataInfo ?
type
TxnInfo
struct
{
Tid
Tid
Status
TxnStatus
User
[]
byte
...
...
@@ -62,7 +65,6 @@ type TxnMeta struct {
Extension
[]
byte
}
// XXX +TxnInfo = TxnMeta + []DataInfo ?
// DataInfo represents information about one data record.
type
DataInfo
struct
{
...
...
@@ -185,7 +187,7 @@ type ITxnIterator interface {
// 2. iterator over transaction's data records.
// transaction metadata stays valid until next call to NextTxn().
// 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.
...
...
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)
// 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
{
var
objInfo
zodb
.
StorageRecordInformation
var
objInfo
zodb
.
DataInfo
buf
,
tid
,
err
:=
stor
.
Load
(
ctx
,
xid
)
if
err
!=
nil
{
...
...
go/zodb/zodbtools/dump.go
View file @
f2eb6a5b
...
...
@@ -67,7 +67,7 @@ var _LF = []byte{'\n'}
// DumpData dumps one data record
// XXX naming -> DumpObj ?
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
StorageRecordInformation
)
error
{
func
(
d
*
dumper
)
DumpData
(
datai
*
zodb
.
DataInfo
)
error
{
buf
:=
&
d
.
buf
buf
.
Reset
()
...
...
@@ -121,8 +121,8 @@ out:
}
// DumpTxn dumps one transaction record
func
(
d
*
dumper
)
DumpTxn
(
txni
*
zodb
.
TxnInfo
,
dataIter
zodb
.
I
StorageRecord
Iterator
)
error
{
var
datai
*
zodb
.
StorageRecordInformation
func
(
d
*
dumper
)
DumpTxn
(
txni
*
zodb
.
TxnInfo
,
dataIter
zodb
.
I
Data
Iterator
)
error
{
var
datai
*
zodb
.
DataInfo
// LF in-between txn records
vskip
:=
"
\n
"
...
...
@@ -168,7 +168,7 @@ out:
// Dump dumps transaction records in between tidMin..tidMax
func
(
d
*
dumper
)
Dump
(
stor
zodb
.
IStorage
,
tidMin
,
tidMax
zodb
.
Tid
)
error
{
var
txni
*
zodb
.
TxnInfo
var
dataIter
zodb
.
I
StorageRecord
Iterator
var
dataIter
zodb
.
I
Data
Iterator
var
err
error
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