flight
Arrow Flight utilities.
ChainedFlightReader ¶
ChainedFlightReader(endpoints, initial_url, metadata=None)
Bases: StreamReader
Sequential reader for time-ordered endpoint slices.
Groups endpoints by time slice (based on the start time in their tickets), orders slices chronologically, and reads each slice to completion before starting the next. Concurrent endpoints within the same slice are handled by a MultiFlightReader.
Source code in arrakis/flight.py
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 | |
MultiFlightReader ¶
MultiFlightReader(endpoints, initial_url, metadata=None)
Bases: StreamReader
Multi-threaded Arrow Flight endpoint stream iterator context manager
Given a list of endpoints, connect to all of them in parallel and stream data from them all interleaved.
Source code in arrakis/flight.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
close ¶
close()
close all streams
Source code in arrakis/flight.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
done ¶
done()
returns True when all threads are done and the queue is empty
Source code in arrakis/flight.py
325 326 327 | |
read ¶
read(*, convert_blocks=False)
read all available data from all streams
Yields:
| Type | Description |
|---|---|
tuple of (stream_id, data)
|
|
Source code in arrakis/flight.py
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 | |
RequestValidator ¶
RequestValidator()
A validator for JSON-encoded requests.
Source code in arrakis/flight.py
62 63 64 65 66 67 | |
validate ¶
validate(payload)
Validate a JSON-encoded request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Request
|
A dictionary with a 'request' and an 'args' key encoding the given Flight request. |
required |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
create_command ¶
create_command(request_type, *, validator, **kwargs)
Create a Flight command containing a JSON-encoded request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_type
|
RequestType
|
The type of request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
**kwargs
|
dict
|
Extra arguments corresponding to the specific request. |
{}
|
Returns:
| Type | Description |
|---|---|
bytes
|
The JSON-encoded request. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |
create_descriptor ¶
create_descriptor(request_type, *, validator, **kwargs)
Create a Flight descriptor given a request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_type
|
RequestType
|
The type of request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
**kwargs
|
dict
|
Extra arguments corresponding to the specific request. |
{}
|
Returns:
| Type | Description |
|---|---|
FlightDescriptor
|
A Flight Descriptor containing the request. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |
parse_command ¶
parse_command(cmd, *, validator)
Parse a Flight command into a request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
bytes
|
The JSON-encoded request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request_type |
RequestType
|
The type of request. |
kwargs |
dict
|
Arguments corresponding to the specific request. |
Raises:
| Type | Description |
|---|---|
JSONDecodeError
|
If the command does not decode to valid JSON. |
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |