Commit f37de13c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9e0450d4
......@@ -23,6 +23,7 @@ package main
import (
//"context"
"reflect"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
......@@ -36,16 +37,18 @@ const zwendelin = "wendelin.bigfile.file_zodb"
// ZBlk0 mimics ZBlk0 from python.
type ZBlk0 struct {
*zodb.PyPersistent
zodb.Persistent
blkdata string
}
func (zb *ZBlk0) DropState() {
type zBlk0State ZBlk0 // hide state methods from public API
func (zb *zBlk0State) DropState() {
zb.blkdata = ""
}
func (zb *ZBlk0) PySetState(pystate interface{}) error {
func (zb *zBlk0State) PySetState(pystate interface{}) error {
blkdata, ok := pystate.(string)
if !ok {
// XXX
......@@ -59,16 +62,18 @@ func (zb *ZBlk0) PySetState(pystate interface{}) error {
// ZData mimics ZData from python.
type ZData struct {
*zodb.PyPersistent
zodb.Persistent
data string
}
func (zd *ZData) DropState() {
type zDataState ZData // hide state methods from public API
func (zd *zDataState) DropState() {
zd.data = ""
}
func (zd *ZData) PySetState(pystate interface{}) error {
func (zd *zDataState) PySetState(pystate interface{}) error {
data, ok := pystate.(string)
if !ok {
// XXX
......@@ -80,16 +85,18 @@ func (zd *ZData) PySetState(pystate interface{}) error {
// ZBlk1 mimics ZBlk1 from python.
type ZBlk1 struct {
*zodb.PyPersistent
zodb.Persistent
chunktab *btree.BTree // {} offset -> ZData(chunk)
}
func (zb *ZBlk1) DropState() {
type zBlk1State ZBlk1 // hide state methods from public API
func (zb *zBlk1State) DropState() {
zb.chunktab = nil
}
func (zb *ZBlk1) PySetState(pystate interface{}) error {
func (zb *zBlk1State) PySetState(pystate interface{}) error {
chunktab, ok := pystate.(*btree.BTree)
if !ok {
// XXX
......@@ -104,21 +111,23 @@ func (zb *ZBlk1) PySetState(pystate interface{}) error {
// ZBigFile mimics ZBigFile from python.
type ZBigFile struct {
*zodb.PyPersistent
zodb.Persistent
blksize int64
blktab *btree.BTree // LOBtree{} blk -> ZBlk*(blkdata)
}
type zBigFileState ZBigFile // hide state methods from public API
// DropState implements Stateful.
func (bf *ZBigFile) DropState() {
func (bf *zBigFileState) DropState() {
bf.blksize = -1
bf.blktab = nil
}
// PySetState implements PyStateful.
func (bf *ZBigFile) PySetState(pystate interface{}) (err error) {
func (bf *zBigFileState) PySetState(pystate interface{}) (err error) {
// ZBigFile
// .blksize xint
// .blktab LOBtree{} blk -> ZBlk*(blkdata)
......@@ -148,15 +157,11 @@ func (bf *ZBigFile) PySetState(pystate interface{}) (err error) {
// ----------------------------------------
func zblk0New(base *zodb.PyPersistent) zodb.IPyPersistent { return &ZBlk0{PyPersistent: base} }
func zblk1New(base *zodb.PyPersistent) zodb.IPyPersistent { return &ZBlk1{PyPersistent: base} }
func zdataNew(base *zodb.PyPersistent) zodb.IPyPersistent { return &ZData{PyPersistent: base} }
func zbigfileNew(pyobj *zodb.PyPersistent) zodb.IPyPersistent { return &ZBigFile{PyPersistent: pyobj} }
func init() {
zodb.PyRegisterClass(zwendelin + ".ZBlk", zblk0New)
zodb.PyRegisterClass(zwendelin + ".ZBlk0", zblk0New)
zodb.PyRegisterClass(zwendelin + ".ZBlk1", zblk1New)
zodb.PyRegisterClass(zwendelin + ".ZData", zdataNew)
zodb.PyRegisterClass(zwendelin + ".ZBigFile", zbigfileNew)
t := reflect.TypeOf
zodb.RegisterClass(zwendelin + ".ZBlk", t(ZBlk0{}), t(zBlk0State{}))
zodb.RegisterClass(zwendelin + ".ZBlk0", t(ZBlk0{}), t(zBlk0State{}))
zodb.RegisterClass(zwendelin + ".ZBlk1", t(ZBlk1{}), t(zBlk1State{}))
zodb.RegisterClass(zwendelin + ".ZData", t(ZData{}), t(zDataState{}))
zodb.RegisterClass(zwendelin + ".ZBigFile", t(ZBigFile{}), t(zBigFileState{}))
}
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package main
// TODO
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment