-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add async iterator over bytes in result of
get
(#11)
* Add async iterator over bytes in result of `get` * Add synchronous iteration * Implement `aiter` and `iter` on `GetResult` * Chunk size * Add python test
- Loading branch information
1 parent
922b58f
commit c10f3fe
Showing
6 changed files
with
262 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import object_store_rs as obs | ||
import pytest | ||
from object_store_rs.store import MemoryStore | ||
|
||
|
||
def test_stream_sync(): | ||
store = MemoryStore() | ||
|
||
data = b"the quick brown fox jumps over the lazy dog," * 5000 | ||
path = "big-data.txt" | ||
|
||
obs.put_file(store, path, data) | ||
resp = obs.get(store, path) | ||
stream = resp.stream(min_chunk_size=0) | ||
|
||
# Note: it looks from manual testing that with the local store we're only getting | ||
# one chunk and not able to test the chunk sizing. | ||
pos = 0 | ||
for chunk in stream: | ||
size = len(chunk) | ||
assert chunk == data[pos : pos + size] | ||
pos += size | ||
|
||
assert pos == len(data) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_stream_async(): | ||
store = MemoryStore() | ||
|
||
data = b"the quick brown fox jumps over the lazy dog," * 5000 | ||
path = "big-data.txt" | ||
|
||
await obs.put_file_async(store, path, data) | ||
resp = await obs.get_async(store, path) | ||
stream = resp.stream(min_chunk_size=0) | ||
|
||
# Note: it looks from manual testing that with the local store we're only getting | ||
# one chunk and not able to test the chunk sizing. | ||
pos = 0 | ||
async for chunk in stream: | ||
size = len(chunk) | ||
assert chunk == data[pos : pos + size] | ||
pos += size | ||
|
||
assert pos == len(data) |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.