Skip to content

Commit

Permalink
get_buffer -> get_buffers and update example
Browse files Browse the repository at this point in the history
  • Loading branch information
pcmoritz committed Aug 28, 2017
1 parent 8c36903 commit e60ea73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion python/examples/plasma/sorting/sort_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def put_df(df):

def get_dfs(object_ids):
"""Retrieve dataframes from the object store given their object IDs."""
buffers = client.get(object_ids)
buffers = client.get_buffers(object_ids)
return [pa.RecordBatchStreamReader(buf).read_next_batch().to_pandas()
for buf in buffers]

Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/plasma.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ cdef class PlasmaClient:
metadata.size(), &data))
return self._make_mutable_plasma_buffer(object_id, data, data_size)

def get_buffer(self, object_ids, timeout_ms=-1):
def get_buffers(self, object_ids, timeout_ms=-1):
"""
Returns data buffer from the PlasmaStore based on object ID.
Expand Down Expand Up @@ -419,7 +419,7 @@ cdef class PlasmaClient:
"""
if isinstance(object_ids, collections.Sequence):
results = []
buffers = self.get_buffer(object_ids, timeout_ms)
buffers = self.get_buffers(object_ids, timeout_ms)
for i in range(len(object_ids)):
# buffers[i] is None if this object was not available within the
# timeout
Expand Down
18 changes: 9 additions & 9 deletions python/pyarrow/tests/test_plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def create_object(client, data_size, metadata_size, seal=True):
def assert_get_object_equal(unit_test, client1, client2, object_id,
memory_buffer=None, metadata=None):
import pyarrow.plasma as plasma
client1_buff = client1.get_buffer([object_id])[0]
client2_buff = client2.get_buffer([object_id])[0]
client1_buff = client1.get_buffers([object_id])[0]
client2_buff = client2.get_buffers([object_id])[0]
client1_metadata = client1.get_metadata([object_id])[0]
client2_metadata = client2.get_metadata([object_id])[0]
assert len(client1_buff) == len(client2_buff)
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_create(self):
# Seal the object.
self.plasma_client.seal(object_id)
# Get the object.
memory_buffer = np.frombuffer(self.plasma_client.get_buffer([object_id])[0],
memory_buffer = np.frombuffer(self.plasma_client.get_buffers([object_id])[0],
dtype="uint8")
for i in range(length):
assert memory_buffer[i] == i % 256
Expand All @@ -209,7 +209,7 @@ def test_create_with_metadata(self):
self.plasma_client.seal(object_id)
# Get the object.
memory_buffer = np.frombuffer(
self.plasma_client.get_buffer([object_id])[0], dtype="uint8")
self.plasma_client.get_buffers([object_id])[0], dtype="uint8")
for i in range(length):
assert memory_buffer[i] == i % 256
# Get the metadata.
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_get(self):
# Test timing out of get with various timeouts.
for timeout in [0, 10, 100, 1000]:
object_ids = [random_object_id() for _ in range(num_object_ids)]
results = self.plasma_client.get_buffer(object_ids, timeout_ms=timeout)
results = self.plasma_client.get_buffers(object_ids, timeout_ms=timeout)
assert results == num_object_ids * [None]

data_buffers = []
Expand All @@ -256,7 +256,7 @@ def test_get(self):
# Test timing out from some but not all get calls with various
# timeouts.
for timeout in [0, 10, 100, 1000]:
data_results = self.plasma_client.get_buffer(object_ids,
data_results = self.plasma_client.get_buffers(object_ids,
timeout_ms=timeout)
# metadata_results = self.plasma_client.get_metadata(
# object_ids, timeout_ms=timeout)
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_store_arrow_objects(self):
pa.write_tensor(tensor, stream)
self.plasma_client.seal(object_id)
# Read the arrow object.
[tensor] = self.plasma_client.get_buffer([object_id])
[tensor] = self.plasma_client.get_buffers([object_id])
reader = pa.BufferReader(tensor)
array = pa.read_tensor(reader).to_numpy()
# Assert that they are equal.
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_store_pandas_dataframe(self):
self.plasma_client.seal(object_id)

# Read the DataFrame.
[data] = self.plasma_client.get_buffer([object_id])
[data] = self.plasma_client.get_buffers([object_id])
reader = pa.RecordBatchStreamReader(pa.BufferReader(data))
result = reader.get_next_batch().to_pandas()

Expand Down Expand Up @@ -564,7 +564,7 @@ def test_illegal_functionality(self):
# with pytest.raises(Exception):
# illegal_assignment()
# Get the object.
memory_buffer = self.plasma_client.get_buffer([object_id])[0]
memory_buffer = self.plasma_client.get_buffers([object_id])[0]

# Make sure the object is read only.
def illegal_assignment():
Expand Down

0 comments on commit e60ea73

Please sign in to comment.