Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
f37de13c
Commit
f37de13c
authored
Aug 03, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9e0450d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
22 deletions
+49
-22
wcfs/zblk.go
wcfs/zblk.go
+27
-22
wcfs/zblk_test.go
wcfs/zblk_test.go
+22
-0
No files found.
wcfs/zblk.go
View file @
f37de13c
...
...
@@ -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
.
Py
Persistent
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
.
Py
Persistent
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
.
Py
Persistent
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
.
Py
Persistent
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
*
ZBigFil
e
)
DropState
()
{
func
(
bf
*
zBigFileStat
e
)
DropState
()
{
bf
.
blksize
=
-
1
bf
.
blktab
=
nil
}
// PySetState implements PyStateful.
func
(
bf
*
ZBigFil
e
)
PySetState
(
pystate
interface
{})
(
err
error
)
{
func
(
bf
*
zBigFileStat
e
)
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
{}))
}
wcfs/zblk_test.go
0 → 100644
View file @
f37de13c
// 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
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