Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 7 files changed
  • 0 comments
  • 1 contributor
25  src/loge/database.go
@@ -129,6 +129,27 @@ func (db *LogeDB) FlushCache() int {
129 129
 	return count
130 130
 }
131 131
 
  132
+// -----------------------------------------------
  133
+// Dirty Operations
  134
+// -----------------------------------------------
  135
+
  136
+func (db *LogeDB) DirtyExists(typeName string, key LogeKey) bool {
  137
+	var obj = db.store.get(db.types[typeName], key)
  138
+	return obj != nil
  139
+}
  140
+
  141
+func (db *LogeDB) DirtyRead(typeName string, key LogeKey) interface{} {
  142
+	var typ = db.types[typeName]
  143
+	var obj = db.store.get(typ, key)
  144
+	if obj == nil {
  145
+		return typ.NilValue()
  146
+	}
  147
+	return obj
  148
+}
  149
+
  150
+func (db *LogeDB) DirtyReadLinks(typeName string, linkName string, key LogeKey) []string {
  151
+	return db.store.getLinks(db.types[typeName], linkName, key)
  152
+}
132 153
 
133 154
 // -----------------------------------------------
134 155
 // Internals
@@ -202,7 +223,3 @@ func (db *LogeDB) ensureObj(ref objRef, load bool) *logeObject {
202 223
 }
203 224
 
204 225
 
205  
-func (db *LogeDB) newWriteBatch() writeBatch {
206  
-	return db.store.newWriteBatch()
207  
-}
208  
-
59  src/loge/dirty_test.go
... ...
@@ -0,0 +1,59 @@
  1
+package loge
  2
+
  3
+import (
  4
+	"testing"
  5
+	"reflect"
  6
+)
  7
+
  8
+func TestDirtyOps(test *testing.T) {
  9
+	var db = NewLogeDB(NewMemStore())
  10
+	db.CreateType("test", 1, &TestObj{}, LinkSpec{ "other": "test" })
  11
+
  12
+	db.Transact(func (t *Transaction) {
  13
+		t.Set("test", "foo", &TestObj{ "foo" })
  14
+		t.Set("test", "bar", &TestObj{ "bar" })
  15
+		
  16
+		t.AddLink("test", "other", "foo", "bar")
  17
+		t.AddLink("test", "other", "bar", "foo")
  18
+	}, 0)
  19
+
  20
+	if !db.DirtyExists("test", "foo") {
  21
+		test.Error("Dirty foo doesn't exist")
  22
+	}
  23
+
  24
+	if !db.DirtyExists("test", "bar") {
  25
+		test.Error("Dirty bar doesn't exist")
  26
+	}
  27
+
  28
+	if db.DirtyExists("test", "wib") {
  29
+		test.Error("Dirty wib exists")
  30
+	}
  31
+
  32
+	if db.DirtyRead("test", "foo").(*TestObj).Name != "foo" {
  33
+		test.Error("Dirty read has wrong name")
  34
+	}
  35
+
  36
+	if db.DirtyRead("test", "bar").(*TestObj).Name != "bar" {
  37
+		test.Error("Dirty read has wrong name")
  38
+	}
  39
+
  40
+	var wib = db.DirtyRead("test", "wib").(*TestObj)
  41
+	if wib != nil {
  42
+		test.Errorf("Missing obj is not nil (%v)", wib)
  43
+	}
  44
+
  45
+	var fooLinks = db.DirtyReadLinks("test", "other", "foo")
  46
+	if !reflect.DeepEqual(fooLinks, []string{ "bar" }) {
  47
+		test.Errorf("Wrong dirty links: %v", fooLinks)
  48
+	}
  49
+
  50
+	var barLinks = db.DirtyReadLinks("test", "other", "bar")
  51
+	if !reflect.DeepEqual(barLinks, []string{ "foo" }) {
  52
+		test.Errorf("Wrong dirty links: %v", barLinks)
  53
+	}
  54
+
  55
+	var wibLinks = db.DirtyReadLinks("test", "other", "wib")
  56
+	if !reflect.DeepEqual(wibLinks, []string{}) {
  57
+		test.Errorf("Wrong dirty links: %v", wibLinks)
  58
+	}
  59
+}
207  src/loge/leveldb.go
@@ -16,16 +16,23 @@ const ldb_LINK_INFO_TAG uint16 = 3
16 16
 const ldb_INDEX_TAG uint16 = 4
17 17
 const ldb_START_TAG uint16 = 8
18 18
 
  19
