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
860c4019
Commit
860c4019
authored
Feb 15, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c9a3e4ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
28 deletions
+27
-28
go/neo/neo.go
go/neo/neo.go
+2
-4
go/neo/storage/fs1/fs1.go
go/neo/storage/fs1/fs1.go
+1
-3
go/neo/storage/sqlite/sqlite.go
go/neo/storage/sqlite/sqlite.go
+24
-21
No files found.
go/neo/neo.go
View file @
860c4019
...
...
@@ -17,11 +17,9 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package neo
and its children provide distributed object storage for ZODB
.
// Package neo
provides Go implementation of NEO database
.
//
// Package neo itself provides protocol definition and common infrastructure.
// See packages neo.client and neo.server for client and server sides respectively.
// FIXME text
// TODO text
package
neo
//go:generate gotrace gen .
...
...
go/neo/storage/fs1/fs1.go
View file @
860c4019
...
...
@@ -34,6 +34,7 @@ import (
type
Backend
struct
{
// TODO storage layout:
// meta/
// meta.fs
// data/
// 1 inbox/ (commit queues)
// 2 ? (data.fs)
...
...
@@ -43,9 +44,6 @@ type Backend struct {
// plain zodb.IStorage (e.g. loading with nextSerial) and even if
// nextSerial will be gone in the future, we will probably depend on
// particular layout more and more -> directly work with fs1 & friends.
//
// TODO -> abstract into backend interfaces so various backands are
// possible (e.g. +SQL)
zstor
*
fs1
.
FileStorage
// underlying ZODB storage
}
...
...
go/neo/storage/sqlite/sqlite.go
View file @
860c4019
...
...
@@ -25,6 +25,7 @@ import (
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/storage"
"lab.nexedi.com/kirr/neo/go/zodb"
...
...
@@ -161,8 +162,10 @@ func (b *Backend) LastOid(ctx context.Context) (zodb.Oid, error) {
panic
(
"TODO"
)
}
func
(
b
*
Backend
)
Load
(
ctx
context
.
Context
,
xid
zodb
.
Xid
)
(
*
mem
.
Buf
,
zodb
.
Tid
,
zodb
.
Tid
,
error
)
{
func
(
b
*
Backend
)
Load
(
ctx
context
.
Context
,
xid
zodb
.
Xid
)
(
*
proto
.
AnswerObject
,
error
)
{
// XXX err ctx zodb.OpError{URL: b.url, Op: "load", Err: ...}
obj
:=
&
proto
.
AnswerObject
{
Oid
:
xid
.
Oid
}
var
data
sql
.
RawBytes
// XXX pid = getReadablePartition (= oid % Np, raise if pid not readable)
err
:=
b
.
query1
(
ctx
,
...
...
@@ -170,19 +173,26 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, z
" FROM obj LEFT JOIN data ON obj.data_id = data.id"
+
" WHERE partition=? AND oid=? AND tid<=?"
+
" ORDER BY tid DESC LIMIT 1"
,
pid
,
xid
.
Oid
,
xid
.
At
)
.
Scan
(
&
serial
,
&
compression
,
&
hash
,
&
data
,
&
data_tid
)
pid
,
xid
.
Oid
,
xid
.
At
)
.
Scan
(
&
obj
.
Serial
,
&
obj
.
Compression
,
&
obj
.
Checksum
,
&
data
,
&
obj
.
DataSerial
)
if
err
!=
nil
{
if
err
==
sql
.
ErrNoRows
{
// XXX see if object exists at all
err
=
zodb
.
ErrNoData
|
zodb
.
ErrNoObject
err
=
&
zodb
.
NoDataError
{
Oid
:
xid
.
Oid
,
DeletedAt
:
0
,
// XXX hardcoded
}
return
err
err
=
&
zodb
.
NoObjectError
{
Oid
:
xid
.
Oid
}
}
buf
=
return
nil
,
err
}
// data -> obj.Data
obj
.
Data
=
mem
.
BufAlloc
(
len
(
data
))
copy
(
obj
.
Data
.
Data
,
data
)
// find out nextSerial
// XXX kill nextSerial support after neo/py cache does not need it
...
...
@@ -190,30 +200,22 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, z
"SELECT tid from obj"
+
" WHERE partition=? AND oid=? AND tid>?"
+
" ORDER BY tid LIMIT 1"
,
pid
,
xid
.
Oid
,
xid
.
At
)
.
Scan
(
&
n
extSerial
)
pid
,
xid
.
Oid
,
xid
.
At
)
.
Scan
(
&
obj
.
N
extSerial
)
if
err
!=
nil
{
if
err
==
sql
.
ErrNo
Object
{
n
extSerial
=
proto
.
INVALID_TID
if
err
==
sql
.
ErrNo
Rows
{
obj
.
N
extSerial
=
proto
.
INVALID_TID
}
else
{
return
err
return
nil
,
err
}
}
return
&
proto
.
AnswerObject
{
Oid
:
xid
.
Oid
,
Serial
:
serial
,
NextSerial
:
nextSerial
,
Compression
:
compression
,
Checksum
:
hash
,
Data
:
buf
,
DataSerial
:
data_tid
,
}
return
obj
,
nil
}
/*
func (b *Backend) config(key string) (..., error) {
// XXX cache
var value string
...
...
@@ -229,6 +231,7 @@ func (b *Backend) config(key string) (..., error) {
return value, nil
}
*/
// ---- open by URL ----
...
...
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