Use BINC encoding instead of MsgPACK for storage
This commit is contained in:
parent
218ce8ad82
commit
dc3793d03d
3 changed files with 9 additions and 8 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue