jorisvandenbossche commented on code in PR #41967:
URL: https://github.com/apache/arrow/pull/41967#discussion_r1634861855
##########
java/c/src/test/python/integration_tests.py:
##########
@@ -183,6 +190,55 @@ def round_trip_reader(self, schema, batches):
def test_string_array(self):
self.round_trip_array(lambda: pa.array([None, "a", "bb", "ccc"]))
+ def test_stringview_array(self):
+ # with nulls short strings
+ self.round_trip_array(lambda: pa.array([None, "a", "bb", "c"],
type=pa.string_view()))
+ # with nulls long and strings
+ self.round_trip_array(lambda: pa.array([None, "a", "bb"*10, "c"*13],
type=pa.string_view()))
+ # without nulls short strings
+ self.round_trip_array(lambda: pa.array(["a", "bb", "c"],
type=pa.string_view()))
+ # without nulls long and strings
+ self.round_trip_array(lambda: pa.array(["a", "bb"*10, "c"*13],
type=pa.string_view()))
+ # with multiple data buffers
+ data = []
+ for i in range(1, 501):
+ s = ''.join(str(j) for j in range(i))
+ data.append(s)
+ self.round_trip_array(lambda: pa.array(data, type=pa.string_view()))
Review Comment:
This will indeed create multiple data buffers, although that relies a bit on
the Builder's default size used for a data buffer. Another potentially slightly
easier way to create am array with multiple data buffers is by concatenating;
```
In [30]: arr1 = pa.array([None, "a", "bb", "c"], type=pa.string_view())
In [31]: arr2 = pa.array(["a", "bb"*10, "c"*13], type=pa.string_view())
In [32]: pa.concat_arrays([arr1, arr2]).buffers()
Out[32]:
[<pyarrow.Buffer address=0x7faeab209180 size=1 is_cpu=True is_mutable=True>,
<pyarrow.Buffer address=0x7faeab208100 size=112 is_cpu=True
is_mutable=True>,
<pyarrow.Buffer address=0x7faead33e5c0 size=0 is_cpu=True is_mutable=True>,
<pyarrow.Buffer address=0x7faeab2092c0 size=33 is_cpu=True is_mutable=True>]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]