Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed May 21, 2024
1 parent f767704 commit 8cf6207
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ go 1.21

toolchain go1.22.2

require github.com/absolutelightning/go-immutable-adaptive-radix v1.0.10
require github.com/absolutelightning/go-immutable-adaptive-radix v1.0.11

require github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/absolutelightning/go-immutable-adaptive-radix v1.0.10 h1:/TEeOgR2I8XNxogniqcr6n9679FKMfyrPJ0Bn5xwgcc=
github.com/absolutelightning/go-immutable-adaptive-radix v1.0.10/go.mod h1:mnTsE7jTX4QguPvFwr9Ih787akkQzPGpdtUlg5PJ4K4=
github.com/absolutelightning/go-immutable-adaptive-radix v1.0.11 h1:Pw3M6yzC7McSRm1CUNacz9AcgI67Dq1m1QokrJXrH/s=
github.com/absolutelightning/go-immutable-adaptive-radix v1.0.11/go.mod h1:mnTsE7jTX4QguPvFwr9Ih787akkQzPGpdtUlg5PJ4K4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
Expand Down
2 changes: 0 additions & 2 deletions integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ func TestComplexDB(t *testing.T) {
}
}

// TODO Revisit
func TestWatchUpdate(t *testing.T) {
t.Skip()
db := testComplexDB(t)
testPopulateData(t, db)
txn := db.Txn(false) // read only
Expand Down
11 changes: 7 additions & 4 deletions memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ func (db *MemDB) DBSchema() *DBSchema {
}

// getRoot is used to do an atomic load of the root pointer
func (db *MemDB) getRoot() *adaptive.RadixTree[any] {
func (db *MemDB) getRoot(clone bool) *adaptive.RadixTree[any] {
root := (*adaptive.RadixTree[any])(atomic.LoadPointer(&db.root))
if clone {
return root.Clone(true)
}
return root
}

Expand All @@ -77,7 +80,7 @@ func (db *MemDB) Txn(write bool) *Txn {
txn := &Txn{
db: db,
write: write,
rootTxn: db.getRoot().Txn(),
rootTxn: db.getRoot(false).Txn(),
}
return txn
}
Expand All @@ -91,7 +94,7 @@ func (db *MemDB) Txn(write bool) *Txn {
func (db *MemDB) Snapshot() *MemDB {
clone := &MemDB{
schema: db.schema,
root: unsafe.Pointer(db.getRoot()),
root: unsafe.Pointer(db.getRoot(true)),
primary: false,
}
return clone
Expand All @@ -100,7 +103,7 @@ func (db *MemDB) Snapshot() *MemDB {
// initialize is used to setup the DB for use after creation. This should
// be called only once after allocating a MemDB.
func (db *MemDB) initialize() error {
root := db.getRoot()
root := db.getRoot(false)
for tName, tableSchema := range db.schema.Tables {
for iName := range tableSchema.Indexes {
index := adaptive.NewRadixTree[any]()
Expand Down

0 comments on commit 8cf6207

Please sign in to comment.