forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.h
More file actions
689 lines (544 loc) · 23.6 KB
/
Copy pathtypes.h
File metadata and controls
689 lines (544 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Data structure for Flight RPC. API should be considered experimental for now
#pragma once
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "arrow/flight/visibility.h"
#include "arrow/ipc/options.h"
#include "arrow/ipc/writer.h"
#include "arrow/result.h"
namespace arrow {
class Buffer;
class RecordBatch;
class Schema;
class Status;
class Table;
namespace ipc {
class DictionaryMemo;
} // namespace ipc
namespace internal {
class Uri;
} // namespace internal
namespace flight {
/// \brief A Flight-specific status code.
enum class FlightStatusCode : int8_t {
/// An implementation error has occurred.
Internal,
/// A request timed out.
TimedOut,
/// A request was cancelled.
Cancelled,
/// We are not authenticated to the remote service.
Unauthenticated,
/// We do not have permission to make this request.
Unauthorized,
/// The remote service cannot handle this request at the moment.
Unavailable,
/// A request failed for some other reason
Failed
};
// Silence warning
// "non dll-interface class RecordBatchReader used as base for dll-interface class"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4275)
#endif
/// \brief Flight-specific error information in a Status.
class ARROW_FLIGHT_EXPORT FlightStatusDetail : public arrow::StatusDetail {
public:
explicit FlightStatusDetail(FlightStatusCode code) : code_{code} {}
explicit FlightStatusDetail(FlightStatusCode code, std::string extra_info)
: code_{code}, extra_info_(std::move(extra_info)) {}
const char* type_id() const override;
std::string ToString() const override;
/// \brief Get the Flight status code.
FlightStatusCode code() const;
/// \brief Get the extra error info
std::string extra_info() const;
/// \brief Get the human-readable name of the status code.
std::string CodeAsString() const;
/// \brief Set the extra error info
void set_extra_info(std::string extra_info);
/// \brief Try to extract a \a FlightStatusDetail from any Arrow
/// status.
///
/// \return a \a FlightStatusDetail if it could be unwrapped, \a
/// nullptr otherwise
static std::shared_ptr<FlightStatusDetail> UnwrapStatus(const arrow::Status& status);
private:
FlightStatusCode code_;
std::string extra_info_;
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/// \brief Make an appropriate Arrow status for the given
/// Flight-specific status.
///
/// \param code The Flight status code.
/// \param message The message for the error.
/// \param extra_info Optional extra binary info for the error (eg protobuf)
ARROW_FLIGHT_EXPORT
Status MakeFlightError(FlightStatusCode code, std::string message,
std::string extra_info = {});
/// \brief A TLS certificate plus key.
struct ARROW_FLIGHT_EXPORT CertKeyPair {
/// \brief The certificate in PEM format.
std::string pem_cert;
/// \brief The key in PEM format.
std::string pem_key;
};
/// \brief A type of action that can be performed with the DoAction RPC.
struct ARROW_FLIGHT_EXPORT ActionType {
/// \brief The name of the action.
std::string type;
/// \brief A human-readable description of the action.
std::string description;
bool Equals(const ActionType& other) const;
friend bool operator==(const ActionType& left, const ActionType& right) {
return left.Equals(right);
}
friend bool operator!=(const ActionType& left, const ActionType& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<ActionType> Deserialize(std::string_view serialized);
};
/// \brief Opaque selection criteria for ListFlights RPC
struct ARROW_FLIGHT_EXPORT Criteria {
/// Opaque criteria expression, dependent on server implementation
std::string expression;
bool Equals(const Criteria& other) const;
friend bool operator==(const Criteria& left, const Criteria& right) {
return left.Equals(right);
}
friend bool operator!=(const Criteria& left, const Criteria& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<Criteria> Deserialize(std::string_view serialized);
};
/// \brief An action to perform with the DoAction RPC
struct ARROW_FLIGHT_EXPORT Action {
/// The action type
std::string type;
/// The action content as a Buffer
std::shared_ptr<Buffer> body;
bool Equals(const Action& other) const;
friend bool operator==(const Action& left, const Action& right) {
return left.Equals(right);
}
friend bool operator!=(const Action& left, const Action& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<Action> Deserialize(std::string_view serialized);
};
/// \brief Opaque result returned after executing an action
struct ARROW_FLIGHT_EXPORT Result {
std::shared_ptr<Buffer> body;
bool Equals(const Result& other) const;
friend bool operator==(const Result& left, const Result& right) {
return left.Equals(right);
}
friend bool operator!=(const Result& left, const Result& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<Result> Deserialize(std::string_view serialized);
};
/// \brief message for simple auth
struct ARROW_FLIGHT_EXPORT BasicAuth {
std::string username;
std::string password;
bool Equals(const BasicAuth& other) const;
friend bool operator==(const BasicAuth& left, const BasicAuth& right) {
return left.Equals(right);
}
friend bool operator!=(const BasicAuth& left, const BasicAuth& right) {
return !(left == right);
}
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<BasicAuth> Deserialize(std::string_view serialized);
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Deserialize(const std::string& serialized, BasicAuth* out);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Serialize(const BasicAuth& basic_auth, std::string* out);
};
/// \brief A request to retrieve or generate a dataset
struct ARROW_FLIGHT_EXPORT FlightDescriptor {
enum DescriptorType {
UNKNOWN = 0, /// Unused
PATH = 1, /// Named path identifying a dataset
CMD = 2 /// Opaque command to generate a dataset
};
/// The descriptor type
DescriptorType type;
/// Opaque value used to express a command. Should only be defined when type
/// is CMD
std::string cmd;
/// List of strings identifying a particular dataset. Should only be defined
/// when type is PATH
std::vector<std::string> path;
bool Equals(const FlightDescriptor& other) const;
/// \brief Get a human-readable form of this descriptor.
std::string ToString() const;
/// \brief Get the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
arrow::Result<std::string> SerializeToString() const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status SerializeToString(std::string* out) const;
/// \brief Parse the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
static arrow::Result<FlightDescriptor> Deserialize(std::string_view serialized);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Deserialize(const std::string& serialized, FlightDescriptor* out);
// Convenience factory functions
static FlightDescriptor Command(const std::string& c) {
return FlightDescriptor{CMD, c, {}};
}
static FlightDescriptor Path(const std::vector<std::string>& p) {
return FlightDescriptor{PATH, "", p};
}
friend bool operator==(const FlightDescriptor& left, const FlightDescriptor& right) {
return left.Equals(right);
}
friend bool operator!=(const FlightDescriptor& left, const FlightDescriptor& right) {
return !(left == right);
}
};
/// \brief Data structure providing an opaque identifier or credential to use
/// when requesting a data stream with the DoGet RPC
struct ARROW_FLIGHT_EXPORT Ticket {
std::string ticket;
bool Equals(const Ticket& other) const;
friend bool operator==(const Ticket& left, const Ticket& right) {
return left.Equals(right);
}
friend bool operator!=(const Ticket& left, const Ticket& right) {
return !(left == right);
}
/// \brief Get the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
arrow::Result<std::string> SerializeToString() const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status SerializeToString(std::string* out) const;
/// \brief Parse the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
static arrow::Result<Ticket> Deserialize(std::string_view serialized);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Deserialize(const std::string& serialized, Ticket* out);
};
class FlightClient;
class FlightServerBase;
ARROW_FLIGHT_EXPORT
extern const char* kSchemeGrpc;
ARROW_FLIGHT_EXPORT
extern const char* kSchemeGrpcTcp;
ARROW_FLIGHT_EXPORT
extern const char* kSchemeGrpcUnix;
ARROW_FLIGHT_EXPORT
extern const char* kSchemeGrpcTls;
/// \brief A host location (a URI)
struct ARROW_FLIGHT_EXPORT Location {
public:
/// \brief Initialize a blank location.
Location();
/// \brief Initialize a location by parsing a URI string
static arrow::Result<Location> Parse(const std::string& uri_string);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Parse(const std::string& uri_string, Location* location);
/// \brief Initialize a location for a non-TLS, gRPC-based Flight
/// service from a host and port
/// \param[in] host The hostname to connect to
/// \param[in] port The port
/// \return Arrow result with the resulting location
static arrow::Result<Location> ForGrpcTcp(const std::string& host, const int port);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status ForGrpcTcp(const std::string& host, const int port, Location* location);
/// \brief Initialize a location for a TLS-enabled, gRPC-based Flight
/// service from a host and port
/// \param[in] host The hostname to connect to
/// \param[in] port The port
/// \return Arrow result with the resulting location
static arrow::Result<Location> ForGrpcTls(const std::string& host, const int port);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status ForGrpcTls(const std::string& host, const int port, Location* location);
/// \brief Initialize a location for a domain socket-based Flight
/// service
/// \param[in] path The path to the domain socket
/// \return Arrow result with the resulting location
static arrow::Result<Location> ForGrpcUnix(const std::string& path);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status ForGrpcUnix(const std::string& path, Location* location);
/// \brief Initialize a location based on a URI scheme
static arrow::Result<Location> ForScheme(const std::string& scheme,
const std::string& host, const int port);
/// \brief Get a representation of this URI as a string.
std::string ToString() const;
/// \brief Get the scheme of this URI.
std::string scheme() const;
bool Equals(const Location& other) const;
friend bool operator==(const Location& left, const Location& right) {
return left.Equals(right);
}
friend bool operator!=(const Location& left, const Location& right) {
return !(left == right);
}
private:
friend class FlightClient;
friend class FlightServerBase;
std::shared_ptr<arrow::internal::Uri> uri_;
};
/// \brief A flight ticket and list of locations where the ticket can be
/// redeemed
struct ARROW_FLIGHT_EXPORT FlightEndpoint {
/// Opaque ticket identify; use with DoGet RPC
Ticket ticket;
/// List of locations where ticket can be redeemed. If the list is empty, the
/// ticket can only be redeemed on the current service where the ticket was
/// generated
std::vector<Location> locations;
bool Equals(const FlightEndpoint& other) const;
friend bool operator==(const FlightEndpoint& left, const FlightEndpoint& right) {
return left.Equals(right);
}
friend bool operator!=(const FlightEndpoint& left, const FlightEndpoint& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<FlightEndpoint> Deserialize(std::string_view serialized);
};
/// \brief Staging data structure for messages about to be put on the wire
///
/// This structure corresponds to FlightData in the protocol.
struct ARROW_FLIGHT_EXPORT FlightPayload {
std::shared_ptr<Buffer> descriptor;
std::shared_ptr<Buffer> app_metadata;
ipc::IpcPayload ipc_message;
/// \brief Check that the payload can be written to the wire.
Status Validate() const;
};
/// \brief Schema result returned after a schema request RPC
struct ARROW_FLIGHT_EXPORT SchemaResult {
public:
SchemaResult() = default;
explicit SchemaResult(std::string schema) : raw_schema_(std::move(schema)) {}
/// \brief Factory method to construct a SchemaResult.
static arrow::Result<std::unique_ptr<SchemaResult>> Make(const Schema& schema);
/// \brief return schema
/// \param[in,out] dictionary_memo for dictionary bookkeeping, will
/// be modified
/// \return Arrrow result with the reconstructed Schema
arrow::Result<std::shared_ptr<Schema>> GetSchema(
ipc::DictionaryMemo* dictionary_memo) const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status GetSchema(ipc::DictionaryMemo* dictionary_memo,
std::shared_ptr<Schema>* out) const;
const std::string& serialized_schema() const { return raw_schema_; }
bool Equals(const SchemaResult& other) const;
friend bool operator==(const SchemaResult& left, const SchemaResult& right) {
return left.Equals(right);
}
friend bool operator!=(const SchemaResult& left, const SchemaResult& right) {
return !(left == right);
}
/// \brief Serialize this message to its wire-format representation.
arrow::Result<std::string> SerializeToString() const;
/// \brief Deserialize this message from its wire-format representation.
static arrow::Result<SchemaResult> Deserialize(std::string_view serialized);
private:
std::string raw_schema_;
};
/// \brief The access coordinates for retireval of a dataset, returned by
/// GetFlightInfo
class ARROW_FLIGHT_EXPORT FlightInfo {
public:
struct Data {
std::string schema;
FlightDescriptor descriptor;
std::vector<FlightEndpoint> endpoints;
int64_t total_records;
int64_t total_bytes;
};
explicit FlightInfo(const Data& data) : data_(data), reconstructed_schema_(false) {}
explicit FlightInfo(Data&& data)
: data_(std::move(data)), reconstructed_schema_(false) {}
/// \brief Factory method to construct a FlightInfo.
static arrow::Result<FlightInfo> Make(const Schema& schema,
const FlightDescriptor& descriptor,
const std::vector<FlightEndpoint>& endpoints,
int64_t total_records, int64_t total_bytes);
/// \brief Deserialize the Arrow schema of the dataset. Populate any
/// dictionary encoded fields into a DictionaryMemo for
/// bookkeeping
/// \param[in,out] dictionary_memo for dictionary bookkeeping, will
/// be modified
/// \return Arrrow result with the reconstructed Schema
arrow::Result<std::shared_ptr<Schema>> GetSchema(
ipc::DictionaryMemo* dictionary_memo) const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status GetSchema(ipc::DictionaryMemo* dictionary_memo,
std::shared_ptr<Schema>* out) const;
const std::string& serialized_schema() const { return data_.schema; }
/// The descriptor associated with this flight, may not be set
const FlightDescriptor& descriptor() const { return data_.descriptor; }
/// A list of endpoints associated with the flight (dataset). To consume the
/// whole flight, all endpoints must be consumed
const std::vector<FlightEndpoint>& endpoints() const { return data_.endpoints; }
/// The total number of records (rows) in the dataset. If unknown, set to -1
int64_t total_records() const { return data_.total_records; }
/// The total number of bytes in the dataset. If unknown, set to -1
int64_t total_bytes() const { return data_.total_bytes; }
/// \brief Get the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
arrow::Result<std::string> SerializeToString() const;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status SerializeToString(std::string* out) const;
/// \brief Parse the wire-format representation of this type.
///
/// Useful when interoperating with non-Flight systems (e.g. REST
/// services) that may want to return Flight types.
static arrow::Result<std::unique_ptr<FlightInfo>> Deserialize(
std::string_view serialized);
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
static Status Deserialize(const std::string& serialized,
std::unique_ptr<FlightInfo>* out);
private:
Data data_;
mutable std::shared_ptr<Schema> schema_;
mutable bool reconstructed_schema_;
};
/// \brief An iterator to FlightInfo instances returned by ListFlights.
class ARROW_FLIGHT_EXPORT FlightListing {
public:
virtual ~FlightListing() = default;
/// \brief Retrieve the next FlightInfo from the iterator.
/// \return Arrow result with a single FlightInfo. Set to \a nullptr if there
/// are none left.
virtual arrow::Result<std::unique_ptr<FlightInfo>> Next() = 0;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status Next(std::unique_ptr<FlightInfo>* info);
};
/// \brief An iterator to Result instances returned by DoAction.
class ARROW_FLIGHT_EXPORT ResultStream {
public:
virtual ~ResultStream() = default;
/// \brief Retrieve the next Result from the iterator.
/// \return Arrow result with a single Result. Set to \a nullptr if there are none left.
virtual arrow::Result<std::unique_ptr<Result>> Next() = 0;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status Next(std::unique_ptr<Result>* info);
};
/// \brief A holder for a RecordBatch with associated Flight metadata.
struct ARROW_FLIGHT_EXPORT FlightStreamChunk {
public:
std::shared_ptr<RecordBatch> data;
std::shared_ptr<Buffer> app_metadata;
};
/// \brief An interface to read Flight data with metadata.
class ARROW_FLIGHT_EXPORT MetadataRecordBatchReader {
public:
virtual ~MetadataRecordBatchReader() = default;
/// \brief Get the schema for this stream.
virtual arrow::Result<std::shared_ptr<Schema>> GetSchema() = 0;
/// \brief Get the next message from Flight. If the stream is
/// finished, then the members of \a FlightStreamChunk will be
/// nullptr.
virtual arrow::Result<FlightStreamChunk> Next() = 0;
ARROW_DEPRECATED("Deprecated in 8.0.0. Use Result-returning overload instead.")
Status Next(FlightStreamChunk* next);
/// \brief Consume entire stream as a vector of record batches
virtual arrow::Result<std::vector<std::shared_ptr<RecordBatch>>> ToRecordBatches();
ARROW_DEPRECATED("Deprecated in 8.0.0. Use ToRecordBatches instead.")
Status ReadAll(std::vector<std::shared_ptr<RecordBatch>>* batches);
/// \brief Consume entire stream as a Table
virtual arrow::Result<std::shared_ptr<Table>> ToTable();
ARROW_DEPRECATED("Deprecated in 8.0.0. Use ToTable instead.")
Status ReadAll(std::shared_ptr<Table>* table);
};
/// \brief Convert a MetadataRecordBatchReader to a regular RecordBatchReader.
ARROW_FLIGHT_EXPORT
arrow::Result<std::shared_ptr<RecordBatchReader>> MakeRecordBatchReader(
std::shared_ptr<MetadataRecordBatchReader> reader);
/// \brief An interface to write IPC payloads with metadata.
class ARROW_FLIGHT_EXPORT MetadataRecordBatchWriter : public ipc::RecordBatchWriter {
public:
virtual ~MetadataRecordBatchWriter() = default;
/// \brief Begin writing data with the given schema. Only used with \a DoExchange.
virtual Status Begin(const std::shared_ptr<Schema>& schema,
const ipc::IpcWriteOptions& options) = 0;
virtual Status Begin(const std::shared_ptr<Schema>& schema);
virtual Status WriteMetadata(std::shared_ptr<Buffer> app_metadata) = 0;
virtual Status WriteWithMetadata(const RecordBatch& batch,
std::shared_ptr<Buffer> app_metadata) = 0;
};
/// \brief A FlightListing implementation based on a vector of
/// FlightInfo objects.
///
/// This can be iterated once, then it is consumed.
class ARROW_FLIGHT_EXPORT SimpleFlightListing : public FlightListing {
public:
explicit SimpleFlightListing(const std::vector<FlightInfo>& flights);
explicit SimpleFlightListing(std::vector<FlightInfo>&& flights);
arrow::Result<std::unique_ptr<FlightInfo>> Next() override;
private:
int position_;
std::vector<FlightInfo> flights_;
};
/// \brief A ResultStream implementation based on a vector of
/// Result objects.
///
/// This can be iterated once, then it is consumed.
class ARROW_FLIGHT_EXPORT SimpleResultStream : public ResultStream {
public:
explicit SimpleResultStream(std::vector<Result>&& results);
arrow::Result<std::unique_ptr<Result>> Next() override;
private:
std::vector<Result> results_;
size_t position_;
};
} // namespace flight
} // namespace arrow