Skip to content

Commit 813bda0

Browse files
committed
1 parent 88e921b commit 813bda0

7 files changed

+52
-36
lines changed

client_tools.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type IntKey struct {
88

99
func (k IntKey) encodeMsgpackImpl(enc *Encoder) error {
1010
enc.EncodeArrayLen(1)
11-
enc.EncodeInt(k.I)
11+
enc.encodeIntImpl(int64(k.I))
1212
return nil
1313
}
1414

@@ -20,7 +20,7 @@ type UintKey struct {
2020

2121
func (k UintKey) encodeMsgpackImpl(enc *Encoder) error {
2222
enc.EncodeArrayLen(1)
23-
enc.EncodeUint(k.I)
23+
enc.encodeUintImpl(uint64(k.I))
2424
return nil
2525
}
2626

@@ -44,8 +44,8 @@ type IntIntKey struct {
4444

4545
func (k IntIntKey) encodeMsgpackImpl(enc *Encoder) error {
4646
enc.EncodeArrayLen(2)
47-
enc.EncodeInt(k.I1)
48-
enc.EncodeInt(k.I2)
47+
enc.encodeIntImpl(int64(k.I1))
48+
enc.encodeIntImpl(int64(k.I2))
4949
return nil
5050
}
5151

@@ -59,7 +59,7 @@ type Op struct {
5959
func (o Op) encodeMsgpackImpl(enc *Encoder) error {
6060
enc.EncodeArrayLen(3)
6161
enc.EncodeString(o.Op)
62-
enc.EncodeInt(o.Field)
62+
enc.encodeIntImpl(int64(o.Field))
6363
return enc.Encode(o.Arg)
6464
}
6565

@@ -147,9 +147,9 @@ type OpSplice struct {
147147
func (o OpSplice) encodeMsgpackImpl(enc *Encoder) error {
148148
enc.EncodeArrayLen(5)
149149
enc.EncodeString(o.Op)
150-
enc.EncodeInt(o.Field)
151-
enc.EncodeInt(o.Pos)
152-
enc.EncodeInt(o.Len)
150+
enc.encodeIntImpl(int64(o.Field))
151+
enc.encodeIntImpl(int64(o.Pos))
152+
enc.encodeIntImpl(int64(o.Len))
153153
enc.EncodeString(o.Replace)
154154
return nil
155155
}

datetime/datetime_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (c *Tuple2) encodeMsgpackImpl(e *Encoder) error {
332332
if err := e.EncodeArrayLen(3); err != nil {
333333
return err
334334
}
335-
if err := e.EncodeUint(c.Cid); err != nil {
335+
if err := e.EncodeUint64(uint64(c.Cid)); err != nil {
336336
return err
337337
}
338338
if err := e.EncodeString(c.Orig); err != nil {

example_custom_unpacking_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (c *Tuple2) encodeMsgpackImpl(e *tarantool.Encoder) error {
2727
if err := e.EncodeArrayLen(3); err != nil {
2828
return err
2929
}
30-
if err := e.EncodeUint(c.Cid); err != nil {
30+
if err := e.EncodeUintImpl(uint64(c.Cid)); err != nil {
3131
return err
3232
}
3333
if err := e.EncodeString(c.Orig); err != nil {

export_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,11 @@ func RefImplExecuteBody(enc *Encoder, expr string, args interface{}) error {
7878
func NewEncoder(w io.Writer) *Encoder {
7979
return newEncoder(w)
8080
}
81+
82+
func (e *Encoder) EncodeUintImpl(v uint64) error {
83+
return e.encodeUintImpl(v)
84+
}
85+
86+
func (e *Encoder) EncodeIntImpl(v int64) error {
87+
return e.encodeIntImpl(v)
88+
}

msgpack.go

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ func newDecoder(r io.Reader) *Decoder {
2525
return &Decoder{Decoder: dec}
2626
}
2727

28+
func (e *Encoder) encodeUintImpl(v uint64) error {
29+
return e.EncodeUint(uint(v))
30+
}
31+
32+
func (e *Encoder) encodeIntImpl(v int64) error {
33+
return e.EncodeInt(int(v))
34+
}
35+
2836
func msgpackIsUint(code byte) bool {
2937
return code == msgpcode.Uint8 || code == msgpcode.Uint16 ||
3038
code == msgpcode.Uint32 || code == msgpcode.Uint64 ||

request.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@ import (
88
)
99

1010
func fillSearch(enc *Encoder, spaceNo, indexNo uint32, key interface{}) error {
11-
enc.EncodeUint(KeySpaceNo)
12-
enc.EncodeUint(uint(spaceNo))
13-
enc.EncodeUint(KeyIndexNo)
14-
enc.EncodeUint(uint(indexNo))
15-
enc.EncodeUint(KeyKey)
11+
enc.encodeUintImpl(KeySpaceNo)
12+
enc.encodeUintImpl(uint64(spaceNo))
13+
enc.encodeUintImpl(KeyIndexNo)
14+
enc.encodeUintImpl(uint64(indexNo))
15+
enc.encodeUintImpl(KeyKey)
1616
return enc.Encode(key)
1717
}
1818

1919
func fillIterator(enc *Encoder, offset, limit, iterator uint32) {
20-
enc.EncodeUint(KeyIterator)
21-
enc.EncodeUint(uint(iterator))
22-
enc.EncodeUint(KeyOffset)
23-
enc.EncodeUint(uint(offset))
24-
enc.EncodeUint(KeyLimit)
25-
enc.EncodeUint(uint(limit))
20+
enc.encodeUintImpl(KeyIterator)
21+
enc.encodeUintImpl(uint64(iterator))
22+
enc.encodeUintImpl(KeyOffset)
23+
enc.encodeUintImpl(uint64(offset))
24+
enc.encodeUintImpl(KeyLimit)
25+
enc.encodeUintImpl(uint64(limit))
2626
}
2727

2828
func fillInsert(enc *Encoder, spaceNo uint32, tuple interface{}) error {
2929
enc.EncodeMapLen(2)
30-
enc.EncodeUint(KeySpaceNo)
31-
enc.EncodeUint(uint(spaceNo))
32-
enc.EncodeUint(KeyTuple)
30+
enc.encodeUintImpl(KeySpaceNo)
31+
enc.encodeUintImpl(uint64(spaceNo))
32+
enc.encodeUintImpl(KeyTuple)
3333
return enc.Encode(tuple)
3434
}
3535

@@ -44,19 +44,19 @@ func fillUpdate(enc *Encoder, spaceNo, indexNo uint32, key, ops interface{}) err
4444
if err := fillSearch(enc, spaceNo, indexNo, key); err != nil {
4545
return err
4646
}
47-
enc.EncodeUint(KeyTuple)
47+
enc.encodeUintImpl(KeyTuple)
4848
return enc.Encode(ops)
4949
}
5050

5151
func fillUpsert(enc *Encoder, spaceNo uint32, tuple, ops interface{}) error {
5252
enc.EncodeMapLen(3)
53-
enc.EncodeUint(KeySpaceNo)
54-
enc.EncodeUint(uint(spaceNo))
55-
enc.EncodeUint(KeyTuple)
53+
enc.encodeUintImpl(KeySpaceNo)
54+
enc.encodeUintImpl(uint64(spaceNo))
55+
enc.encodeUintImpl(KeyTuple)
5656
if err := enc.Encode(tuple); err != nil {
5757
return err
5858
}
59-
enc.EncodeUint(KeyDefTuple)
59+
enc.encodeUintImpl(KeyDefTuple)
6060
return enc.Encode(ops)
6161
}
6262

@@ -67,25 +67,25 @@ func fillDelete(enc *Encoder, spaceNo, indexNo uint32, key interface{}) error {
6767

6868
func fillCall(enc *Encoder, functionName string, args interface{}) error {
6969
enc.EncodeMapLen(2)
70-
enc.EncodeUint(KeyFunctionName)
70+
enc.encodeUintImpl(KeyFunctionName)
7171
enc.EncodeString(functionName)
72-
enc.EncodeUint(KeyTuple)
72+
enc.encodeUintImpl(KeyTuple)
7373
return enc.Encode(args)
7474
}
7575

7676
func fillEval(enc *Encoder, expr string, args interface{}) error {
7777
enc.EncodeMapLen(2)
78-
enc.EncodeUint(KeyExpression)
78+
enc.encodeUintImpl(KeyExpression)
7979
enc.EncodeString(expr)
80-
enc.EncodeUint(KeyTuple)
80+
enc.encodeUintImpl(KeyTuple)
8181
return enc.Encode(args)
8282
}
8383

8484
func fillExecute(enc *Encoder, expr string, args interface{}) error {
8585
enc.EncodeMapLen(2)
86-
enc.EncodeUint(KeySQLText)
86+
enc.encodeUintImpl(KeySQLText)
8787
enc.EncodeString(expr)
88-
enc.EncodeUint(KeySQLBind)
88+
enc.encodeUintImpl(KeySQLBind)
8989
return encodeSQLBind(enc, args)
9090
}
9191

tarantool_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (m *Member) encodeMsgpackImpl(e *Encoder) error {
2828
if err := e.EncodeString(m.Name); err != nil {
2929
return err
3030
}
31-
if err := e.EncodeUint(m.Val); err != nil {
31+
if err := e.EncodeUintImpl(uint64(m.Val)); err != nil {
3232
return err
3333
}
3434
return nil

0 commit comments

Comments
 (0)