|
| 1 | +b2view: Browse TreeStore Bundles in the Terminal |
| 2 | +================================================ |
| 3 | + |
| 4 | +The ``b2view`` CLI opens an interactive terminal browser (TUI) for Blosc2 |
| 5 | +TreeStore bundles, either sparse directories (``.b2d``) or compact |
| 6 | +zip-backed files (``.b2z``). It shows the tree of groups and nodes, the |
| 7 | +metadata and vlmeta of the selected node, and a paged view of the data |
| 8 | +itself — NDArrays of any dimensionality as well as CTables. |
| 9 | + |
| 10 | +``b2view`` is installed with python-blosc2; no extra dependencies are |
| 11 | +needed. |
| 12 | + |
| 13 | +Step 1 — Create a sample store |
| 14 | +------------------------------ |
| 15 | + |
| 16 | +Run the snippet below once to produce ``sample.b2z`` with a couple of |
| 17 | +arrays and some metadata: |
| 18 | + |
| 19 | +.. code-block:: python |
| 20 | +
|
| 21 | + import blosc2 |
| 22 | +
|
| 23 | + with blosc2.TreeStore("sample.b2z", mode="w") as tstore: |
| 24 | + tstore.vlmeta["author"] = "me" |
| 25 | + a = blosc2.linspace(0, 1, num=1_000_000, shape=(1000, 1000)) |
| 26 | + a.vlmeta["description"] = "a 2-D linspace" |
| 27 | + tstore["/dense/a"] = a |
| 28 | + tstore["/dense/b"] = blosc2.arange(10_000, shape=(10, 100, 10)) |
| 29 | +
|
| 30 | +Any existing TreeStore bundle works too — for instance the output of the |
| 31 | +``parquet-to-blosc2`` converter (see :doc:`parquet_to_blosc2`). |
| 32 | + |
| 33 | +Step 2 — Open it |
| 34 | +---------------- |
| 35 | + |
| 36 | +.. code-block:: console |
| 37 | +
|
| 38 | + b2view sample.b2z |
| 39 | +
|
| 40 | +The screen is split into four panels: the **tree** of the bundle on the |
| 41 | +left, and **meta**, **vlmeta** and **data** panels for the node selected |
| 42 | +in the tree. Move between panels with ``tab`` / ``shift+tab``, maximize |
| 43 | +the focused one with ``m`` (``r`` restores it), and quit with ``q``. |
| 44 | + |
| 45 | +You can also jump straight to a node and panel: |
| 46 | + |
| 47 | +.. code-block:: console |
| 48 | +
|
| 49 | + b2view sample.b2z /dense/a --panel data |
| 50 | +
|
| 51 | +Step 3 — Navigate the data panel |
| 52 | +-------------------------------- |
| 53 | + |
| 54 | +The data panel pages through objects far larger than the screen. Press |
| 55 | +``?`` at any time for the full key reference; the essentials are: |
| 56 | + |
| 57 | +================================ ============================================= |
| 58 | +Key Action |
| 59 | +================================ ============================================= |
| 60 | +``up`` / ``down`` move the cursor; pages at the edges |
| 61 | +``pageup`` / ``pagedown`` previous / next page of rows |
| 62 | +``t`` / ``b`` first / last row |
| 63 | +``g`` go to a row number |
| 64 | +``left`` / ``right`` move across columns; pages at the edges |
| 65 | +``s`` / ``e`` (``home``/``end``) first / last column window |
| 66 | +``c`` go to a column index or name |
| 67 | +================================ ============================================= |
| 68 | + |
| 69 | +For N-D arrays, press ``d`` to enter *dim mode*: ``left`` / ``right`` |
| 70 | +select the active dimension, ``up`` / ``down`` change its fixed index (or |
| 71 | +scroll the viewport), ``enter`` toggles a dimension between fixed and |
| 72 | +navigable, and ``escape`` leaves dim mode. |
| 73 | + |
| 74 | +CLI options |
| 75 | +----------- |
| 76 | + |
| 77 | +``--preview-rows N`` and ``--preview-cols N`` bound the size of each data |
| 78 | +page (20 rows by 10 columns by default), and ``--panel`` chooses the panel |
| 79 | +focused on startup (``tree``, ``meta``, ``vlmeta`` or ``data``). |
0 commit comments