Skip to content

Commit 2b93a71

Browse files
Merge pull request #618 from Blosc/containers-tutorial
Containers tutorial
2 parents c4b00d9 + 07ba01e commit 2b93a71

23 files changed

Lines changed: 2277 additions & 591 deletions

doc/getting_started/tutorials.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ Tutorials
1717
tutorials/09.ucodecs-ufilters
1818
tutorials/10.prefilters
1919
tutorials/11.vlarray
20+
tutorials/12.batcharray
21+
tutorials/13.containers
2022
tutorials/14.indexing-arrays

doc/getting_started/tutorials/12.batchstore.ipynb renamed to doc/getting_started/tutorials/12.batcharray.ipynb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"id": "2c822501cae3b91d",
66
"metadata": {},
77
"source": [
8-
"# Working with BatchStore\n",
8+
"# Working with BatchArray\n",
99
"\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",
1111
"\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."
1313
]
1414
},
1515
{
@@ -37,8 +37,8 @@
3737
" print(f\"{label}: {value}\")\n",
3838
"\n",
3939
"\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",
4242
"blosc2.remove_urlpath(urlpath)\n",
4343
"blosc2.remove_urlpath(copy_path)"
4444
]
@@ -48,9 +48,9 @@
4848
"id": "dda38c56e3e63ec1",
4949
"metadata": {},
5050
"source": [
51-
"## Creating and populating a BatchStore\n",
51+
"## Creating and populating a BatchArray\n",
5252
"\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`."
5454
]
5555
},
5656
{
@@ -80,7 +80,7 @@
8080
}
8181
],
8282
"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",
8484
"store.append(\n",
8585
" [\n",
8686
" {\"name\": \"alpha\", \"count\": 1},\n",
@@ -212,7 +212,7 @@
212212
"source": [
213213
"## Iteration and summary info\n",
214214
"\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."
216216
]
217217
},
218218
{
@@ -237,7 +237,7 @@
237237
"output_type": "stream",
238238
"text": [
239239
"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",
241241
"serializer : msgpack\n",
242242
"nbatches : 5 (items per batch: mean=2.20, max=3, min=2)\n",
243243
"nblocks : 6 (items per block: mean=1.83, max=2, min=1)\n",
@@ -267,7 +267,7 @@
267267
"source": [
268268
"## Copying and changing storage settings\n",
269269
"\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."
271271
]
272272
},
273273
{
@@ -316,7 +316,7 @@
316316
"source": [
317317
"## Round-tripping through cframes and reopening from disk\n",
318318
"\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."
320320
]
321321
},
322322
{
@@ -340,9 +340,9 @@
340340
"name": "stdout",
341341
"output_type": "stream",
342342
"text": [
343-
"from_cframe type: BatchStore\n",
343+
"from_cframe type: BatchArray\n",
344344
"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",
346346
"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"
347347
]
348348
}
@@ -412,7 +412,7 @@
412412
"source": [
413413
"## Flat item access with `.items`\n",
414414
"\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."
416416
]
417417
},
418418
{

0 commit comments

Comments
 (0)