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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
245d1005
Commit
245d1005
authored
Jul 15, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d38d1525
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
19 deletions
+86
-19
wcfs/btree.go
wcfs/btree.go
+9
-2
wcfs/wcfs.go
wcfs/wcfs.go
+7
-3
wcfs/weak.go
wcfs/weak.go
+27
-6
wcfs/weak_test.go
wcfs/weak_test.go
+35
-1
wcfs/zblk.go
wcfs/zblk.go
+4
-3
wcfs/zodb.go
wcfs/zodb.go
+4
-4
No files found.
wcfs/btree.go
View file @
245d1005
...
...
@@ -157,6 +157,9 @@ func (t *ZBTree) PDeactivate() {
t
.
pyobj
.
PDeactivate
()
}
func
(
t
*
ZBTree
)
PActivate
(
ctx
context
.
Context
)
error
{
panic
(
"TODO"
)
}
// XXX ZBucket.MinKey ?
...
...
@@ -202,7 +205,9 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
// .next present
if
len
(
t
)
==
2
{
next
,
ok
:=
t
[
1
]
.
(
*
ZBucket
)
// XXX if !ok
if
!
ok
{
// XXX
}
b
.
next
=
next
}
...
...
@@ -220,7 +225,9 @@ func (b *ZBucket) PActivate(ctx context.Context) error {
v
:=
t
[
2
*
i
+
1
]
k
,
ok
:=
xk
.
(
int64
)
// XXX use KEY
// XXX if !ok
if
!
ok
{
// XXX
}
b
.
keys
=
append
(
b
.
keys
,
KEY
(
k
))
// XXX cast
b
.
values
=
append
(
b
.
values
,
v
)
...
...
wcfs/wcfs.go
View file @
245d1005
...
...
@@ -254,9 +254,9 @@ import (
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/fuse/nodefs"
"github.com/pkg/errors"
//
"github.com/pkg/errors"
pickle
"github.com/kisielk/og-rek"
// XXX should be temp here?
//
pickle "github.com/kisielk/og-rek" // XXX should be temp here?
)
// BigFileRoot represents "/bigfile"
...
...
@@ -359,7 +359,9 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
br
.
mu
.
Unlock
()
ctx
:=
context
.
Background
()
// XXX ok?
/*
_
=
ctx
return
nil
,
fuse
.
ENOSYS
// XXX temp
/* XXX kill
buf, _, err := br.zstor.Load(ctx, zodb.Xid{Oid: oid, At: zodb.TidMax}) // FIXME At, use serial
if err != nil {
switch errors.Cause(err).(type) {
...
...
@@ -380,6 +382,7 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
}
*/
/* XXX reenable (.zpy not yet here)
pybf, err := br.zpy.Load(ctx, zodb.Xid{Oid: oid, At: zodb.TidMax}) // FIXME At, use serial
if err != nil {
switch errors.Cause(err).(type) {
...
...
@@ -422,6 +425,7 @@ func (br *BigFileRoot) Mkdir(name string, mode uint32, _ *fuse.Context) (*nodefs
// XXX mkfile(bh, "invalidations", bh.inv)
return bx.Inode(), fuse.OK
*/
}
// XXX do we need to support rmdir? (probably no)
...
...
wcfs/weak.go
View file @
245d1005
// XXX copytight = ?
// Copyright (C) 2018 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// based on:
// https://groups.google.com/d/msg/golang-nuts/PYWxjT2v6ps/dL71oJk1mXEJ
// https://play.golang.org/p/f9HY6-z8Pp
//
// 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
// weak reference
...
...
@@ -20,6 +38,7 @@ type iface struct {
data
uintptr
// data
}
// weakRefState represents current state of an object WeakRef points to.
type
weakRefState
int32
const
(
...
...
@@ -32,6 +51,9 @@ const (
// WeakRef is a weak reference.
//
// Create one with NewWeakRef and retrieve referenced object with Get.
//
// There must be no more than 1 weak references to any object.
// Weak references must not be attached to an object on which runtime.SetFinalizer is also used.
type
WeakRef
struct
{
iface
...
...
@@ -40,12 +62,11 @@ type WeakRef struct {
state
weakRefState
}
//
XXX
//
NewWeakRef creates new weak reference pointing to obj.
func
NewWeakRef
(
obj
interface
{})
*
WeakRef
{
// original code uses ^ for pointers not to cause GC thinking that original
// object is still referenced from WeakRef.data. However starting with ~ Go1.4
// the GC is precise, so we don't need that trick this days.
i
:=
(
*
[
2
]
uintptr
)(
unsafe
.
Pointer
(
&
obj
))
// since starting from ~ Go1.4 the GC is precise, we can save interface
// pointers to uintptr and that won't prevent GC from garbage
// collecting the object.
w
:=
&
WeakRef
{
iface
:
*
(
*
iface
)(
unsafe
.
Pointer
(
&
obj
)),
state
:
objLive
,
...
...
wcfs/weak_test.go
View file @
245d1005
...
...
@@ -19,6 +19,40 @@
package
main
// sizeof(interface{}) == 2*sizeof(uintptr)
import
(
"testing"
"unsafe"
)
// v -> weakref -> get -> == v
// GC -> get -> alive -> GC get alive -> GC get alive -> GC GC get ø
// verify that interface <-> iface works ok.
func
TestIface
(
t
*
testing
.
T
)
{
var
i
interface
{}
var
fi
*
iface
isize
:=
unsafe
.
Sizeof
(
i
)
fsize
:=
unsafe
.
Sizeof
(
*
fi
)
if
isize
!=
fsize
{
t
.
Fatalf
(
"sizeof(interface{}) (%d) != sizeof(iface) (%d)"
,
isize
,
fsize
)
}
i
=
3
var
j
interface
{}
if
!
(
j
==
nil
&&
i
!=
j
)
{
t
.
Fatalf
(
"i == j ? (i: %#v, j: %#v}"
,
i
,
j
)
}
fi
=
(
*
iface
)(
unsafe
.
Pointer
(
&
i
))
fj
:=
(
*
iface
)(
unsafe
.
Pointer
(
&
j
))
*
fj
=
*
fi
if
i
!=
j
{
t
.
Fatalf
(
"i (%#v) != j (%#v)"
,
i
,
j
)
}
}
func
TestWeakRef
(
t
*
testing
.
T
)
{
}
wcfs/zblk.go
View file @
245d1005
...
...
@@ -22,10 +22,10 @@ package main
import
(
"context"
//
"context"
//"lab.nexedi.com/kirr/neo/go/zodb"
pickle
"github.com/kisielk/og-rek"
//
pickle "github.com/kisielk/og-rek"
)
...
...
@@ -105,6 +105,7 @@ func (bf *ZBigFile) PDeactivate() {
}
/* XXX reenable (pickletools)
func (bf *ZBigFile) PActivate(ctx context.Context) (err error) {
if bf.blktab != nil {
return nil
...
...
@@ -137,7 +138,7 @@ func (bf *ZBigFile) PActivate(ctx context.Context) (err error) {
bf.blktab = blktab
return nil
}
*/
// XXX -> newGhost
...
...
wcfs/zodb.go
View file @
245d1005
...
...
@@ -122,12 +122,12 @@ func (conn *Connection) Get(ctx context.Context, oid zodb.Oid) (*PyObject, error
func
(
conn
*
Connection
)
loadpy
(
ctx
context
.
Context
,
oid
zodb
.
Oid
)
(
pyclass
pickle
.
Class
,
pystate
interface
{},
serial
zodb
.
Tid
,
_
error
)
{
buf
,
serial
,
err
:=
conn
.
stor
.
Load
(
ctx
,
zodb
.
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
if
err
!=
nil
{
return
pickle
.
Class
{},
nil
,
zodb
.
InvalidTID
,
err
return
pickle
.
Class
{},
nil
,
0
,
err
}
pyclass
,
pystate
,
err
=
zodb
.
PyData
(
buf
.
Data
)
.
Decode
()
if
err
!=
nil
{
return
pickle
.
Class
{},
nil
,
zodb
.
InvalidTID
,
err
// XXX err ctx
return
pickle
.
Class
{},
nil
,
0
,
err
// XXX err ctx
}
buf
.
Release
()
...
...
@@ -138,7 +138,7 @@ func (conn *Connection) loadpy(ctx context.Context, oid zodb.Oid) (pyclass pickl
// newGhost creates new ghost object.
func
(
conn
*
Connection
)
newGhost
(
pyclass
pickle
.
Class
,
oid
zodb
.
Oid
)
interface
{}
{
pyobj
:=
PyObject
{
Object
:
Object
{
jar
:
conn
,
oid
:
oid
,
serial
:
zodb
.
InvalidTID
},
Object
:
Object
{
jar
:
conn
,
oid
:
oid
,
serial
:
0
},
pyclass
:
pyclass
,
pystate
:
nil
,
}
...
...
@@ -157,7 +157,7 @@ func (pyobj *PyObject) PDeactivate() {
// FIXME if state=modified PDeactivate must be noop.
pyobj
.
pystate
=
nil
pyobj
.
serial
=
zodb
.
InvalidTID
pyobj
.
serial
=
0
}
// PActivate brings object to live state.
...
...
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