in http/get_compressed/python/client/client.py [0:0]
def request_and_process(uri, compression):
batches = []
log_prefix = f"{'[' + compression + ']':>10}:"
print(
f"{log_prefix} Requesting data from {uri} with `{compression}` compression strategy."
)
start_time = time.time()
response = make_request(uri, compression)
with pa.ipc.open_stream(response) as reader:
schema = reader.schema
time_to_schema = time.time() - start_time
try:
batch = reader.read_next_batch()
time_to_first_batch = time.time() - start_time
batches.append(batch)
while True:
batch = reader.read_next_batch()
batches.append(batch)
except StopIteration:
pass
processing_time = time.time() - start_time
reader_stats = reader.stats
print(
f"{log_prefix} Schema received in {time_to_schema:.3f} seconds."
f" schema=({', '.join(schema.names)})."
)
print(
f"{log_prefix} First batch received and processed in"
f" {time_to_first_batch:.3f} seconds"
)
print(
f"{log_prefix} Processing of all batches completed in"
f" {processing_time:.3f} seconds."
)
print(f"{log_prefix}", reader_stats)
return batches