|
5 | 5 | "id": "2c822501cae3b91d", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Working with BatchStore\n", |
| 8 | + "# Working with BatchArray\n", |
9 | 9 | "\n", |
10 | | - "A `BatchStore` is a batch-oriented container for variable-length Python items backed by a single `SChunk`. Each batch is stored in one compressed chunk, and each chunk may contain one or more internal variable-length blocks.\n", |
| 10 | + "A `BatchArray` is a batch-oriented container for variable-length Python items backed by a single `SChunk`. Each batch is stored in one compressed chunk, and each chunk may contain one or more internal variable-length blocks.\n", |
11 | 11 | "\n", |
12 | | - "This makes `BatchStore` a good fit when data arrives naturally in batches and you want efficient batch append/update operations together with occasional item-level access inside each batch." |
| 12 | + "This makes `BatchArray` a good fit when data arrives naturally in batches and you want efficient batch append/update operations together with occasional item-level access inside each batch." |
13 | 13 | ] |
14 | 14 | }, |
15 | 15 | { |
|
37 | 37 | " print(f\"{label}: {value}\")\n", |
38 | 38 | "\n", |
39 | 39 | "\n", |
40 | | - "urlpath = \"batchstore_tutorial.b2b\"\n", |
41 | | - "copy_path = \"batchstore_tutorial_copy.b2b\"\n", |
| 40 | + "urlpath = \"batcharray_tutorial.b2b\"\n", |
| 41 | + "copy_path = \"batcharray_tutorial_copy.b2b\"\n", |
42 | 42 | "blosc2.remove_urlpath(urlpath)\n", |
43 | 43 | "blosc2.remove_urlpath(copy_path)" |
44 | 44 | ] |
|
48 | 48 | "id": "dda38c56e3e63ec1", |
49 | 49 | "metadata": {}, |
50 | 50 | "source": [ |
51 | | - "## Creating and populating a BatchStore\n", |
| 51 | + "## Creating and populating a BatchArray\n", |
52 | 52 | "\n", |
53 | | - "A `BatchStore` is indexed by batch. Batches can be appended one by one with `append()` or in bulk with `extend()`. Here we set a small `max_blocksize` just so the internal block structure is easy to observe in `.info`." |
| 53 | + "A `BatchArray` is indexed by batch. Batches can be appended one by one with `append()` or in bulk with `extend()`. Here we set a small `items_per_block` just so the internal block structure is easy to observe in `.info`." |
54 | 54 | ] |
55 | 55 | }, |
56 | 56 | { |
|
80 | 80 | } |
81 | 81 | ], |
82 | 82 | "source": [ |
83 | | - "store = blosc2.BatchStore(urlpath=urlpath, mode=\"w\", contiguous=True, max_blocksize=2)\n", |
| 83 | + "store = blosc2.BatchArray(urlpath=urlpath, mode=\"w\", contiguous=True, items_per_block=2)\n", |
84 | 84 | "store.append(\n", |
85 | 85 | " [\n", |
86 | 86 | " {\"name\": \"alpha\", \"count\": 1},\n", |
|
212 | 212 | "source": [ |
213 | 213 | "## Iteration and summary info\n", |
214 | 214 | "\n", |
215 | | - "Iterating a `BatchStore` yields batches. The `.info` summary reports both batch-level and internal block-level statistics." |
| 215 | + "Iterating a `BatchArray` yields batches. The `.info` summary reports both batch-level and internal block-level statistics." |
216 | 216 | ] |
217 | 217 | }, |
218 | 218 | { |
|
237 | 237 | "output_type": "stream", |
238 | 238 | "text": [ |
239 | 239 | "Batches via iteration: [[{'name': 'alpha*', 'count': 10}, {'name': 'beta*', 'count': 20}], [{'name': 'delta*', 'count': 40}, {'name': 'epsilon*', 'count': 50}], [{'name': 'between-a', 'count': 99}, {'name': 'between-b', 'count': 100}], [{'name': 'eta', 'count': 7}, {'name': 'theta', 'count': 8}], [{'name': 'iota', 'count': 9}, {'name': 'kappa', 'count': 10}, {'name': 'lambda', 'count': 11}]]\n", |
240 | | - "type : BatchStore\n", |
| 240 | + "type : BatchArray\n", |
241 | 241 | "serializer : msgpack\n", |
242 | 242 | "nbatches : 5 (items per batch: mean=2.20, max=3, min=2)\n", |
243 | 243 | "nblocks : 6 (items per block: mean=1.83, max=2, min=1)\n", |
|
267 | 267 | "source": [ |
268 | 268 | "## Copying and changing storage settings\n", |
269 | 269 | "\n", |
270 | | - "Like other Blosc2 containers, `BatchStore.copy()` can write a new persistent store while changing storage or compression settings." |
| 270 | + "Like other Blosc2 containers, `BatchArray.copy()` can write a new persistent store while changing storage or compression settings." |
271 | 271 | ] |
272 | 272 | }, |
273 | 273 | { |
|
316 | 316 | "source": [ |
317 | 317 | "## Round-tripping through cframes and reopening from disk\n", |
318 | 318 | "\n", |
319 | | - "Tagged persistent stores automatically reopen as `BatchStore`, and a serialized cframe buffer does too." |
| 319 | + "Tagged persistent stores automatically reopen as `BatchArray`, and a serialized cframe buffer does too." |
320 | 320 | ] |
321 | 321 | }, |
322 | 322 | { |
|
340 | 340 | "name": "stdout", |
341 | 341 | "output_type": "stream", |
342 | 342 | "text": [ |
343 | | - "from_cframe type: BatchStore\n", |
| 343 | + "from_cframe type: BatchArray\n", |
344 | 344 | "from_cframe batches: [[{'name': 'alpha*', 'count': 10}, {'name': 'beta*', 'count': 20}], [{'name': 'delta*', 'count': 40}, {'name': 'epsilon*', 'count': 50}], [{'name': 'between-a', 'count': 99}, {'name': 'between-b', 'count': 100}], [{'name': 'eta', 'count': 7}, {'name': 'theta', 'count': 8}], [{'name': 'iota', 'count': 9}, {'name': 'kappa', 'count': 10}, {'name': 'lambda', 'count': 11}]]\n", |
345 | | - "Reopened type: BatchStore\n", |
| 345 | + "Reopened type: BatchArray\n", |
346 | 346 | "Reopened batches: [[{'name': 'alpha*', 'count': 10}, {'name': 'beta*', 'count': 20}], [{'name': 'delta*', 'count': 40}, {'name': 'epsilon*', 'count': 50}], [{'name': 'between-a', 'count': 99}, {'name': 'between-b', 'count': 100}], [{'name': 'eta', 'count': 7}, {'name': 'theta', 'count': 8}], [{'name': 'iota', 'count': 9}, {'name': 'kappa', 'count': 10}, {'name': 'lambda', 'count': 11}]]\n" |
347 | 347 | ] |
348 | 348 | } |
|
412 | 412 | "source": [ |
413 | 413 | "## Flat item access with `.items`\n", |
414 | 414 | "\n", |
415 | | - "The main `BatchStore` API remains batch-oriented, but the `.items` accessor offers a read-only flat view across all items. Integer indexing returns one item and slicing returns a Python list." |
| 415 | + "The main `BatchArray` API remains batch-oriented, but the `.items` accessor offers a read-only flat view across all items. Integer indexing returns one item and slicing returns a Python list." |
416 | 416 | ] |
417 | 417 | }, |
418 | 418 | { |
|
0 commit comments