@useairfoil/flight 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-Bp6m_JJh.js +13 -0
- package/dist/{src/index.d.ts → index.d.ts} +96 -67
- package/dist/{src/index.js → index.js} +113 -101
- package/dist/index.js.map +1 -0
- package/dist/proto/Flight.proto +4 -11
- package/package.json +20 -33
- package/src/arrow-flight-client.ts +168 -0
- package/src/arrow-flight-sql-client.ts +147 -0
- package/src/arrow-utils.ts +5 -4
- package/src/flight-client-error.ts +27 -0
- package/src/flight-data-encoder.ts +5 -13
- package/src/index.ts +12 -8
- package/src/proto/google/protobuf/descriptor.ts +12 -1
- package/src/proto/google/protobuf/timestamp.ts +7 -6
- package/src/proto-utils.ts +1 -5
- package/src/record-batch-decoder.ts +32 -66
- package/src/record-batch-with-metadata.ts +6 -0
- package/dist/src/index.js.map +0 -1
- package/dist/test/index.d.ts +0 -30
- package/dist/test/index.js +0 -80
- package/dist/test/index.js.map +0 -1
- package/src/arrow-flight-sql.ts +0 -121
- package/src/arrow-flight.ts +0 -149
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (all) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
return target;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __export as t };
|
|
@@ -1,10 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { RecordBatch, Schema } from "apache-arrow";
|
|
1
|
+
import { Config, Context, Effect, Layer, Scope, Stream } from "effect";
|
|
2
|
+
import { CallOptions, CallOptions as CallOptions$1, Channel, ChannelCredentials, ChannelOptions, CompatServiceDefinition, DefaultCallOptions, NormalizedServiceDefinition } from "nice-grpc";
|
|
3
|
+
import { RecordBatch, RecordBatch as RecordBatch$1, Schema, TypeMap } from "apache-arrow";
|
|
4
4
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
5
|
+
import * as effect_Types0 from "effect/Types";
|
|
6
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
5
7
|
|
|
8
|
+
//#region src/record-batch-with-metadata.d.ts
|
|
9
|
+
type RecordBatchWithMetadata<T extends TypeMap = any> = {
|
|
10
|
+
readonly batch: RecordBatch<T>;
|
|
11
|
+
readonly appMetadata: Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
declare namespace flight_client_error_d_exports {
|
|
14
|
+
export { FlightClientError, FlightClientErrorLike, FlightDecodeError, FlightProtocolError, FlightTransportError };
|
|
15
|
+
}
|
|
16
|
+
declare const FlightClientError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
|
|
17
|
+
readonly _tag: "FlightClientError";
|
|
18
|
+
} & Readonly<A>;
|
|
19
|
+
declare class FlightClientError extends FlightClientError_base<{
|
|
20
|
+
readonly message: string;
|
|
21
|
+
readonly cause?: unknown;
|
|
22
|
+
}> {}
|
|
23
|
+
declare const FlightTransportError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
|
|
24
|
+
readonly _tag: "FlightTransportError";
|
|
25
|
+
} & Readonly<A>;
|
|
26
|
+
declare class FlightTransportError extends FlightTransportError_base<{
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly cause?: unknown;
|
|
29
|
+
}> {}
|
|
30
|
+
declare const FlightDecodeError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
|
|
31
|
+
readonly _tag: "FlightDecodeError";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
declare class FlightDecodeError extends FlightDecodeError_base<{
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly cause?: unknown;
|
|
36
|
+
}> {}
|
|
37
|
+
declare const FlightProtocolError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
|
|
38
|
+
readonly _tag: "FlightProtocolError";
|
|
39
|
+
} & Readonly<A>;
|
|
40
|
+
declare class FlightProtocolError extends FlightProtocolError_base<{
|
|
41
|
+
readonly message: string;
|
|
42
|
+
readonly cause?: unknown;
|
|
43
|
+
}> {}
|
|
44
|
+
type FlightClientErrorLike = FlightClientError | FlightTransportError | FlightDecodeError | FlightProtocolError;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/proto-utils.d.ts
|
|
47
|
+
type RemoveTypeUrl<T> = Omit<T, "$type">;
|
|
48
|
+
type ClientOptions<S extends CompatServiceDefinition> = {
|
|
49
|
+
defaultCallOptions?: DefaultCallOptions<NormalizedServiceDefinition<S>>;
|
|
50
|
+
};
|
|
51
|
+
type HostOrChannel = {
|
|
52
|
+
host: string;
|
|
53
|
+
credentials?: ChannelCredentials;
|
|
54
|
+
channelOptions?: ChannelOptions;
|
|
55
|
+
channel?: never;
|
|
56
|
+
} | {
|
|
57
|
+
host?: never;
|
|
58
|
+
channel: Channel;
|
|
59
|
+
};
|
|
60
|
+
declare function createChannelFromConfig(config: HostOrChannel): Channel;
|
|
61
|
+
//#endregion
|
|
6
62
|
//#region src/proto/Flight.d.ts
|
|
7
|
-
|
|
8
63
|
/** The request that a client provides to a server on handshake. */
|
|
9
64
|
interface HandshakeRequest {
|
|
10
65
|
$type: "arrow.flight.protocol.HandshakeRequest";
|
|
@@ -478,7 +533,7 @@ type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<inf
|
|
|
478
533
|
readonly $case: T["$case"];
|
|
479
534
|
} : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial$1<T[K]> } : Partial<T>;
|
|
480
535
|
type KeysOfUnion$1<T> = T extends T ? keyof T : never;
|
|
481
|
-
type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & { [K in keyof P]: Exact$1<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion$1<P> | "$type">]: never };
|
|
536
|
+
type Exact$1<P$1, I extends P$1> = P$1 extends Builtin$1 ? P$1 : P$1 & { [K in keyof P$1]: Exact$1<P$1[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion$1<P$1> | "$type">]: never };
|
|
482
537
|
interface MessageFns$1<T, V extends string> {
|
|
483
538
|
readonly $type: V;
|
|
484
539
|
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
@@ -488,57 +543,26 @@ interface MessageFns$1<T, V extends string> {
|
|
|
488
543
|
create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
|
|
489
544
|
fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
|
|
490
545
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
type
|
|
495
|
-
defaultCallOptions?: DefaultCallOptions<NormalizedServiceDefinition<
|
|
496
|
-
};
|
|
497
|
-
type HostOrChannel = {
|
|
498
|
-
host: string;
|
|
499
|
-
credentials?: ChannelCredentials;
|
|
500
|
-
channelOptions?: ChannelOptions;
|
|
501
|
-
channel?: never;
|
|
502
|
-
} | {
|
|
503
|
-
host?: never;
|
|
504
|
-
channel: Channel;
|
|
546
|
+
declare namespace arrow_flight_client_d_exports {
|
|
547
|
+
export { ArrowFlightClient, ArrowFlightClientOptions, ArrowFlightClientService, CallOptions$1 as CallOptions, ClientOptions, HostOrChannel, RecordBatch$1 as RecordBatch, RecordBatchWithMetadata, layer$1 as layer, layerConfig$1 as layerConfig, make$1 as make };
|
|
548
|
+
}
|
|
549
|
+
type ArrowFlightClientOptions = HostOrChannel & {
|
|
550
|
+
readonly defaultCallOptions?: DefaultCallOptions<NormalizedServiceDefinition<FlightServiceDefinition>>;
|
|
505
551
|
};
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
* Handshake between client and server.
|
|
515
|
-
*
|
|
516
|
-
* Depending on the server, the handshake may be required to determine the
|
|
517
|
-
* token that should be used for future operations. Both request and response
|
|
518
|
-
* are streams to allow multiple round-trips depending on auth mechanism.
|
|
519
|
-
*/
|
|
520
|
-
handshake(request: AsyncIterable<HandshakeRequest>, options?: CallOptions): AsyncIterable<HandshakeResponse>;
|
|
521
|
-
/** Get a list of available streams given a particular criteria. */
|
|
522
|
-
getFlightInfo(request: FlightDescriptor, options?: CallOptions): Promise<FlightInfo>;
|
|
523
|
-
/**
|
|
524
|
-
* Retrieve a single stream associated with a particular descriptor
|
|
525
|
-
* associated with the referenced ticket. A Flight can be composed of one or
|
|
526
|
-
* more streams where each stream can be retrieved using a separate opaque
|
|
527
|
-
* ticket that the flight service uses for managing a collection of streams.
|
|
528
|
-
*/
|
|
529
|
-
doGet(request: Ticket, options: {
|
|
530
|
-
schema: Schema;
|
|
531
|
-
} & CallOptions): AsyncIterable<RecordBatch>;
|
|
532
|
-
/**
|
|
533
|
-
* Push a stream to the flight service associated with a particular
|
|
534
|
-
* flight stream. This allows a client of a flight service to upload a stream
|
|
535
|
-
* of data. Depending on the particular flight service, a client consumer
|
|
536
|
-
* could be allowed to upload a single stream per descriptor or an unlimited
|
|
537
|
-
* number. In the latter, the service might implement a 'seal' action that
|
|
538
|
-
* can be applied to a descriptor once all streams are uploaded.
|
|
539
|
-
*/
|
|
540
|
-
doPut(request: AsyncIterable<FlightData>, options?: CallOptions): AsyncIterable<PutResult>;
|
|
552
|
+
interface ArrowFlightClientService {
|
|
553
|
+
readonly handshake: (request: AsyncIterable<HandshakeRequest>, options?: CallOptions$1) => Stream.Stream<HandshakeResponse, FlightClientErrorLike>;
|
|
554
|
+
readonly getFlightInfo: (request: FlightDescriptor, options?: CallOptions$1) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
555
|
+
readonly doGet: (request: Ticket, options: {
|
|
556
|
+
readonly schema: Schema;
|
|
557
|
+
} & CallOptions$1) => Stream.Stream<RecordBatchWithMetadata, FlightClientErrorLike>;
|
|
558
|
+
readonly doPut: (request: AsyncIterable<FlightData>, options?: CallOptions$1) => AsyncIterable<PutResult>;
|
|
559
|
+
readonly executeFlightInfo: (info: FlightInfo, options?: CallOptions$1) => Stream.Stream<RecordBatchWithMetadata, FlightClientErrorLike>;
|
|
541
560
|
}
|
|
561
|
+
declare const ArrowFlightClient_base: Context.ServiceClass<ArrowFlightClient, "@useairfoil/flight/ArrowFlightClient", ArrowFlightClientService>;
|
|
562
|
+
declare class ArrowFlightClient extends ArrowFlightClient_base {}
|
|
563
|
+
declare const make$1: (options: ArrowFlightClientOptions) => Effect.Effect<ArrowFlightClientService, never, Scope.Scope>;
|
|
564
|
+
declare const layer$1: (options: ArrowFlightClientOptions) => Layer.Layer<ArrowFlightClient>;
|
|
565
|
+
declare const layerConfig$1: (options: Config.Wrap<ArrowFlightClientOptions>) => Layer.Layer<ArrowFlightClient, Config.ConfigError, never>;
|
|
542
566
|
//#endregion
|
|
543
567
|
//#region src/proto/FlightSql.d.ts
|
|
544
568
|
|
|
@@ -703,7 +727,7 @@ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U
|
|
|
703
727
|
readonly $case: T["$case"];
|
|
704
728
|
} : T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> } : Partial<T>;
|
|
705
729
|
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
706
|
-
type Exact<P, I extends P> = P extends Builtin ? P : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P> | "$type">]: never };
|
|
730
|
+
type Exact<P$1, I extends P$1> = P$1 extends Builtin ? P$1 : P$1 & { [K in keyof P$1]: Exact<P$1[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P$1> | "$type">]: never };
|
|
707
731
|
interface MessageFns<T, V extends string> {
|
|
708
732
|
readonly $type: V;
|
|
709
733
|
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
@@ -713,18 +737,23 @@ interface MessageFns<T, V extends string> {
|
|
|
713
737
|
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
714
738
|
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
715
739
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
executeFlightInfo(
|
|
722
|
-
getCatalogs(request: RemoveTypeUrl<CommandGetCatalogs>, options?: CallOptions)
|
|
723
|
-
getDbSchemas(request: RemoveTypeUrl<CommandGetDbSchemas>, options?: CallOptions)
|
|
724
|
-
getTables(request: RemoveTypeUrl<CommandGetTables>, options?: CallOptions)
|
|
725
|
-
getTableTypes(request: RemoveTypeUrl<CommandGetTableTypes>, options?: CallOptions)
|
|
726
|
-
executeQuery(request: RemoveTypeUrl<CommandStatementQuery>, options?: CallOptions)
|
|
740
|
+
declare namespace arrow_flight_sql_client_d_exports {
|
|
741
|
+
export { ArrowFlightSqlClient, ArrowFlightSqlClientOptions, ArrowFlightSqlClientService, CallOptions, FlightInfo, RecordBatchWithMetadata, layer, layerConfig, make };
|
|
742
|
+
}
|
|
743
|
+
type ArrowFlightSqlClientOptions = ArrowFlightClientOptions;
|
|
744
|
+
interface ArrowFlightSqlClientService {
|
|
745
|
+
readonly executeFlightInfo: (info: FlightInfo, options?: CallOptions) => Stream.Stream<RecordBatchWithMetadata, FlightClientErrorLike>;
|
|
746
|
+
readonly getCatalogs: (request: RemoveTypeUrl<CommandGetCatalogs>, options?: CallOptions) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
747
|
+
readonly getDbSchemas: (request: RemoveTypeUrl<CommandGetDbSchemas>, options?: CallOptions) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
748
|
+
readonly getTables: (request: RemoveTypeUrl<CommandGetTables>, options?: CallOptions) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
749
|
+
readonly getTableTypes: (request: RemoveTypeUrl<CommandGetTableTypes>, options?: CallOptions) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
750
|
+
readonly executeQuery: (request: RemoveTypeUrl<CommandStatementQuery>, options?: CallOptions) => Effect.Effect<FlightInfo, FlightClientErrorLike>;
|
|
727
751
|
}
|
|
752
|
+
declare const ArrowFlightSqlClient_base: Context.ServiceClass<ArrowFlightSqlClient, "@useairfoil/flight/ArrowFlightSqlClient", ArrowFlightSqlClientService>;
|
|
753
|
+
declare class ArrowFlightSqlClient extends ArrowFlightSqlClient_base {}
|
|
754
|
+
declare const make: (options: ArrowFlightClientOptions) => Effect.Effect<ArrowFlightSqlClientService, never, Scope.Scope>;
|
|
755
|
+
declare const layer: (options: ArrowFlightSqlClientOptions) => Layer.Layer<ArrowFlightSqlClient>;
|
|
756
|
+
declare const layerConfig: (options: Config.Wrap<ArrowFlightSqlClientOptions>) => Layer.Layer<ArrowFlightSqlClient, Config.ConfigError, never>;
|
|
728
757
|
//#endregion
|
|
729
758
|
//#region src/flight-data-encoder.d.ts
|
|
730
759
|
declare const FlightDataEncoder: {
|
|
@@ -745,5 +774,5 @@ declare const FlightDataEncoder: {
|
|
|
745
774
|
}): ReadonlyArray<FlightData>;
|
|
746
775
|
};
|
|
747
776
|
//#endregion
|
|
748
|
-
export { ArrowFlightClient, ArrowFlightSqlClient, type ClientOptions, FlightData, FlightDataEncoder, FlightDescriptor, FlightDescriptor_DescriptorType, type
|
|
777
|
+
export { arrow_flight_client_d_exports as ArrowFlightClient, type ArrowFlightClientOptions, type ArrowFlightClientService, arrow_flight_sql_client_d_exports as ArrowFlightSqlClient, type ArrowFlightSqlClientOptions, type ArrowFlightSqlClientService, type ClientOptions, flight_client_error_d_exports as FlightClientError, type FlightClientErrorLike, FlightData, FlightDataEncoder, FlightDescriptor, FlightDescriptor_DescriptorType, type FlightInfo, type HostOrChannel, PutResult, type RecordBatchWithMetadata, Ticket, createChannelFromConfig };
|
|
749
778
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __export } from "./chunk-Bp6m_JJh.js";
|
|
2
|
+
import { Config, Context, Data, Effect, Layer, Scope, Stream } from "effect";
|
|
3
|
+
import { createChannel, createClient } from "nice-grpc";
|
|
2
4
|
import { Message, MessageHeader, RecordBatch, Struct, Vector, compressionRegistry, makeData } from "apache-arrow";
|
|
3
5
|
import { ITERATOR_DONE } from "apache-arrow/io/interfaces";
|
|
4
6
|
import { COMPRESS_LENGTH_PREFIX, LENGTH_NO_COMPRESSED_DATA } from "apache-arrow/ipc/compression/constants";
|
|
@@ -132,7 +134,10 @@ var RecordBatchStreamReaderFromFlightData = class extends RecordBatchReaderImpl
|
|
|
132
134
|
const header = message.header();
|
|
133
135
|
return {
|
|
134
136
|
done: false,
|
|
135
|
-
value:
|
|
137
|
+
value: {
|
|
138
|
+
batch: this._loadRecordBatch(header, flight.dataBody),
|
|
139
|
+
appMetadata: flight.appMetadata
|
|
140
|
+
}
|
|
136
141
|
};
|
|
137
142
|
} else if (message.isDictionaryBatch()) {
|
|
138
143
|
this._dictionaryIndex++;
|
|
@@ -145,7 +150,10 @@ var RecordBatchStreamReaderFromFlightData = class extends RecordBatchReaderImpl
|
|
|
145
150
|
this._recordBatchIndex++;
|
|
146
151
|
return {
|
|
147
152
|
done: false,
|
|
148
|
-
value:
|
|
153
|
+
value: {
|
|
154
|
+
batch: new _InternalEmptyPlaceholderRecordBatch(this.schema),
|
|
155
|
+
appMetadata: new Uint8Array(0)
|
|
156
|
+
}
|
|
149
157
|
};
|
|
150
158
|
}
|
|
151
159
|
return ITERATOR_DONE;
|
|
@@ -174,6 +182,26 @@ function decodeFlightDataStream(stream, { expectedSchema: _expectedSchema }) {
|
|
|
174
182
|
return new RecordBatchStreamReaderFromFlightData(stream);
|
|
175
183
|
}
|
|
176
184
|
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/flight-client-error.ts
|
|
187
|
+
var flight_client_error_exports = /* @__PURE__ */ __export({
|
|
188
|
+
FlightClientError: () => FlightClientError,
|
|
189
|
+
FlightDecodeError: () => FlightDecodeError,
|
|
190
|
+
FlightProtocolError: () => FlightProtocolError,
|
|
191
|
+
FlightTransportError: () => FlightTransportError
|
|
192
|
+
});
|
|
193
|
+
var FlightClientError = class extends Data.TaggedError("FlightClientError") {};
|
|
194
|
+
var FlightTransportError = class extends Data.TaggedError("FlightTransportError") {};
|
|
195
|
+
var FlightDecodeError = class extends Data.TaggedError("FlightDecodeError") {};
|
|
196
|
+
var FlightProtocolError = class extends Data.TaggedError("FlightProtocolError") {};
|
|
197
|
+
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/proto-utils.ts
|
|
200
|
+
function createChannelFromConfig(config) {
|
|
201
|
+
if (config.host !== void 0) return createChannel(config.host, config.credentials, config.channelOptions);
|
|
202
|
+
return config.channel;
|
|
203
|
+
}
|
|
204
|
+
|
|
177
205
|
//#endregion
|
|
178
206
|
//#region src/proto/typeRegistry.ts
|
|
179
207
|
const messageTypeRegistry = /* @__PURE__ */ new Map();
|
|
@@ -1661,69 +1689,60 @@ function isSet$2(value) {
|
|
|
1661
1689
|
}
|
|
1662
1690
|
|
|
1663
1691
|
//#endregion
|
|
1664
|
-
//#region src/
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1692
|
+
//#region src/arrow-flight-client.ts
|
|
1693
|
+
var arrow_flight_client_exports = /* @__PURE__ */ __export({
|
|
1694
|
+
ArrowFlightClient: () => ArrowFlightClient,
|
|
1695
|
+
layer: () => layer$1,
|
|
1696
|
+
layerConfig: () => layerConfig$1,
|
|
1697
|
+
make: () => make
|
|
1698
|
+
});
|
|
1699
|
+
var ArrowFlightClient = class extends Context.Service()("@useairfoil/flight/ArrowFlightClient") {};
|
|
1700
|
+
const mapTransportError = (message, cause) => new FlightTransportError({
|
|
1701
|
+
message,
|
|
1702
|
+
cause
|
|
1703
|
+
});
|
|
1704
|
+
const mapDecodeError = (message, cause) => new FlightDecodeError({
|
|
1705
|
+
message,
|
|
1706
|
+
cause
|
|
1707
|
+
});
|
|
1708
|
+
const streamFromAsyncIterable = (iterable, message) => Stream.fromAsyncIterable(iterable, (cause) => mapTransportError(message, cause));
|
|
1709
|
+
const make = Effect.fnUntraced(function* (options) {
|
|
1710
|
+
const ownsChannel = "host" in options;
|
|
1711
|
+
const channel = createChannelFromConfig(options);
|
|
1712
|
+
const client = createClient(FlightServiceDefinition, channel, options.defaultCallOptions);
|
|
1713
|
+
if (ownsChannel) {
|
|
1714
|
+
const scope = yield* Scope.Scope;
|
|
1715
|
+
yield* Scope.addFinalizer(scope, Effect.sync(() => {
|
|
1716
|
+
channel.close();
|
|
1717
|
+
}));
|
|
1676
1718
|
}
|
|
1677
|
-
|
|
1719
|
+
const doGet = (request, options$1) => {
|
|
1720
|
+
const { schema: expectedSchema } = options$1;
|
|
1721
|
+
return Stream.fromAsyncIterable(decodeFlightDataStream(client.doGet(request, options$1), { expectedSchema }), (cause) => mapDecodeError("Flight batch decoding failed", cause));
|
|
1722
|
+
};
|
|
1723
|
+
const executeFlightInfo = (info, options$1) => {
|
|
1678
1724
|
const schema = decodeSchemaFromFlightInfo(info);
|
|
1679
|
-
if (!schema)
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
}
|
|
1701
|
-
/** Get a list of available streams given a particular criteria. */
|
|
1702
|
-
getFlightInfo(request, options) {
|
|
1703
|
-
return this.client.getFlightInfo(request, options);
|
|
1704
|
-
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Retrieve a single stream associated with a particular descriptor
|
|
1707
|
-
* associated with the referenced ticket. A Flight can be composed of one or
|
|
1708
|
-
* more streams where each stream can be retrieved using a separate opaque
|
|
1709
|
-
* ticket that the flight service uses for managing a collection of streams.
|
|
1710
|
-
*/
|
|
1711
|
-
doGet(request, options) {
|
|
1712
|
-
const { schema: expectedSchema } = options;
|
|
1713
|
-
return decodeFlightDataStream(this.client.doGet(request, options), { expectedSchema });
|
|
1714
|
-
}
|
|
1715
|
-
/**
|
|
1716
|
-
* Push a stream to the flight service associated with a particular
|
|
1717
|
-
* flight stream. This allows a client of a flight service to upload a stream
|
|
1718
|
-
* of data. Depending on the particular flight service, a client consumer
|
|
1719
|
-
* could be allowed to upload a single stream per descriptor or an unlimited
|
|
1720
|
-
* number. In the latter, the service might implement a 'seal' action that
|
|
1721
|
-
* can be applied to a descriptor once all streams are uploaded.
|
|
1722
|
-
*/
|
|
1723
|
-
doPut(request, options) {
|
|
1724
|
-
return this.client.doPut(request, options);
|
|
1725
|
-
}
|
|
1726
|
-
};
|
|
1725
|
+
if (!schema) return Stream.fail(new FlightProtocolError({ message: "FlightInfo must include a schema" }));
|
|
1726
|
+
return Stream.fromIterable(info.endpoint).pipe(Stream.flatMap((endpoint) => endpoint.ticket === void 0 ? Stream.empty : doGet(endpoint.ticket, {
|
|
1727
|
+
schema,
|
|
1728
|
+
...options$1
|
|
1729
|
+
})));
|
|
1730
|
+
};
|
|
1731
|
+
return ArrowFlightClient.of({
|
|
1732
|
+
handshake: (request, options$1) => streamFromAsyncIterable(client.handshake(request, options$1), "Flight handshake failed"),
|
|
1733
|
+
getFlightInfo: (request, options$1) => Effect.tryPromise({
|
|
1734
|
+
try: () => client.getFlightInfo(request, options$1),
|
|
1735
|
+
catch: (cause) => mapTransportError("Flight getFlightInfo failed", cause)
|
|
1736
|
+
}),
|
|
1737
|
+
doGet,
|
|
1738
|
+
doPut: (request, options$1) => client.doPut(request, options$1),
|
|
1739
|
+
executeFlightInfo
|
|
1740
|
+
});
|
|
1741
|
+
});
|
|
1742
|
+
const layer$1 = (options) => Layer.effect(ArrowFlightClient, make(options));
|
|
1743
|
+
const layerConfig$1 = (options) => Layer.effect(ArrowFlightClient, Effect.gen(function* () {
|
|
1744
|
+
return yield* make(yield* Config.unwrap(options));
|
|
1745
|
+
}));
|
|
1727
1746
|
|
|
1728
1747
|
//#endregion
|
|
1729
1748
|
//#region src/proto/any.ts
|
|
@@ -4022,51 +4041,44 @@ function isSet(value) {
|
|
|
4022
4041
|
}
|
|
4023
4042
|
|
|
4024
4043
|
//#endregion
|
|
4025
|
-
//#region src/arrow-flight-sql.ts
|
|
4026
|
-
var
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4044
|
+
//#region src/arrow-flight-sql-client.ts
|
|
4045
|
+
var arrow_flight_sql_client_exports = /* @__PURE__ */ __export({
|
|
4046
|
+
ArrowFlightSqlClient: () => ArrowFlightSqlClient,
|
|
4047
|
+
layer: () => layer,
|
|
4048
|
+
layerConfig: () => layerConfig,
|
|
4049
|
+
make: () => make$1
|
|
4050
|
+
});
|
|
4051
|
+
var ArrowFlightSqlClient = class extends Context.Service()("@useairfoil/flight/ArrowFlightSqlClient") {};
|
|
4052
|
+
const make$1 = Effect.fnUntraced(function* (options) {
|
|
4053
|
+
const inner = yield* make(options);
|
|
4054
|
+
return ArrowFlightSqlClient.of({
|
|
4055
|
+
executeFlightInfo: (info, options$1) => inner.executeFlightInfo(info, options$1),
|
|
4056
|
+
getCatalogs: (request, options$1) => inner.getFlightInfo(createCommandDescriptor(CommandGetCatalogs.$type, CommandGetCatalogs.encode({
|
|
4036
4057
|
$type: CommandGetCatalogs.$type,
|
|
4037
4058
|
...request
|
|
4038
|
-
}).finish())
|
|
4039
|
-
|
|
4040
|
-
}
|
|
4041
|
-
async getDbSchemas(request, options) {
|
|
4042
|
-
const descriptor = createCommandDescriptor(CommandGetDbSchemas.$type, CommandGetDbSchemas.encode({
|
|
4059
|
+
}).finish()), options$1),
|
|
4060
|
+
getDbSchemas: (request, options$1) => inner.getFlightInfo(createCommandDescriptor(CommandGetDbSchemas.$type, CommandGetDbSchemas.encode({
|
|
4043
4061
|
$type: CommandGetDbSchemas.$type,
|
|
4044
4062
|
...request
|
|
4045
|
-
}).finish())
|
|
4046
|
-
|
|
4047
|
-
}
|
|
4048
|
-
async getTables(request, options) {
|
|
4049
|
-
const descriptor = createCommandDescriptor(CommandGetTables.$type, CommandGetTables.encode({
|
|
4063
|
+
}).finish()), options$1),
|
|
4064
|
+
getTables: (request, options$1) => inner.getFlightInfo(createCommandDescriptor(CommandGetTables.$type, CommandGetTables.encode({
|
|
4050
4065
|
$type: CommandGetTables.$type,
|
|
4051
4066
|
...request
|
|
4052
|
-
}).finish())
|
|
4053
|
-
|
|
4054
|
-
}
|
|
4055
|
-
async getTableTypes(request, options) {
|
|
4056
|
-
const descriptor = createCommandDescriptor(CommandGetTableTypes.$type, CommandGetTableTypes.encode({
|
|
4067
|
+
}).finish()), options$1),
|
|
4068
|
+
getTableTypes: (request, options$1) => inner.getFlightInfo(createCommandDescriptor(CommandGetTableTypes.$type, CommandGetTableTypes.encode({
|
|
4057
4069
|
$type: CommandGetTableTypes.$type,
|
|
4058
4070
|
...request
|
|
4059
|
-
}).finish())
|
|
4060
|
-
|
|
4061
|
-
}
|
|
4062
|
-
async executeQuery(request, options) {
|
|
4063
|
-
const descriptor = createCommandDescriptor(CommandStatementQuery.$type, CommandStatementQuery.encode({
|
|
4071
|
+
}).finish()), options$1),
|
|
4072
|
+
executeQuery: (request, options$1) => inner.getFlightInfo(createCommandDescriptor(CommandStatementQuery.$type, CommandStatementQuery.encode({
|
|
4064
4073
|
$type: CommandStatementQuery.$type,
|
|
4065
4074
|
...request
|
|
4066
|
-
}).finish())
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4075
|
+
}).finish()), options$1)
|
|
4076
|
+
});
|
|
4077
|
+
});
|
|
4078
|
+
const layer = (options) => Layer.effect(ArrowFlightSqlClient, make$1(options));
|
|
4079
|
+
const layerConfig = (options) => Layer.effect(ArrowFlightSqlClient, Effect.gen(function* () {
|
|
4080
|
+
return yield* make$1(yield* Config.unwrap(options));
|
|
4081
|
+
}));
|
|
4070
4082
|
function createCommandDescriptor(typeUrl, value) {
|
|
4071
4083
|
const cmd = Any.create({
|
|
4072
4084
|
typeUrl: `type.googleapis.com/${typeUrl}`,
|
|
@@ -4106,7 +4118,7 @@ const FlightDataEncoder = {
|
|
|
4106
4118
|
function encodeRecordBatchContent(buffers, byteLength, compression = null) {
|
|
4107
4119
|
const out = new Uint8Array(byteLength);
|
|
4108
4120
|
const bufGroupSize = compression != null ? 2 : 1;
|
|
4109
|
-
const bufs =
|
|
4121
|
+
const bufs = Array.from({ length: bufGroupSize });
|
|
4110
4122
|
let pos = 0;
|
|
4111
4123
|
for (let i = 0; i < buffers.length; i += bufGroupSize) {
|
|
4112
4124
|
let size = 0;
|
|
@@ -4129,5 +4141,5 @@ function encodeRecordBatchContent(buffers, byteLength, compression = null) {
|
|
|
4129
4141
|
}
|
|
4130
4142
|
|
|
4131
4143
|
//#endregion
|
|
4132
|
-
export { ArrowFlightClient, ArrowFlightSqlClient, FlightData, FlightDataEncoder, FlightDescriptor, FlightDescriptor_DescriptorType,
|
|
4144
|
+
export { arrow_flight_client_exports as ArrowFlightClient, arrow_flight_sql_client_exports as ArrowFlightSqlClient, flight_client_error_exports as FlightClientError, FlightData, FlightDataEncoder, FlightDescriptor, FlightDescriptor_DescriptorType, FlightInfo, PutResult, Ticket, createChannelFromConfig };
|
|
4133
4145
|
//# sourceMappingURL=index.js.map
|