Skip to content

Commit

Permalink
Use LazyDefaults in python CacheOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Dec 13, 2023
1 parent 6ddb00b commit 8dba65c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion python/pyarrow/includes/libarrow.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ cdef extern from "arrow/io/api.h" namespace "arrow::io" nogil:
int64_t max_ideal_request_size_mib)

@staticmethod
CCacheOptions Defaults()
CCacheOptions LazyDefaults()

cdef cppclass COutputStream" arrow::io::OutputStream"(FileInterface,
Writable):
Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/io.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ cdef class CacheOptions(_Weakrefable):
The maximum size in bytes of a combined range; if combining two
consecutive ranges would produce a range of a size greater than this,
they are not combined
lazy : bool, default False
lazy : bool, default True
lazy = false: request all byte ranges when PreBuffer or WillNeed is called.
lazy = True, prefetch_limit = 0: request merged byte ranges only after the reader
needs them.
Expand All @@ -2146,7 +2146,7 @@ cdef class CacheOptions(_Weakrefable):
"""

def __init__(self, *, hole_size_limit=None, range_size_limit=None, lazy=None, prefetch_limit=None):
self.wrapped = CCacheOptions.Defaults()
self.wrapped = CCacheOptions.LazyDefaults()
if hole_size_limit is not None:
self.hole_size_limit = hole_size_limit
if range_size_limit is not None:
Expand Down
22 changes: 11 additions & 11 deletions python/pyarrow/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,38 +668,38 @@ def test_cache_options():
opts1 = pa.CacheOptions()
opts2 = pa.CacheOptions(hole_size_limit=1024)
opts3 = pa.CacheOptions(hole_size_limit=4096, range_size_limit=8192)
opts4 = pa.CacheOptions(hole_size_limit=4096, range_size_limit=8192, lazy=True)
opts4 = pa.CacheOptions(hole_size_limit=4096, range_size_limit=8192, prefetch_limit=5)
opts5 = pa.CacheOptions(hole_size_limit=4096,
range_size_limit=8192, lazy=True, prefetch_limit=5)
range_size_limit=8192, lazy=False)
opts6 = pa.CacheOptions.from_network_metrics(time_to_first_byte_millis=100,
transfer_bandwidth_mib_per_sec=200,
ideal_bandwidth_utilization_frac=0.9,
max_ideal_request_size_mib=64)

assert opts1.hole_size_limit == 8192
assert opts1.range_size_limit == 32 * 1024 * 1024
assert opts1.lazy is False
assert opts4.prefetch_limit == 0
assert opts1.lazy is True
assert opts1.prefetch_limit == 0

assert opts2.hole_size_limit == 1024
assert opts2.range_size_limit == 32 * 1024 * 1024
assert opts2.lazy is False
assert opts4.prefetch_limit == 0
assert opts2.lazy is True
assert opts2.prefetch_limit == 0

assert opts3.hole_size_limit == 4096
assert opts3.range_size_limit == 8192
assert opts3.lazy is False
assert opts4.prefetch_limit == 0
assert opts3.lazy is True
assert opts3.prefetch_limit == 0

assert opts4.hole_size_limit == 4096
assert opts4.range_size_limit == 8192
assert opts4.lazy is True
assert opts4.prefetch_limit == 0
assert opts4.prefetch_limit == 5

assert opts5.hole_size_limit == 4096
assert opts5.range_size_limit == 8192
assert opts5.lazy is True
assert opts5.prefetch_limit == 5
assert opts5.lazy is False
assert opts5.prefetch_limit == 0

assert opts6.lazy is False

Expand Down

0 comments on commit 8dba65c

Please sign in to comment.