@@ -13,18 +13,6 @@ import (
1313 "github.com/vmihailenco/msgpack/v5"
1414)
1515
16- // INSERT Arrow request.
17- //
18- // FIXME: replace with iproto.IPROTO_INSERT_ARROW when iproto will released.
19- // https://github.com/tarantool/go-replica/issues/30
20- const iprotoInsertArrowType = iproto .Type (17 )
21-
22- // The data in Arrow format.
23- //
24- // FIXME: replace with iproto.IPROTO_ARROW when iproto will released.
25- // https://github.com/tarantool/go-replica/issues/30
26- const iprotoArrowKey = iproto .Key (0x36 )
27-
2816type spaceEncoder struct {
2917 Id uint32
3018 Name string
@@ -148,20 +136,6 @@ func fillInsert(enc *msgpack.Encoder, spaceEnc spaceEncoder, tuple interface{})
148136 return enc .Encode (tuple )
149137}
150138
151- func fillInsertArrow (enc * msgpack.Encoder , spaceEnc spaceEncoder , arrow interface {}) error {
152- if err := enc .EncodeMapLen (2 ); err != nil {
153- return err
154- }
155- if err := spaceEnc .Encode (enc ); err != nil {
156- return err
157- }
158-
159- if err := enc .EncodeUint (uint64 (iprotoArrowKey )); err != nil {
160- return err
161- }
162- return enc .Encode (arrow )
163- }
164-
165139func fillSelect (enc * msgpack.Encoder , spaceEnc spaceEncoder , indexEnc indexEncoder ,
166140 offset , limit uint32 , iterator Iter , key , after interface {}, fetchPos bool ) error {
167141 mapLen := 6
@@ -888,17 +862,41 @@ func (req *baseRequest) Response(header Header, body io.Reader) (Response, error
888862 return & resp , nil
889863}
890864
891- type spaceRequest struct {
865+ type SpaceRequest struct {
892866 baseRequest
893867 space interface {}
894868}
895869
896- func (req * spaceRequest ) setSpace (space interface {}) {
870+ func (r * SpaceRequest ) Context (ctx context.Context ) {
871+ r .ctx = ctx
872+ }
873+
874+ func NewSpaceRequest (rtype iproto.Type , space interface {}) SpaceRequest {
875+ return SpaceRequest {
876+ baseRequest : baseRequest {
877+ rtype : rtype ,
878+ },
879+ space : space ,
880+ }
881+ }
882+
883+ func (req * SpaceRequest ) setSpace (space interface {}) {
897884 req .space = space
898885}
899886
887+ func (req * SpaceRequest ) Encode (res SchemaResolver , enc * msgpack.Encoder ) error {
888+ spaceEnc , err := newSpaceEncoder (res , req .space )
889+ if err != nil {
890+ return err
891+ }
892+ if err := spaceEnc .Encode (enc ); err != nil {
893+ return err
894+ }
895+ return nil
896+ }
897+
900898type spaceIndexRequest struct {
901- spaceRequest
899+ SpaceRequest
902900 index interface {}
903901}
904902
@@ -1141,7 +1139,7 @@ func (req *SelectRequest) Response(header Header, body io.Reader) (Response, err
11411139// InsertRequest helps you to create an insert request object for execution
11421140// by a Connection.
11431141type InsertRequest struct {
1144- spaceRequest
1142+ SpaceRequest
11451143 tuple interface {}
11461144}
11471145
@@ -1182,54 +1180,10 @@ func (req *InsertRequest) Context(ctx context.Context) *InsertRequest {
11821180 return req
11831181}
11841182
1185- // InsertArrowRequest helps you to create an insert request object for execution
1186- // by a Connection.
1187- type InsertArrowRequest struct {
1188- spaceRequest
1189- arrow interface {}
1190- }
1191-
1192- // NewInsertArrowRequest returns a new empty InsertArrowRequest.
1193- func NewInsertArrowRequest (space interface {}) * InsertArrowRequest {
1194- req := new (InsertArrowRequest )
1195- req .rtype = iprotoInsertArrowType
1196- req .setSpace (space )
1197- req .arrow = []interface {}{}
1198- return req
1199- }
1200-
1201- // Arrow sets the arrow for insertion the insert arrow request.
1202- // Note: default value is nil.
1203- func (req * InsertArrowRequest ) Arrow (arrow interface {}) * InsertArrowRequest {
1204- req .arrow = arrow
1205- return req
1206- }
1207-
1208- // Body fills an msgpack.Encoder with the insert arrow request body.
1209- func (req * InsertArrowRequest ) Body (res SchemaResolver , enc * msgpack.Encoder ) error {
1210- spaceEnc , err := newSpaceEncoder (res , req .space )
1211- if err != nil {
1212- return err
1213- }
1214-
1215- return fillInsertArrow (enc , spaceEnc , req .arrow )
1216- }
1217-
1218- // Context sets a passed context to the request.
1219- //
1220- // Pay attention that when using context with request objects,
1221- // the timeout option for Connection does not affect the lifetime
1222- // of the request. For those purposes use context.WithTimeout() as
1223- // the root context.
1224- func (req * InsertArrowRequest ) Context (ctx context.Context ) * InsertArrowRequest {
1225- req .ctx = ctx
1226- return req
1227- }
1228-
12291183// ReplaceRequest helps you to create a replace request object for execution
12301184// by a Connection.
12311185type ReplaceRequest struct {
1232- spaceRequest
1186+ SpaceRequest
12331187 tuple interface {}
12341188}
12351189
@@ -1391,7 +1345,7 @@ func (req *UpdateRequest) Context(ctx context.Context) *UpdateRequest {
13911345// UpsertRequest helps you to create an upsert request object for execution
13921346// by a Connection.
13931347type UpsertRequest struct {
1394- spaceRequest
1348+ SpaceRequest
13951349 tuple interface {}
13961350 ops * Operations
13971351}
0 commit comments