felipecrv commented on code in PR #35345: URL: https://github.com/apache/arrow/pull/35345#discussion_r1396632467
########## cpp/src/arrow/array/concatenate_test.cc: ########## @@ -69,33 +99,117 @@ class ConcatenateTest : public ::testing::Test { return slices; } + std::shared_ptr<Buffer> ValidityBitmap(int64_t size, double null_probability) { + return rag_.NullBitmap(size, null_probability, kDefaultBufferAlignment, + default_memory_pool()); + } + template <typename PrimitiveType> - std::shared_ptr<Array> GeneratePrimitive(int64_t size, double null_probability) { + std::shared_ptr<Array> PrimitiveArray(int64_t size, double null_probability) { if (std::is_same<PrimitiveType, BooleanType>::value) { - return rng_.Boolean(size, 0.5, null_probability); + return rag_.Boolean(size, 0.5, null_probability); } - return rng_.Numeric<PrimitiveType, uint8_t>(size, 0, 127, null_probability); + return rag_.Numeric<PrimitiveType, uint8_t>(size, 0, 127, null_probability); + } + + std::shared_ptr<Array> StringArray(int64_t size, double null_probability) { + return rag_.String(size, /*min_length =*/0, /*max_length =*/15, null_probability); + } + + std::shared_ptr<Array> LargeStringArray(int64_t size, double null_probability) { + return rag_.LargeString(size, /*min_length =*/0, /*max_length =*/15, + null_probability); + } + + std::shared_ptr<Array> StringViewArray(int64_t size, double null_probability) { + return rag_.StringView(size, /*min_length =*/0, /*max_length =*/40, null_probability, + /*max_buffer_length=*/200); + } + + std::shared_ptr<Array> ArrayOf(std::shared_ptr<DataType> type, int64_t size, + double null_probability) { + return rag_.ArrayOf(std::move(type), size, null_probability); + } + + // TODO(GH-38656): Use the random array generators from testing/random.h here + + template <typename ListType, + typename ListArrayType = typename TypeTraits<ListType>::ArrayType> + Result<std::shared_ptr<ListArrayType>> ListArray(int32_t length, + double null_probability) { + using offset_type = typename ListType::offset_type; + using OffsetArrowType = typename CTypeTraits<offset_type>::ArrowType; + + auto values_size = length * 4; + auto values = PrimitiveArray<Int8Type>(values_size, null_probability); + auto offsets_vector = Offsets<offset_type>(values_size, length); + // Ensure first and last offsets encompass the whole values array + offsets_vector.front() = 0; Review Comment: @pitrou I also don't do this for list-views anymore. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org