Skip to content

Commit

Permalink
[FIX] Fix bound errors in pipeline batching
Browse files Browse the repository at this point in the history
  • Loading branch information
captchanjack committed Aug 19, 2022
1 parent 71e558c commit d4c8566
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jedis"
uuid = "b89ccfe0-2c5f-46f6-b89b-da3e1c2e286f"
authors = ["Jack Chan <[email protected]>"]
version = "0.2.14"
version = "0.2.15"

[deps]
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
Expand Down
6 changes: 3 additions & 3 deletions src/execute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ function execute(pipe::Pipeline, batch_size::Int)

n_cmd = length(pipe.resp)
messages = Vector{Any}(undef, n_cmd)
l, r = 1, min(batch_size, n_cmd)
l, r = 1, batch_size

while l <= n_cmd
write(pipe.client.socket, join(pipe.resp[l:r]))
write(pipe.client.socket, join(pipe.resp[l:min(r, n_cmd)]))

for i in l:r
for i in l:min(r, n_cmd)
messages[i] = recv(pipe.client.socket)
end

Expand Down
12 changes: 10 additions & 2 deletions test/test_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ end
end

@testset "Pipeline - Batching" begin
batch_size = 100
result = pipeline(100) do pipe
batch_size = 333
result = pipeline(batch_size) do pipe
for _ in 1:1000
lrange("nothing", 0, -1; client=pipe)
end
end
@test result == fill([], 1000)

batch_size = 3333
result = pipeline(batch_size) do pipe
for _ in 1:1000
lrange("nothing", 0, -1; client=pipe)
end
Expand Down

2 comments on commit d4c8566

@captchanjack
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/66533

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.15 -m "<description of version>" d4c8566d3930ae05972184fa512f46ad20ff9896
git push origin v0.2.15

Please sign in to comment.