Fix PrimaryKey Marshalling and add Bolt test

Based on LevelDB test exactly. Sure enough, it found a bug.
This commit is contained in:
Barak Michener 2015-02-21 18:25:00 -05:00
parent cf3e286d15
commit bffcd47257
3 changed files with 471 additions and 4 deletions

View file

@ -368,7 +368,7 @@ func (qs *QuadStore) Close() {
}
func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
var q quad.Quad
var d graph.Delta
tok := k.(*Token)
err := qs.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket(tok.bucket)
@ -390,13 +390,13 @@ func (qs *QuadStore) Quad(k graph.Value) quad.Quad {
// No harm, no foul.
return nil
}
return json.Unmarshal(data, &q)
return json.Unmarshal(data, &d)
})
if err != nil {
glog.Error("Error getting quad: ", err)
return quad.Quad{}
}
return q
return d.Quad
}
func (qs *QuadStore) ValueOf(s string) graph.Value {