Commit cf2f3cef authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7f63e821
...@@ -157,6 +157,7 @@ const ( ...@@ -157,6 +157,7 @@ const (
// //
// Object state is used once and then won't be used for a long time. // Object state is used once and then won't be used for a long time.
// There is no reason to preserve object state in cache. // There is no reason to preserve object state in cache.
// XXX Don't pollute ...
PCacheNonTemporal // XXX PCachePolicy ? PCacheNonTemporal // XXX PCachePolicy ?
) )
......
...@@ -217,13 +217,7 @@ type tPersistentDB struct { ...@@ -217,13 +217,7 @@ type tPersistentDB struct {
db *DB db *DB
head Tid // last committed transaction head Tid // last committed transaction
commitq []toCommit // queue to be committed commitq []IPersistent // queue to be committed
}
// XXX place? name?
type toCommit struct {
oid Oid
value string
} }
// tPersistentConn represents testing Connection. XXX -> tConn ? // tPersistentConn represents testing Connection. XXX -> tConn ?
...@@ -283,22 +277,17 @@ func (t *tPersistentDB) Close() { ...@@ -283,22 +277,17 @@ func (t *tPersistentDB) Close() {
// //
// The commit is performed by Commit. // The commit is performed by Commit.
func (t *tPersistentDB) Add(oid Oid, value string) { func (t *tPersistentDB) Add(oid Oid, value string) {
t.commitq = append(t.commitq, toCommit{oid, value}) obj := NewMyObject(nil) // XXX hack - goes without jar
obj.oid = oid
obj.value = value
t.commitq = append(t.commitq, obj)
} }
// Commit commits objects queued by Add. // Commit commits objects queued by Add.
func (t *tPersistentDB) Commit() { func (t *tPersistentDB) Commit() {
t.Helper() t.Helper()
var objv []IPersistent head, err := ZPyCommit(t.zurl, t.head, t.commitq...)
for _, tc := range t.commitq {
obj := NewMyObject(nil) // XXX hack - goes without jar
obj.oid = tc.oid
obj.value = tc.value
objv = append(objv, obj)
}
head, err := ZPyCommit(t.zurl, t.head, objv...)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -455,47 +444,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) { ...@@ -455,47 +444,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
tdb.Commit() tdb.Commit()
at1 := tdb.head at1 := tdb.head
/*
// create test db via py with 2 objects
// XXX hack as _objX go without jar.
_obj1 := NewMyObject(nil); _obj1.oid = 101; _obj1.value = "init"
_obj2 := NewMyObject(nil); _obj2.oid = 102; _obj2.value = "db"
at0, err := ZPyCommit(zurl, 0, _obj1, _obj2); X(err)
_obj1.value = "hello"
_obj2.value = "world"
at1, err := ZPyCommit(zurl, at0, _obj1, _obj2); X(err)
// open connection to it via zodb/go
ctx := context.Background()
stor, err := Open(ctx, zurl, &OpenOptions{ReadOnly: true, NoCache: !rawcache}); X(err)
db := NewDB(stor)
defer func() {
err := db.Close(); X(err)
}()
// testopen opens new db transaction/connection and wraps it with tPersistentDB.
testopen := func(opt *ConnOptions) *tPersistentDB {
t0.Helper()
txn, ctx := transaction.New(context.Background())
conn, err := db.Open(ctx, opt); X(err)
assert.Same(conn.db, db)
assert.Same(conn.txn, txn)
return &tPersistentDB{
T: t0,
txn: txn,
ctx: ctx,
conn: conn,
}
}
*/
db := tdb.db db := tdb.db
t1 := tdb.Open(&ConnOptions{}) t1 := tdb.Open(&ConnOptions{})
t := t1 t := t1
assert.Equal(t.conn.At(), at1) assert.Equal(t.conn.At(), at1)
......
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