Skip to content

Commit

Permalink
Add global data pool
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Nov 2, 2023
1 parent 6893c03 commit 4ac4649
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pack_data.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tarantool

import (
"bytes"
"fmt"
"sync"

Expand Down Expand Up @@ -169,13 +168,17 @@ func (data *packData) packIndex(space interface{}, index interface{}, o []byte)
}

func (data *packData) MarshalMsg(o []byte) ([]byte, error) {
o, _ = msgp.AppendIntf(o, data.defaultSpace)
var err error

if o, err = msgp.AppendIntf(o, data.defaultSpace); err != nil {
return o, err
}
o = msgp.AppendBytes(o, data.packedDefaultSpace)
o, _ = msgp.AppendIntf(o, data.packedDefaultIndex)
o, _ = msgp.AppendIntf(o, data.packedIterEq)
o, _ = msgp.AppendIntf(o, data.packedDefaultLimit)
o, _ = msgp.AppendIntf(o, data.packedDefaultOffset)
o, _ = msgp.AppendIntf(o, data.packedSingleKey)
o = msgp.AppendBytes(o, data.packedDefaultIndex)
o = msgp.AppendBytes(o, data.packedIterEq)
o = msgp.AppendBytes(o, data.packedDefaultLimit)
o = msgp.AppendBytes(o, data.packedDefaultOffset)
o = msgp.AppendBytes(o, data.packedSingleKey)

o = msgp.AppendMapHeader(o, uint32(len(data.spaceMap)))
for key, val := range data.spaceMap {
Expand All @@ -196,7 +199,9 @@ func (data *packData) MarshalMsg(o []byte) ([]byte, error) {
o = msgp.AppendMapHeader(o, uint32(len(data.primaryKeyMap)))
for key, val := range data.primaryKeyMap {
o = msgp.AppendUint64(o, key)
o, _ = msgp.AppendIntf(o, val)
if o, err = msgp.AppendIntf(o, val); err != nil {
return o, err
}
}

return o, nil
Expand All @@ -209,18 +214,13 @@ func (pool *packDataPool) Put(data *packData) *packData {
return nil
}

o, err := data.MarshalMsg(nil)
o, err := msgp.AppendIntf(nil, data)
if err != nil {
fmt.Println(err)
return data
}

var buf bytes.Buffer
msgp.CopyToJSON(&buf, bytes.NewReader(o))
key := buf.String()

fmt.Println(data)
fmt.Println("json", key)
key := string(o)
fmt.Println("key", string(o))

pool.Lock()
Expand Down

0 comments on commit 4ac4649

Please sign in to comment.