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 @@
...
@@ -17,11 +17,9 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// 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.
// TODO text
// See packages neo.client and neo.server for client and server sides respectively.
// FIXME text
package
neo
package
neo
//go:generate gotrace gen .
//go:generate gotrace gen .
...
...
go/neo/storage/fs1/fs1.go
View file @
860c4019
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
type
Backend
struct
{
type
Backend
struct
{
// TODO storage layout:
// TODO storage layout:
// meta/
// meta/
// meta.fs
// data/
// data/
// 1 inbox/ (commit queues)
// 1 inbox/ (commit queues)
// 2 ? (data.fs)
// 2 ? (data.fs)
...
@@ -43,9 +44,6 @@ type Backend struct {
...
@@ -43,9 +44,6 @@ type Backend struct {
// plain zodb.IStorage (e.g. loading with nextSerial) and even if
// plain zodb.IStorage (e.g. loading with nextSerial) and even if
// nextSerial will be gone in the future, we will probably depend on
// nextSerial will be gone in the future, we will probably depend on
// particular layout more and more -> directly work with fs1 & friends.
// 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
zstor
*
fs1
.
FileStorage
// underlying ZODB storage
}
}
...
...
go/neo/storage/sqlite/sqlite.go
View file @
860c4019
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"lab.nexedi.com/kirr/go123/mem"
"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/neo/storage"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
...
@@ -161,8 +162,10 @@ func (b *Backend) LastOid(ctx context.Context) (zodb.Oid, error) {
...
@@ -161,8 +162,10 @@ func (b *Backend) LastOid(ctx context.Context) (zodb.Oid, error) {
panic
(
"TODO"
)
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: ...}
// 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)
// XXX pid = getReadablePartition (= oid % Np, raise if pid not readable)
err
:=
b
.
query1
(
ctx
,
err
:=
b
.
query1
(
ctx
,
...
@@ -170,19 +173,26 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, z
...
@@ -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"
+
" FROM obj LEFT JOIN data ON obj.data_id = data.id"
+
" WHERE partition=? AND oid=? AND tid<=?"
+
" WHERE partition=? AND oid=? AND tid<=?"
+
" ORDER BY tid DESC LIMIT 1"
,
" ORDER BY tid DESC LIMIT 1"
,
pid
,
xid
.
Oid
,
xid
.
At
)
pid
,
xid
.
Oid
,
xid
.
At
)
.
.
Scan
(
&
serial
,
&
compression
,
&
hash
,
&
data
,
&
data_tid
)
Scan
(
&
obj
.
Serial
,
&
obj
.
Compression
,
&
obj
.
Checksum
,
&
data
,
&
obj
.
DataSerial
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
sql
.
ErrNoRows
{
if
err
==
sql
.
ErrNoRows
{
// XXX see if object exists at all
// 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
// find out nextSerial
// XXX kill nextSerial support after neo/py cache does not need it
// 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
...
@@ -190,30 +200,22 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, z
"SELECT tid from obj"
+
"SELECT tid from obj"
+
" WHERE partition=? AND oid=? AND tid>?"
+
" WHERE partition=? AND oid=? AND tid>?"
+
" ORDER BY tid LIMIT 1"
,
" ORDER BY tid LIMIT 1"
,
pid
,
xid
.
Oid
,
xid
.
At
)
pid
,
xid
.
Oid
,
xid
.
At
)
.
.
Scan
(
&
n
extSerial
)
Scan
(
&
obj
.
N
extSerial
)
if
err
!=
nil
{
if
err
!=
nil
{
if
err
==
sql
.
ErrNo
Object
{
if
err
==
sql
.
ErrNo
Rows
{
n
extSerial
=
proto
.
INVALID_TID
obj
.
N
extSerial
=
proto
.
INVALID_TID
}
else
{
}
else
{
return
err
return
nil
,
err
}
}
}
}
return
&
proto
.
AnswerObject
{
return
obj
,
nil
Oid
:
xid
.
Oid
,
Serial
:
serial
,
NextSerial
:
nextSerial
,
Compression
:
compression
,
Checksum
:
hash
,
Data
:
buf
,
DataSerial
:
data_tid
,
}
}
}
/*
func (b *Backend) config(key string) (..., error) {
func (b *Backend) config(key string) (..., error) {
// XXX cache
// XXX cache
var value string
var value string
...
@@ -229,6 +231,7 @@ func (b *Backend) config(key string) (..., error) {
...
@@ -229,6 +231,7 @@ func (b *Backend) config(key string) (..., error) {
return value, nil
return value, nil
}
}
*/
// ---- open by URL ----
// ---- 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