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

Function allocate_bytes

python/pyarrow/tests/test_memory.py:47–60  ·  view source on GitHub ↗

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

(pool, nbytes)

Source from the content-addressed store, hash-verified

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