Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: add support of a batch insert request #411

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dmyger
Copy link

@dmyger dmyger commented Oct 2, 2024

Draft changes: add support the IPROTO_INSERT_ARROW request and message pack type MP_ARROW .

Closes #399

@dmyger dmyger added the feature A new functionality label Oct 2, 2024
@oleg-jukovec oleg-jukovec removed the feature A new functionality label Oct 2, 2024
@dmyger dmyger force-pushed the dmyger/gh-399-add-support-IPROTO_INSERT_ARROW branch 11 times, most recently from 1f88b6f to b6ad2cc Compare October 7, 2024 15:46
@dmyger dmyger marked this pull request as ready for review October 7, 2024 15:47
@dmyger dmyger requested a review from DerekBum October 7, 2024 15:48
arrow/arrow.go Outdated Show resolved Hide resolved
test_helpers/main.go Outdated Show resolved Hide resolved
test_helpers/main.go Show resolved Hide resolved
arrow/arrow.go Outdated Show resolved Hide resolved
arrow/arrow.go Outdated Show resolved Hide resolved
arrow/example_test.go Outdated Show resolved Hide resolved
arrow/example_test.go Outdated Show resolved Hide resolved
arrow/example_test.go Outdated Show resolved Hide resolved
request_test.go Outdated Show resolved Hide resolved
arrow/arrow.go Show resolved Hide resolved
@oleg-jukovec
Copy link
Collaborator

Draft changes: add support the IPROTO_INSERT_ARROW request and message pack type MP_ARROW . Please, split the commit message into multiple lines. A commit message should contains lines with 72 chars max.

arrow/request.go Outdated Show resolved Hide resolved
Environment variable TARANTOOL_BIN can be used to
specify path of Tarantool executable.
@dmyger dmyger force-pushed the dmyger/gh-399-add-support-IPROTO_INSERT_ARROW branch from b6ad2cc to d7e9eab Compare October 8, 2024 14:19
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to see green tests first.

@dmyger dmyger force-pushed the dmyger/gh-399-add-support-IPROTO_INSERT_ARROW branch 2 times, most recently from b00104f to a994eb0 Compare October 9, 2024 09:57
Add support the IPROTO_INSERT_ARROW request and
message pack type MP_ARROW.

Closes #399
@dmyger dmyger force-pushed the dmyger/gh-399-add-support-IPROTO_INSERT_ARROW branch from a994eb0 to 53310a5 Compare October 9, 2024 10:04
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch. Just a few non-critical issues left.

Comment on lines +68 to +100
func TestEncodeArrow(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
enc := msgpack.NewEncoder(buf)

arr, err := arrow.MakeArrow(tt.arr)
require.NoError(t, err)

err = enc.Encode(arr)
require.NoError(t, err)

require.Equal(t, tt.enc, buf.Bytes())
})

}
}

func TestDecodeArrow(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

buf := bytes.NewBuffer(tt.enc)
dec := msgpack.NewDecoder(buf)

var arr arrow.Arrow
err := dec.Decode(&arr)
require.NoError(t, err)

require.Equal(t, tt.arr, arr.Raw())
})
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no negative scenarios here, only positive ones. Please, add cases with encoding (if possible)/decoding (should be possible) errors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename config.lua -> config-memtx.lua, config-ee.lua -> config-memcs.lua? Up to you.

Comment on lines +56 to +58
if len(resp) == 0 {
fmt.Printf("Batch arrow inserted")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So our intention is a little more clear.

Suggested change
if len(resp) == 0 {
fmt.Printf("Batch arrow inserted")
}
if len(resp) > 0 {
log.Fatalf("Unexpected response")
}
fmt.Printf("Batch arrow inserted")

Comment on lines +32 to +33
// NewInsertRequest returns a new empty InsertRequest.
func NewInsertRequest(space interface{}) *InsertRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will make using the request a little more useful. But we need to have the Arrow method as well.

Suggested change
// NewInsertRequest returns a new empty InsertRequest.
func NewInsertRequest(space interface{}) *InsertRequest {
// NewInsertRequest returns a new empty InsertRequest.
func NewInsertRequest(space interface{}, arrow Arrow) *InsertRequest {

request := arrow.NewInsertRequest(validSpace)
resp, err := request.Response(header, bytes.NewBuffer(buf.Bytes()))
require.NoError(t, err)
require.IsType(t, baseResponse, resp)
Copy link
Collaborator

@oleg-jukovec oleg-jukovec Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do without this (IsType) check. It tells too much of the internal implementation and will complicate refactoring in the future.

request := arrow.NewInsertRequest(validSpace)
resp, err := request.Response(header, bytes.NewBuffer(buf.Bytes()))
require.NoError(t, err)
require.IsType(t, baseResponse, resp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: add support of a batch insert request
2 participants