+var linkSpec *spack.TypeSpec = spack.MakeTypeSpec([]string{})
  20
+var linkInfoSpec *spack.TypeSpec = spack.MakeTypeSpec(linkInfo{})
  21
+
  22
+type levelDBWriter interface {
  23
+	GetType(string) *spack.VersionedType
  24
+	Put([]byte, []byte) error
  25
+	Delete([]byte) error
  26
+}
  27
+
19 28
 type levelDBStore struct {
20 29
 	basePath string
21 30
 	db *levigo.DB
22 31
 	types *spack.TypeSet
23 32
 
24  
-	writeQueue chan *levelDBWriteBatch
  33
+	writeQueue chan *levelDBContext
25 34
 	flushed bool
26 35
 
27  
-	linkSpec *spack.TypeSpec
28  
-	linkInfoSpec *spack.TypeSpec
29 36
 }
30 37
 
31 38
 type levelDBResultSet struct {
@@ -35,8 +42,8 @@ type levelDBResultSet struct {
35 42
 	closed bool
36 43
 }
37 44
 
38  
-type levelDBWriteBatch struct {
39  
-	store *levelDBStore
  45
+type levelDBContext struct {
  46
+	ldbStore *levelDBStore
40 47
 	batch []levelDBWriteEntry
41 48
 	result chan error
42 49
 }
@@ -65,11 +72,8 @@ func NewLevelDBStore(basePath string) LogeStore {
65 72
 		db: db,
66 73
 		types: spack.NewTypeSet(),
67 74
 		
68  
-		writeQueue: make(chan *levelDBWriteBatch),
  75
+		writeQueue: make(chan *levelDBContext),
69 76
 		flushed: false,
70  
-
71  
-		linkSpec: spack.MakeTypeSpec([]string{}),
72  
-		linkInfoSpec: spack.MakeTypeSpec(linkInfo{}),
73 77
 	}
74 78
 
75 79
 	store.types.LastTag = ldb_START_TAG
@@ -116,9 +120,20 @@ func (store *levelDBStore) registerType(typ *logeType) {
116 120
 	vt.Dirty = false
117 121
 }
118 122
 
  123
+func (store *levelDBStore) GetType(typeName string) *spack.VersionedType {
  124
+	return store.types.Type(typeName)
  125
+}
119 126
 
120  
-func (store *levelDBStore) get(typ *logeType, key LogeKey) interface{} {
  127
+func (store *levelDBStore) Put(key []byte, val []byte) error {
  128
+	return store.db.Put(writeOptions, key, val)
  129
+}
121 130
 
  131
+func (store *levelDBStore) Delete(key []byte) error {
  132
+	return store.db.Delete(writeOptions, key)
  133
+}
  134
+
  135
+
  136
+func (store *levelDBStore) get(typ *logeType, key LogeKey) interface{} {
122 137
 	var vt = store.types.Type(typ.Name)
123 138
 	var encKey = vt.EncodeKey(string(key))
124 139
 
@@ -162,11 +177,18 @@ func (store *levelDBStore) getLinks(typ *logeType, linkName string, objKey LogeK
162 177
 	}
163 178
 
164 179
 	var links linkList
165  
-	spack.DecodeFromBytes(&links, store.linkSpec, val)
  180
+	spack.DecodeFromBytes(&links, linkSpec, val)
166 181
 
167 182
 	return links
168 183
 }
169 184
 
  185
+func (store *levelDBStore) store(obj *logeObject) error {
  186
+	return ldb_store(store, obj)
  187
+}
  188
+
  189
+func (store *levelDBStore) storeLinks(obj *logeObject) error {
  190
+	return ldb_storeLinks(store, obj)
  191
+}
170 192
 
171 193
 // -----------------------------------------------
172 194
 // Search
@@ -228,9 +250,9 @@ func (rs *levelDBResultSet) Close() {
228 250
 // Write Batches
229 251
 // -----------------------------------------------
230 252
 
231  
-func (store *levelDBStore) newWriteBatch() writeBatch {
232  
-	return &levelDBWriteBatch{
233  
-		store: store,
  253
+func (store *levelDBStore) newContext() transactionContext {
  254
+	return &levelDBContext{
  255
+		ldbStore: store,
234 256
 		batch: make([]levelDBWriteEntry, 0),
235 257
 		result: make(chan error),
236 258
 	}
@@ -239,84 +261,39 @@ func (store *levelDBStore) newWriteBatch() writeBatch {
239 261
 func (store *levelDBStore) writer() {
240 262
 	runtime.LockOSThread()
241 263
 	defer runtime.UnlockOSThread()
242  
-	for batch := range store.writeQueue {
243  
-		if batch == nil {
  264
+	for context := range store.writeQueue {
  265
+		if context == nil {
244 266
 			break
245 267
 		}
246  
-		batch.result<- batch.Write()
  268
+		context.result<- context.Write()
247 269
 	}
248 270
 	store.flushed = true
249 271
 }
250 272
 
251  
-func (batch *levelDBWriteBatch) Store(obj *logeObject) error {
252  
-	var vt = batch.store.types.Type(obj.Type.Name)
253  
-	var key = vt.EncodeKey(string(obj.Key))
254  
-
255  
-	if !obj.Current.hasValue() {
256  
-		batch.Delete(key)
257  
-		return nil
258  
-	}
259  
-
260  
-	var val, err = vt.EncodeObj(obj.Current.Object)
261 273
 
262  
-	if err != nil {
263  
-		panic(fmt.Sprintf("Encoding error: %v\n", err))
264  
-	}
265  
-	
266  
-	batch.Append(key, val)
267  
-
268  
-	return nil
  274
+func (context *levelDBContext) GetType(typeName string) *spack.VersionedType {
  275
+	return context.ldbStore.types.Type(typeName)
269 276
 }
270 277
 
271  
-func (batch *levelDBWriteBatch) StoreLinks(linkObj *logeObject) error {
272  
-	var set = linkObj.Current.Object.(*linkSet)
273  
-
274  
-	if len(set.Added) == 0 && len(set.Removed) == 0 {
275  
-		return nil
276  
-	}
277  
-
278  
-	var vt = batch.store.types.Type(linkObj.Type.Name)
279  
-	var linkInfo = linkObj.Type.Links[linkObj.LinkName]
280  
-
281  
-	var key = encodeTaggedKey([]uint16{ldb_LINK_TAG, vt.Tag, linkInfo.Tag}, string(linkObj.Key))
282  
-	val, _ := spack.EncodeToBytes(set.ReadKeys(), batch.store.linkSpec)
283  
-
284  
-	batch.Append(key, val)
285  
-
286  
-	var prefix = encodeTaggedKey([]uint16{ldb_INDEX_TAG, vt.Tag, linkInfo.Tag}, "")
287  
-	var source = string(linkObj.Key)
288  
-
289  
-	for _, target := range set.Removed {
290  
-		var key = encodeIndexKey(prefix, target, source)
291  
-		batch.Delete(key)
292  
-	}
293  
-
294  
-	for _, target := range set.Added {
295  
-		var key = encodeIndexKey(prefix, target, source)
296  
-		batch.Append(key, []byte{})
297  
-	}
298  
-
299  
-
  278
+func (context *levelDBContext) Put(key []byte, val []byte) error {
  279
+	context.batch = append(context.batch, levelDBWriteEntry{ key, val, false })
300 280
 	return nil
301 281
 }
302 282
 
303  
-func (batch *levelDBWriteBatch) Append(key []byte, val []byte) {
304  
-	batch.batch = append(batch.batch, levelDBWriteEntry{ key, val, false })
305  
-}
306  
-
307  
-func (batch *levelDBWriteBatch) Delete(key []byte) {
308  
-	batch.batch = append(batch.batch, levelDBWriteEntry{ key, nil, true })
  283
+func (context *levelDBContext) Delete(key []byte) error {
  284
+	context.batch = append(context.batch, levelDBWriteEntry{ key, nil, true })
  285
+	return nil
309 286
 }
310 287
 
311  
-func (batch *levelDBWriteBatch) Commit() error {
312  
-	batch.store.writeQueue <- batch
313  
-	return <-batch.result
  288
+func (context *levelDBContext) commit() error {
  289
+	context.ldbStore.writeQueue <- context
  290
+	return <-context.result
314 291
 }
315 292
 
316  
-func (batch *levelDBWriteBatch) Write() error {
  293
+func (context *levelDBContext) Write() error {
317 294
 	var wb = levigo.NewWriteBatch()
318 295
 	defer wb.Close()
319  
-	for _, entry := range batch.batch {
  296
+	for _, entry := range context.batch {
320 297
 		if entry.Delete {
321 298
 			wb.Delete(entry.Key)
322 299
 		} else {
@@ -324,9 +301,28 @@ func (batch *levelDBWriteBatch) Write() error {
324 301
 		}
325 302
 	}
326 303
 
327  
-	return batch.store.db.Write(writeOptions, wb)
  304
+	return context.ldbStore.db.Write(writeOptions, wb)
  305
+}
  306
+
  307
+func (context *levelDBContext) store(obj *logeObject) error {
  308
+	return ldb_store(context, obj)
  309
+}
  310
+
  311
+func (context *levelDBContext) storeLinks(obj *logeObject) error {
  312
+	return ldb_storeLinks(context, obj)
  313
+}
  314
+
  315
+func (context *levelDBContext) find(typ *logeType, linkName string, target LogeKey) ResultSet {
  316
+	return context.ldbStore.find(typ, linkName, target)
  317
+}
  318
+
  319
+func (context *levelDBContext) get(typ *logeType, key LogeKey) interface{} {
  320
+	return context.ldbStore.get(typ, key)
328 321
 }
329 322
 
  323
+func (context *levelDBContext) getLinks(typ *logeType, linkName string, key LogeKey) []string {
  324
+	return context.ldbStore.getLinks(typ, linkName, key)
  325
+}
330 326
 
331 327
 // -----------------------------------------------
332 328
 // Internals
@@ -356,7 +352,7 @@ func (store *levelDBStore) tagVersions(vt *spack.VersionedType, typ *logeType) {
356 352
 
357 353
 	for it = it; it.Valid(); it.Next() {
358 354
 		var info = &linkInfo{}
359  
-		spack.DecodeFromBytes(info, store.linkInfoSpec, it.Value())
  355
+		spack.DecodeFromBytes(info, linkInfoSpec, it.Value())
360 356
 		typ.Links[info.Name] = info
361 357
 	}
362 358
 
@@ -377,7 +373,7 @@ func (store *levelDBStore) tagVersions(vt *spack.VersionedType, typ *logeType) {
377 373
 		maxTag++
378 374
 		info.Tag = maxTag
379 375
 		var key = encodeTaggedKey([]uint16{ldb_LINK_INFO_TAG, vt.Tag}, info.Name)
380  
-		enc, _ := spack.EncodeToBytes(info, store.linkInfoSpec)
  376
+		enc, _ := spack.EncodeToBytes(info, linkInfoSpec)
381 377
 		fmt.Printf("Updating link: %s::%s (%d)\n", typ.Name, info.Name, info.Tag)
382 378
 		var err = store.db.Put(writeOptions, key, enc)
383 379
 		if err != nil {
@@ -410,6 +406,63 @@ func encodeIndexKey(prefix []byte, target string, source string) []byte {
410 406
 	return buf
411 407
 }
412 408
 
  409
+
  410
+// -----------------------------------------------
  411
+// Levigo interaction
  412
+// -----------------------------------------------
  413
+
  414
+func ldb_store(writer levelDBWriter, obj *logeObject) error {
  415
+	var vt = writer.GetType(obj.Type.Name)
  416
+	var key = vt.EncodeKey(string(obj.Key))
  417
+
  418
+	if !obj.Current.hasValue() {
  419
+		writer.Delete(key)
  420
+		return nil
  421
+	}
  422
+
  423
+	var val, err = vt.EncodeObj(obj.Current.Object)
  424
+
  425
+	if err != nil {
  426
+		panic(fmt.Sprintf("Encoding error: %v\n", err))
  427
+	}
  428
+	
  429
+	writer.Put(key, val)
  430
+
  431
+	return nil
  432
+}
  433
+
  434
+func ldb_storeLinks(writer levelDBWriter, linkObj *logeObject) error {
  435
+	var set = linkObj.Current.Object.(*linkSet)
  436
+
  437
+	if len(set.Added) == 0 && len(set.Removed) == 0 {
  438
+		return nil
  439
+	}
  440
+
  441
+	var vt = writer.GetType(linkObj.Type.Name)
  442
+	var linkInfo = linkObj.Type.Links[linkObj.LinkName]
  443
+
  444
+	var key = encodeTaggedKey([]uint16{ldb_LINK_TAG, vt.Tag, linkInfo.Tag}, string(linkObj.Key))
  445
+	val, _ := spack.EncodeToBytes(set.ReadKeys(), linkSpec)
  446
+
  447
+	writer.Put(key, val)
  448
+
  449
+	var prefix = encodeTaggedKey([]uint16{ldb_INDEX_TAG, vt.Tag, linkInfo.Tag}, "")
  450
+	var source = string(linkObj.Key)
  451
+
  452
+	for _, target := range set.Removed {
  453
+		var key = encodeIndexKey(prefix, target, source)
  454
+		writer.Delete(key)
  455
+	}
  456
+
  457
+	for _, target := range set.Added {
  458
+		var key = encodeIndexKey(prefix, target, source)
  459
+		writer.Put(key, []byte{})
  460
+	}
  461
+
  462
+
  463
+	return nil
  464
+}
  465
+
413 466
 // -----------------------------------------------
414 467
 // Prefix iterator
415 468
 // -----------------------------------------------
6  src/loge/objects.go
@@ -48,13 +48,13 @@ func (obj *logeObject) newVersion() *objectVersion {
48 48
 	}
49 49
 }
50 50
 
51  
-func (obj *logeObject) applyVersion(version *objectVersion, batch writeBatch) {
  51
+func (obj *logeObject) applyVersion(version *objectVersion, context storeContext) {
52 52
 	obj.Current = version
53 53
 
54 54
 	if obj.LinkName == "" {
55  
-		batch.Store(obj)
  55
+		context.store(obj)
56 56
 	} else {
57  
-		batch.StoreLinks(obj)
  57
+		context.storeLinks(obj)
58 58
 	}
59 59
 
60 60
 	version.Dirty = false
98  src/loge/storage.go
... ...
@@ -1,13 +1,11 @@
1 1
 package loge
2 2
 
  3
+
3 4
 type LogeStore interface {
4  
-	get(t *logeType, key LogeKey) interface{}
5  
-	getLinks(*logeType, string, LogeKey) []string
6  
-	find(*logeType, string, LogeKey) ResultSet
  5
+	storeContext
7 6
 	close()
8  
-
9 7
 	registerType(*logeType)
10  
-	newWriteBatch() writeBatch
  8
+	newContext() transactionContext
11 9
 }
12 10
 
13 11
 type ResultSet interface {
@@ -16,12 +14,18 @@ type ResultSet interface {
16 14
 	Close()
17 15
 }
18 16
 
19  
-type writeBatch interface {
20  
-	Store(*logeObject) error
21  
-	StoreLinks(*logeObject) error
22  
-	Commit() error
  17
+type storeContext interface {
  18
+	get(*logeType, LogeKey) interface{}
  19
+	getLinks(*logeType, string, LogeKey) []string
  20
+	find(*logeType, string, LogeKey) ResultSet
  21
+	store(*logeObject) error
  22
+	storeLinks(*logeObject) error
23 23
 }
24 24
 
  25
+type transactionContext interface {
  26
+	storeContext
  27
+	commit() error
  28
+}
25 29
 
26 30
 type objectMap map[string]map[LogeKey]interface{}
27 31
 
@@ -31,8 +35,8 @@ type memStore struct {
31 35
 	lock spinLock
32 36
 }
33 37
 
34  
-type memWriteBatch struct {
35  
-	store *memStore
  38
+type memContext struct {
  39
+	mstore *memStore
36 40
 	writes []memWriteEntry
37 41
 }
38 42
 
@@ -61,12 +65,10 @@ func (store *memStore) registerType(typ *logeType) {
61 65
 
62 66
 func (store *memStore) get(t *logeType, key LogeKey) interface{} {
63 67
 	var objMap = store.objects[t.Name]
64  
-
65 68
 	object, ok := objMap[key]
66 69
 	if !ok {
67 70
 		return nil
68 71
 	}
69  
-
70 72
 	return object
71 73
 }
72 74
 
@@ -85,27 +87,61 @@ func (store *memStore) find(typ *logeType, linkName string, key LogeKey) ResultS
85 87
 	panic("Find not implemented on memstore")
86 88
 }
87 89
 
88  
-func (store *memStore) newWriteBatch() writeBatch {
89  
-	return &memWriteBatch{
90  
-		store: store,
  90
+func (store *memStore) store(obj *logeObject) error {
  91
+	obj.Lock.SpinLock()
  92
+	defer obj.Lock.Unlock()
  93
+	if !obj.Current.hasValue() {
  94
+		delete(store.objects[obj.Type.Name], obj.Key)
  95
+	} else {
  96
+		store.objects[obj.Type.Name][obj.Key] = obj.Current.Object
91 97
 	}
  98
+	return nil
92 99
 }
93 100
 
  101
+func (store *memStore) storeLinks(obj *logeObject) error {
  102
+	obj.Lock.SpinLock()
  103
+	defer obj.Lock.Unlock()
  104
+	var typeKey = memStoreLinkKey(obj.Type.Name, obj.LinkName)
  105
+	var val = linkList(obj.Current.Object.(*linkSet).ReadKeys())
  106
+	store.objects[typeKey][obj.Key] = val
  107
+	return nil
  108
+}
94 109
 
95  
-func (batch *memWriteBatch) Store(obj *logeObject) error {
96  
-	batch.writes = append(
97  
-		batch.writes,
  110
+func (store *memStore) newContext() transactionContext {
  111
+	return &memContext{
  112
+		mstore: store,
  113
+	}
  114
+}
  115
+
  116
+
  117
+func (context *memContext) get(t *logeType, key LogeKey) interface{} {
  118
+	return context.mstore.get(t, key)
  119
+}
  120
+
  121
+func (context *memContext) getLinks(t *logeType, linkName string, key LogeKey) []string {
  122
+	return context.mstore.getLinks(t, linkName, key)
  123
+}
  124
+
  125
+func (context *memContext) store(obj *logeObject) error {
  126
+	var val interface{}
  127
+	if !obj.Current.hasValue() {
  128
+		val = nil
  129
+	} else {
  130
+		val = obj.Current.Object
  131
+	}
  132
+	context.writes = append(
  133
+		context.writes,
98 134
 		memWriteEntry{ 
99 135
 		TypeKey: obj.Type.Name, 
100 136
 		ObjKey: obj.Key, 
101  
-		Value: obj.Current.Object,
  137
+		Value: val,
102 138
 	})
103 139
 	return nil
104 140
 }
105 141
 
106  
-func (batch *memWriteBatch) StoreLinks(obj *logeObject) error {
107  
-	batch.writes = append(
108  
-		batch.writes,
  142
+func (context *memContext) storeLinks(obj *logeObject) error {
  143
+	context.writes = append(
  144
+		context.writes,
109 145
 		memWriteEntry{ 
110 146
 		TypeKey: memStoreLinkKey(obj.Type.Name, obj.LinkName),
111 147
 		ObjKey: obj.Key,
@@ -114,11 +150,17 @@ func (batch *memWriteBatch) StoreLinks(obj *logeObject) error {
114 150
 	return nil
115 151
 }
116 152
 
117  
-func (batch *memWriteBatch) Commit() error {
118  
-	batch.store.lock.SpinLock()
119  
-	defer batch.store.lock.Unlock()
120  
-	for _, entry := range batch.writes {
121  
-		batch.store.objects[entry.TypeKey][entry.ObjKey] = entry.Value
  153
+func (context *memContext) find(typ *logeType, linkName string, key LogeKey) ResultSet {
  154
+	// Until I can be bothered
  155
+	panic("Find not implemented on memstore")
  156
+}
  157
+
  158
+func (context *memContext) commit() error {
  159
+	var store = context.mstore
  160
+	store.lock.SpinLock()
  161
+	defer store.lock.Unlock()
  162
+	for _, entry := range context.writes {
  163
+		store.objects[entry.TypeKey][entry.ObjKey] = entry.Value
122 164
 	}
123 165
 	return nil
124 166
 }
5  src/loge/transactions.go
@@ -165,7 +165,6 @@ func (t *Transaction) Commit() bool {
165 165
 }
166 166
 
167 167
 func (t *Transaction) tryCommit() bool {
168  
-	//fmt.Printf("-------------\n")
169 168
 	for _, version := range t.versions {
170 169
 		var obj = version.LogeObj
171 170
 
@@ -187,7 +186,7 @@ func (t *Transaction) tryCommit() bool {
187 186
 		}
188 187
 	}
189 188
 
190  
-	var batch = t.db.newWriteBatch()
  189
+	var batch = t.db.store.newContext()
191 190
 	for _, version := range t.versions {
192 191
 		version.LogeObj.RefCount--
193 192
 		if version.Dirty {
@@ -195,7 +194,7 @@ func (t *Transaction) tryCommit() bool {
195 194
 		}
196 195
 	}
197 196
 
198  
-	var err = batch.Commit()
  197
+	var err = batch.commit()
199 198
 	if err != nil {
200 199
 		t.state = ERROR
201 200
 		fmt.Printf("Commit error: %v\n", err)
4  src/logetest/main.go
@@ -12,8 +12,8 @@ type Pet struct {
12 12
 }
13 13
 
14 14
 func main() {
15  
-	LinkBench()
16  
-	//LinkSandbox()
  15
+	//LinkBench()
  16
+	LinkSandbox()
17 17
 	//WriteBench()
18 18
 	//Sandbox()
19 19
 	//Example()

No commit comments for this range

Something went wrong with that request. Please try again.