Skills2026年4月15日·1 分钟阅读

Apache Arrow — Columnar In-Memory Format and Compute Runtime

A cross-language columnar format, zero-copy IPC and compute library that has become the common data-plane for DuckDB, Polars, Pandas 2.x, Spark, Snowflake clients and most modern analytics tools.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Community
入口
Apache Arrow Guide
先审查命令
npx -y tokrepo@latest install 2ea0c9b8-3920-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

TL;DR
Apache Arrow is a cross-language columnar memory format powering DuckDB, Polars, and Pandas 2.x.
§01

What it is

Apache Arrow defines a language-independent columnar memory layout for flat and hierarchical data. It provides libraries in C++, Java, Rust, Go, Python, R, JavaScript, and C# that read, write, transport, and process data without serialization overhead.

Arrow has become the common data plane for modern analytics tools. DuckDB, Polars, Pandas 2.x, Spark, Snowflake clients, and most contemporary data tools use Arrow as their interchange format, turning data-copying silos into a cooperative ecosystem.

§02

How it saves time or tokens

Arrow eliminates serialization costs when moving data between tools. Without Arrow, transferring data from a Python process to a Spark job requires serializing to CSV or Parquet, writing to disk, and deserializing. With Arrow, data stays in memory in a shared format that both tools understand natively. Arrow Flight provides a gRPC-based protocol for moving Arrow batches over the network at near-memory speeds. The vectorized compute kernels (SIMD-accelerated filter, math, string, and aggregate operations) eliminate Python loops for data transformations.

§03

How to use

  1. Install PyArrow:
pip install 'pyarrow>=16'
  1. Build a table, compute, and write to Parquet:
import pyarrow as pa
import pyarrow.compute as pc
import pyarrow.parquet as pq

tbl = pa.table({'id': [1, 2, 3], 'price': [9.99, 19.5, 4.25]})
tbl = tbl.append_column('tax', pc.multiply(tbl['price'], 0.07))
tbl = tbl.filter(pc.greater(tbl['tax'], 0.5))
pq.write_table(tbl, '/tmp/orders.parquet')
  1. Use zero-copy integration with Pandas:
import pandas as pd
df = tbl.to_pandas()  # zero-copy where possible
arrow_tbl = pa.Table.from_pandas(df)
§04

Example

Using Arrow Flight to transfer data between services:

import pyarrow.flight as flight

# Client: connect and fetch data
client = flight.connect('grpc://data-service:8815')
info = client.get_flight_info(
    flight.FlightDescriptor.for_path('orders', '2026-04')
)
reader = client.do_get(info.endpoints[0].ticket)
table = reader.read_all()
print(f'Fetched {table.num_rows} rows in Arrow format')
# No serialization needed - data arrives as Arrow batches
§05

Related on TokRepo

§06

Common pitfalls

  • Assuming Arrow replaces Parquet. Arrow is an in-memory format; Parquet is a storage format. Use Arrow for computation and Parquet for persistence. They are complementary.
  • Not using Arrow's compute kernels and falling back to Python loops defeats the performance benefit. Use pyarrow.compute for filtering, math, and string operations.
  • Mixing Arrow versions across tools in the same pipeline can cause compatibility issues. Pin to the same major version of PyArrow across your data stack.

常见问题

What is the difference between Arrow and Parquet?+

Arrow is an in-memory columnar format optimized for computation (random access, vectorized operations). Parquet is an on-disk columnar format optimized for storage (compression, encoding). Arrow reads and writes Parquet files natively.

Which tools use Apache Arrow?+

DuckDB, Polars, Pandas 2.x, Apache Spark, Snowflake clients, InfluxDB 3, DataFusion, Ballista, and most modern analytics tools use Arrow as their data interchange format.

What is Arrow Flight?+

Arrow Flight is a gRPC-based protocol for high-throughput data transfer using Arrow batches. It avoids serialization overhead by sending data in Arrow's native format over the network, achieving near-memory-speed transfers.

Does Arrow support nested data types?+

Yes. Arrow supports structs, lists, maps, unions, and arbitrarily nested combinations. Nested types compose by reference with separate validity bitmaps, maintaining the columnar layout.

What programming languages does Arrow support?+

Arrow has official implementations in C++, Java, Rust, Go, Python (via PyArrow), R, JavaScript, and C#. All implementations share the same in-memory format bit-for-bit.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产