1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 13:30:26 +00:00

Drop memdb dependency because it is not used yet

This commit is contained in:
bouncepaw 2021-01-24 13:36:03 +05:00
parent 225c83d851
commit f34757afbd
4 changed files with 2 additions and 89 deletions

1
go.mod
View File

@ -5,7 +5,6 @@ go 1.14
require ( require (
github.com/adrg/xdg v0.2.2 github.com/adrg/xdg v0.2.2
github.com/gorilla/feeds v1.1.1 github.com/gorilla/feeds v1.1.1
github.com/hashicorp/go-memdb v1.3.0
github.com/kr/pretty v0.2.1 // indirect github.com/kr/pretty v0.2.1 // indirect
github.com/valyala/quicktemplate v1.6.3 github.com/valyala/quicktemplate v1.6.3
) )

9
go.sum
View File

@ -5,15 +5,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY= github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA= github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-memdb v1.3.0 h1:xdXq34gBOMEloa9rlGStLxmfX/dyIK8htOv36dQUwHU=
github.com/hashicorp/go-memdb v1.3.0/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=

View File

@ -1,8 +1,7 @@
package hyphae package hyphae
import ( // TODO: do
"github.com/bouncepaw/mycorrhiza/storage" import ()
)
type Hypha struct { type Hypha struct {
Name string Name string
@ -15,17 +14,6 @@ type Hypha struct {
// AddHypha adds a hypha named `name` with such `textPath` and `binaryPath`. Both paths can be empty. Does //not// check for hypha's existence beforehand. Count is handled. // AddHypha adds a hypha named `name` with such `textPath` and `binaryPath`. Both paths can be empty. Does //not// check for hypha's existence beforehand. Count is handled.
func AddHypha(name, textPath, binaryPath string) { func AddHypha(name, textPath, binaryPath string) {
txn := storage.DB.Txn(true)
txn.Insert("hyphae",
&Hypha{
Name: name,
TextPath: textPath,
BinaryPath: binaryPath,
OutLinks: make([]string, 0),
BackLinks: make([]string, 0),
})
txn.Commit()
IncrementCount()
} }
// DeleteHypha clears both paths and all out-links from the named hypha and marks it as non-existent. It does not actually delete it from the memdb. Count is handled. // DeleteHypha clears both paths and all out-links from the named hypha and marks it as non-existent. It does not actually delete it from the memdb. Count is handled.

View File

@ -1,65 +0,0 @@
package storage
import (
"github.com/hashicorp/go-memdb"
)
// Create the DB schema
var schema = &memdb.DBSchema{
Tables: map[string]*memdb.TableSchema{
"hyphae": &memdb.TableSchema{
Name: "hyphae",
Indexes: map[string]*memdb.IndexSchema{
"id": &memdb.IndexSchema{
Name: "id",
Unique: true,
Indexer: &memdb.StringFieldIndex{Field: "Name"},
},
"exists": &memdb.IndexSchema{
Name: "exists",
Unique: false,
Indexer: &memdb.BoolFieldIndex{Field: "Exists"},
},
"out-links": &memdb.IndexSchema{
Name: "out-links",
Unique: false,
Indexer: &memdb.StringSliceFieldIndex{Field: "OutLinks"},
},
"back-links": &memdb.IndexSchema{
Name: "back-links",
Unique: false,
Indexer: &memdb.StringSliceFieldIndex{Field: "BackLinks"},
},
},
},
},
}
var DB *memdb.MemDB
func init() {
var err error
DB, err = memdb.NewMemDB(schema)
if err != nil {
panic(err)
}
}
func ForEveryRecord(table string, λ func(obj interface{})) error {
txn := DB.Txn(false)
defer txn.Abort()
it, err := txn.Get(table, "id")
if err != nil {
return err
}
for obj := it.Next(); obj != nil; obj = it.Next() {
λ(obj)
}
return nil
}
func TxnW() *memdb.Txn { return DB.Txn(true) }
func TxnR() *memdb.Txn { return DB.Txn(false) }