|
1 | | -Announcing Python-Blosc2 4.4.1 |
| 1 | +Announcing Python-Blosc2 4.4.2 |
2 | 2 | ============================== |
3 | 3 |
|
4 | | -We are happy to announce this feature release that brings an interactive |
5 | | -TUI data viewer, automatic SUMMARY indexes for fast WHERE queries, |
6 | | -chunk-aligned Arrow/Parquet imports, expanded ``where()`` acceleration, and a |
7 | | -range of CTable ergonomics and performance improvements. |
| 4 | +We are happy to announce this feature and maintenance release that promotes |
| 5 | +DSL kernels to first-class CTable computed columns, adds a convenient new |
| 6 | +column-assignment API, speeds up bulk NDArray writes, and fixes several |
| 7 | +correctness issues. |
8 | 8 |
|
9 | 9 | The main highlights are: |
10 | 10 |
|
11 | | -- **New ``b2view`` interactive viewer**: a terminal-based viewer for all blosc2 |
12 | | - containers (``NDArray``, ``CTable``, ``SChunk``, ``BatchArray``, …), launched |
13 | | - with ``b2view <file>`` or ``blosc2.b2view()``. Supports full 1-D/2-D/N-D |
14 | | - browsing, ``CTable`` row navigation, a vlmeta pane, and keyboard shortcuts. |
| 11 | +- **DSL kernels as first-class CTable columns**: ``@blosc2.jit``-decorated |
| 12 | + functions can now back virtual computed columns, stored generated columns, |
| 13 | + and ``where()`` filter predicates directly — in addition to the existing |
| 14 | + string-expression form. Columns survive save/open round-trips via |
| 15 | + persisted source. |
15 | 16 |
|
16 | | -- **Automatic SUMMARY indexes**: when a ``CTable`` is closed after writing, |
17 | | - SUMMARY indexes (per-block min/max) are built by default for all eligible |
18 | | - scalar columns. They are accumulated *incrementally* during writes so the |
19 | | - close step adds almost no extra cost. At query time, a block-skip prefilter |
20 | | - uses these bitmaps to skip blocks that cannot satisfy the WHERE predicate, |
21 | | - reducing decompression work for selective queries. |
| 17 | +- **New ``t["col"] = arr`` assignment**: a clean shorthand for overwriting all |
| 18 | + live rows of a column. Accepts any array-like, including ``blosc2.NDArray``. |
22 | 19 |
|
23 | | -- **Chunk-aligned Arrow/Parquet imports**: fixed-size columns are now written on |
24 | | - a shared chunk/block grid and incoming batches are buffered to exact chunk |
25 | | - boundaries, so every chunk is compressed exactly once. Dictionary columns are |
26 | | - imported in bulk. A new ``--reduce-mem`` CLI flag caps Arrow read-batch size |
27 | | - for memory-constrained nested imports. |
| 20 | +- **Chunked NDArray writes**: passing a ``blosc2.NDArray`` to ``extend()`` or |
| 21 | + ``col[:] = arr`` now decompresses one chunk at a time instead of loading |
| 22 | + the entire array into memory, keeping peak RSS bounded for large columns. |
28 | 23 |
|
29 | | -- **``where()`` and miniexpr acceleration**: single- and two-argument ``where`` |
30 | | - calls are now dispatched directly to miniexpr, avoiding numexpr overhead. |
31 | | - Sparse boolean masks trigger a fast gather path, and a new pre-check skips |
32 | | - per-chunk numexpr setup when the condition is trivially true or false. |
| 24 | +- **``BLOSC_ME_JIT`` full override**: the environment variable now takes |
| 25 | + unconditional priority over both ``jit=`` and ``jit_backend=`` keyword |
| 26 | + arguments, making backend switching from the command line effortless. |
33 | 27 |
|
34 | | -- **``CTable.copy()`` enhancements**: a new C-level bulk copy path |
35 | | - (``chunk_copy()``) transfers pre-compressed chunks without |
36 | | - serialization/recompression. ``copy()`` now accepts ``chunks``, ``blocks``, |
37 | | - and ``cparams`` overrides; the ``parquet-to-blosc2`` CLI gains ``--chunks`` |
38 | | - and ``--blocks`` flags. |
| 28 | +- **Correctness fixes**: a ``None == None`` guard bug that could corrupt rows |
| 29 | + when writing to a view-backed column via the NDArray fast path; a missing |
| 30 | + view guard in the new ``__setitem__``; and the fast path being silently |
| 31 | + disabled for disk-opened tables have all been fixed. |
39 | 32 |
|
40 | | -- **``sort_by()`` on views is now lazy**: sorting a filtered view returns a |
41 | | - position-reordered view whose columns are read in sorted order without a full |
42 | | - materialization pass. |
| 33 | +A quick example of the new DSL computed column API:: |
43 | 34 |
|
44 | | -- **``context manager`` support for ``blosc2.open()``**: all objects returned by |
45 | | - ``blosc2.open()`` now support the ``with`` statement for clean flush-and-close |
46 | | - semantics. |
47 | | - |
48 | | -- **``NestedColumn`` public class**: the dotted-column accessor is now a proper |
49 | | - public class with aggregate metadata (``nbytes``, ``cbytes``, ``cratio``) and |
50 | | - a structured ``.info`` report. |
51 | | - |
52 | | -- **Python 3.10 dropped**: Python 3.11 is now the minimum supported version. |
| 35 | + import blosc2 |
| 36 | + import dataclasses |
| 37 | + import numpy as np |
53 | 38 |
|
54 | | -A small example showing the new SUMMARY index benefit:: |
| 39 | + @dataclasses.dataclass |
| 40 | + class Row: |
| 41 | + price: float = blosc2.field(blosc2.float64()) |
| 42 | + qty: int = blosc2.field(blosc2.int64()) |
55 | 43 |
|
56 | | - import blosc2 |
| 44 | + @blosc2.dsl_kernel |
| 45 | + def revenue(price, qty): |
| 46 | + return price * qty |
57 | 47 |
|
58 | | - # Create a table and let SUMMARY indexes be built automatically on close |
59 | | - t = blosc2.CTable(Row, urlpath="my_table.b2d", mode="w") |
60 | | - t.extend(data) |
61 | | - t.close() # SUMMARY indexes built here |
| 48 | + t = blosc2.CTable(Row, new_data=[(1.5, 10), (2.0, 5), (3.0, 3)]) |
| 49 | + t.add_computed_column("revenue", revenue, inputs=["price", "qty"]) |
| 50 | + print(t["revenue"][:]) # array([15., 10., 9.]) |
62 | 51 |
|
63 | | - # Re-open and run a selective WHERE query — block skipping kicks in |
64 | | - t = blosc2.open("my_table.b2d") |
65 | | - result = t.where(t.value > 0.99) |
66 | | - print(result[:]) |
| 52 | + # Column assignment with a blosc2.NDArray — written chunk-by-chunk |
| 53 | + new_prices = blosc2.array([1.0, 2.5, 4.0]) |
| 54 | + t["price"] = new_prices |
67 | 55 |
|
68 | 56 | Install it with:: |
69 | 57 |
|
|
0 commit comments