From dc3793d03da724ceb944cd7e942288b89974275c Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 14 Sep 2016 22:26:41 +0100 Subject: [PATCH] Use BINC encoding instead of MsgPACK for storage --- db/define.go | 6 +++--- util/data/data.go | 4 ++-- util/item/item.go | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/db/define.go b/db/define.go index 504c511d..a0b5ce31 100644 --- a/db/define.go +++ b/db/define.go @@ -97,7 +97,7 @@ func executeDefineRulesStatement(txn kvs.TX, ast *sql.DefineRulesStatement) (out // Set the field definition rkey := &keys.RU{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, RU: RU} - if err := txn.Put(rkey.Encode(), pack.ToPACK(ast)); err != nil { + if err := txn.Put(rkey.Encode(), pack.ToBINC(ast)); err != nil { return nil, err } @@ -146,7 +146,7 @@ func executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldStatement) (out // Set the field definition fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, FD: ast.Name} - if err := txn.Put(fkey.Encode(), pack.ToPACK(ast)); err != nil { + if err := txn.Put(fkey.Encode(), pack.ToBINC(ast)); err != nil { return nil, err } @@ -193,7 +193,7 @@ func executeDefineIndexStatement(txn kvs.TX, ast *sql.DefineIndexStatement) (out // Set the index definition ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: ast.Name} - if err := txn.Put(ikey.Encode(), pack.ToPACK(ast)); err != nil { + if err := txn.Put(ikey.Encode(), pack.ToBINC(ast)); err != nil { return nil, err } diff --git a/util/data/data.go b/util/data/data.go index ca13785c..b383b4f9 100644 --- a/util/data/data.go +++ b/util/data/data.go @@ -57,13 +57,13 @@ func (d *Doc) JSON() (data []byte) { // Encode encodes the data object to a byte slice. func (d *Doc) Encode() (dst []byte) { - dst = pack.ToPACK(d.data) + dst = pack.ToBINC(d.data) return } // Decode decodes the byte slice into a data object. func (d *Doc) Decode(src []byte) *Doc { - pack.FromPACK(src, d.data) + pack.FromBINC(src, d.data) return d } diff --git a/util/item/item.go b/util/item/item.go index 0b688072..ac38a43b 100644 --- a/util/item/item.go +++ b/util/item/item.go @@ -16,6 +16,7 @@ package item import ( "fmt" + "reflect" "github.com/abcum/surreal/kvs" "github.com/abcum/surreal/sql" @@ -74,7 +75,7 @@ func (this *Doc) getRules() { key := new(keys.RU) key.Decode(kv.Key()) if str, ok := key.RU.(string); ok { - pack.FromPACK(kv.Val(), &rul) + pack.FromBINC(kv.Val(), &rul) this.rules[str] = &rul } } @@ -91,7 +92,7 @@ func (this *Doc) getFields() { for _, kv := range rng { var fld sql.DefineFieldStatement - pack.FromPACK(kv.Val(), &fld) + pack.FromBINC(kv.Val(), &fld) this.fields = append(this.fields, &fld) } @@ -107,7 +108,7 @@ func (this *Doc) getIndexs() { for _, kv := range rng { var idx sql.DefineIndexStatement - pack.FromPACK(kv.Val(), &idx) + pack.FromBINC(kv.Val(), &idx) this.indexs = append(this.indexs, &idx) }