Skip to content

Commit e7ebe9f

Browse files
committed
Add the reference to VLArray in docs
1 parent adac9c6 commit e7ebe9f

2 files changed

Lines changed: 85 additions & 2 deletions

File tree

doc/reference/classes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Main Classes
1313
LazyArray
1414
C2Array
1515
Array
16+
BatchArray
17+
VLArray
1618
SChunk
1719
DictStore
1820
TreeStore
1921
EmbedStore
20-
BatchArray
21-
VLArray
2222
Ref
2323
Proxy
2424
ProxySource

doc/reference/vlarray.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. _VLArray:
2+
3+
VLArray
4+
=======
5+
6+
Overview
7+
--------
8+
VLArray is a variable-length array container backed by a single Blosc2 ``SChunk``.
9+
10+
Each entry is stored as one compressed chunk:
11+
12+
- entries can be any serializable Python object
13+
- items are serialized with msgpack before compression
14+
- Blosc2 containers (:class:`NDArray`, :class:`SChunk`, :class:`VLArray`,
15+
:class:`BatchArray`, :class:`EmbedStore`) are serialized transparently
16+
via :meth:`to_cframe` / :func:`blosc2.from_cframe`
17+
- structured Blosc2 reference objects (:class:`C2Array`, :class:`LazyExpr`,
18+
and :class:`LazyUDF` backed by :func:`blosc2.dsl_kernel`) are also supported
19+
20+
VLArray is a good fit when you need:
21+
22+
- a persistent, compressed list of arbitrary Python objects
23+
- per-item random access and mutation
24+
- compact summary information via ``.info``
25+
26+
Quick example
27+
-------------
28+
29+
.. code-block:: python
30+
31+
import blosc2
32+
33+
vl = blosc2.VLArray(urlpath="example.b2z", mode="w", contiguous=True)
34+
vl.append({"x": 1, "y": 2})
35+
vl.append([3, 4, 5])
36+
vl.append("hello")
37+
38+
print(vl[0]) # {'x': 1, 'y': 2}
39+
print(vl[1]) # [3, 4, 5]
40+
print(len(vl)) # 3
41+
42+
reopened = blosc2.open("example.b2z", mode="r")
43+
print(type(reopened).__name__)
44+
print(reopened.info)
45+
46+
.. currentmodule:: blosc2
47+
48+
.. autoclass:: VLArray
49+
50+
Constructors
51+
------------
52+
.. automethod:: __init__
53+
54+
Item Interface
55+
--------------
56+
.. automethod:: __getitem__
57+
.. automethod:: __setitem__
58+
.. automethod:: __delitem__
59+
.. automethod:: __len__
60+
.. automethod:: __iter__
61+
62+
Mutation
63+
--------
64+
.. automethod:: append
65+
.. automethod:: extend
66+
.. automethod:: insert
67+
.. automethod:: delete
68+
.. automethod:: pop
69+
.. automethod:: clear
70+
.. automethod:: copy
71+
72+
Context Manager
73+
---------------
74+
.. automethod:: __enter__
75+
.. automethod:: __exit__
76+
77+
Public Members
78+
--------------
79+
.. automethod:: to_cframe
80+
81+
Constructors
82+
------------
83+
.. autofunction:: blosc2.vlarray_from_cframe

0 commit comments

Comments
 (0)