Exemplo n.º 1
0
def _format_batch(batch: Block, batch_format: str) -> BatchType:
    import pyarrow as pa

    if batch_format == "native":
        # Always promote Arrow blocks to pandas for consistency, since
        # we lazily convert pandas->Arrow internally for efficiency.
        if isinstance(batch, pa.Table) or isinstance(batch, bytes):
            batch = BlockAccessor.for_block(batch)
            batch = batch.to_pandas()
        return batch
    elif batch_format == "pandas":
        batch = BlockAccessor.for_block(batch)
        return batch.to_pandas()
    elif batch_format == "pyarrow":
        batch = BlockAccessor.for_block(batch)
        return batch.to_arrow()
    else:
        raise ValueError(f"The given batch format: {batch_format} "
                         f"is invalid. Supported batch type: {BatchType}")
Exemplo n.º 2
0
def _block_to_vineyard(block: Block):
    client = vineyard.connect()
    block = BlockAccessor.for_block(block)
    return client.put(block.to_pandas())