Arrow Flight Client
TypeScript 7 Python 3 10 个 gRPC 方法 0.0.19
适用于 Node.js 的 Apache Arrow Flight 客户端。为官方 Flight 协议定义中的所有一元和流式 gRPC 方法提供类型化接口。
安装
在项目中安装客户端及其必需的对等依赖 apache-arrow。
Shell
npm install arrow-flight-client apache-arrow
读取表
启动本地 Flight 服务器。它提供描述符为 demo/people 的表。先调用 getFlightInfo() 获取表信息,再将返回的票据传给 getTable()。
client.ts
import { FlightClient, pathDescriptor } from 'arrow-flight-client';
const client = new FlightClient('127.0.0.1:8815');
try {
const info = await client.getFlightInfo(pathDescriptor('demo', 'people'));
const ticket = info.endpoints[0]?.ticket;
if (!ticket) {
throw new Error('The Flight endpoint has no ticket');
}
const table = await client.getTable(ticket);
console.log(table.toString());
}
finally {
await client.close();
}
使用以下命令运行示例。输出包含两行,名字分别为 Ada 和 Lin。
Shell
node client.ts