MCPcopy Create free account
hub / github.com/apache/arrow / allocate_bytes

Function allocate_bytes

python/pyarrow/tests/test_memory.py:46–59  ·  view source on GitHub ↗

Temporarily allocate *nbytes* from the given *pool*.

(pool, nbytes)

Source from the content-addressed store, hash-verified

44
45@contextlib.contextmanager
46def allocate_bytes(pool, nbytes):
47 """
48 Temporarily allocate *nbytes* from the given *pool*.
49 """
50 arr = pa.array([b"x" * nbytes], type=pa.binary(), memory_pool=pool)
51 # Fetch the values buffer from the varbinary array and release the rest,
52 # to get the desired allocation amount
53 buf = arr.buffers()[2]
54 arr = None
55 assert len(buf) == nbytes
56 try:
57 yield
58 finally:
59 buf = None
60
61
62def check_allocated_bytes(pool):

Callers 3

check_allocated_bytesFunction · 0.85
test_set_memory_poolFunction · 0.85

Calls 3

lenFunction · 0.85
buffersMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected