Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ def _(
rec.state["ir_context"],
ch_out,
num_producers=num_producers,
estimated_chunk_bytes=executor.target_partition_size,
estimated_chunk_bytes=(
plan.estimated_chunk_bytes or executor.target_partition_size
),
)
]
return nodes, channels
Expand Down
13 changes: 11 additions & 2 deletions python/cudf_polars/cudf_polars/streaming/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,21 @@ class IOPartitionPlan:
- SINGLE_READ: `factor` is the total number of files.
"""

__slots__ = ("factor", "flavor")
__slots__ = ("estimated_chunk_bytes", "factor", "flavor")
factor: int
flavor: IOPartitionFlavor
estimated_chunk_bytes: int | None
"""Estimated decompressed bytes per chunk (Scan nodes only)."""

def __init__(self, factor: int, flavor: IOPartitionFlavor) -> None:
def __init__(
self,
factor: int,
flavor: IOPartitionFlavor,
*,
estimated_chunk_bytes: int | None = None,
) -> None:
if flavor == IOPartitionFlavor.SINGLE_FILE and factor != 1: # pragma: no cover
raise ValueError(f"Expected factor == 1 for {flavor}, got: {factor}")
self.factor = factor
self.flavor = flavor
self.estimated_chunk_bytes = estimated_chunk_bytes
8 changes: 6 additions & 2 deletions python/cudf_polars/cudf_polars/streaming/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ def scan_partition_plan(
if (file_size := sum(column_sizes)) > 0:
if file_size > blocksize:
# Split large files
factor = math.ceil(file_size / blocksize)
return IOPartitionPlan(
math.ceil(file_size / blocksize),
factor,
IOPartitionFlavor.SPLIT_FILES,
estimated_chunk_bytes=file_size // factor,
)
else:
# Fuse small files
factor = max(blocksize // int(file_size), 1)
return IOPartitionPlan(
max(blocksize // int(file_size), 1),
factor,
IOPartitionFlavor.FUSED_FILES,
estimated_chunk_bytes=file_size * factor,
)

# TODO: Use file sizes for csv and json
Expand Down
Loading