Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions cpp/src/arrow/array-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class TestPrimitiveBuilder : public TestBuilder {
Attrs::draw(N, &draws_);

valid_bytes_.resize(static_cast<size_t>(N));
test::random_null_bytes(N, pct_null, valid_bytes_.data());
random_null_bytes(N, pct_null, valid_bytes_.data());
}

void Check(const std::unique_ptr<BuilderType>& builder, bool nullable) {
Expand All @@ -323,7 +323,7 @@ class TestPrimitiveBuilder : public TestBuilder {
if (nullable) {
ASSERT_OK(
BitUtil::BytesToBits(valid_bytes_, default_memory_pool(), &ex_null_bitmap));
ex_null_count = test::null_count(valid_bytes_);
ex_null_count = CountNulls(valid_bytes_);
} else {
ex_null_bitmap = nullptr;
}
Expand Down Expand Up @@ -381,23 +381,23 @@ struct UniformIntSampleType<int8_t> {
\
static std::shared_ptr<DataType> type() { return std::make_shared<Type>(); }

#define PINT_DECL(CapType, c_type) \
struct P##CapType { \
PTYPE_DECL(CapType, c_type) \
static void draw(int64_t N, vector<T>* draws) { \
using sample_type = typename UniformIntSampleType<c_type>::type; \
const T lower = std::numeric_limits<T>::min(); \
const T upper = std::numeric_limits<T>::max(); \
test::randint(N, static_cast<sample_type>(lower), static_cast<sample_type>(upper), \
draws); \
} \
#define PINT_DECL(CapType, c_type) \
struct P##CapType { \
PTYPE_DECL(CapType, c_type) \
static void draw(int64_t N, vector<T>* draws) { \
using sample_type = typename UniformIntSampleType<c_type>::type; \
const T lower = std::numeric_limits<T>::min(); \
const T upper = std::numeric_limits<T>::max(); \
randint(N, static_cast<sample_type>(lower), static_cast<sample_type>(upper), \
draws); \
} \
}

#define PFLOAT_DECL(CapType, c_type, LOWER, UPPER) \
struct P##CapType { \
PTYPE_DECL(CapType, c_type) \
static void draw(int64_t N, vector<T>* draws) { \
test::random_real(N, 0, LOWER, UPPER, draws); \
random_real(N, 0, LOWER, UPPER, draws); \
} \
}

Expand All @@ -423,8 +423,8 @@ void TestPrimitiveBuilder<PBoolean>::RandomData(int64_t N, double pct_null) {
draws_.resize(static_cast<size_t>(N));
valid_bytes_.resize(static_cast<size_t>(N));

test::random_null_bytes(N, 0.5, draws_.data());
test::random_null_bytes(N, pct_null, valid_bytes_.data());
random_null_bytes(N, 0.5, draws_.data());
random_null_bytes(N, pct_null, valid_bytes_.data());
}

template <>
Expand All @@ -445,7 +445,7 @@ void TestPrimitiveBuilder<PBoolean>::Check(const std::unique_ptr<BooleanBuilder>
ASSERT_OK(BitUtil::BytesToBits(draws_, default_memory_pool(), &ex_data));
if (nullable) {
ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, default_memory_pool(), &ex_null_bitmap));
ex_null_count = test::null_count(valid_bytes_);
ex_null_count = CountNulls(valid_bytes_);
} else {
ex_null_bitmap = nullptr;
}
Expand Down Expand Up @@ -923,8 +923,8 @@ TEST(TestBooleanBuilder, TestStdBoolVectorAppend) {
std::vector<bool> values, is_valid;

const int length = 10000;
test::random_is_valid(length, 0.5, &values);
test::random_is_valid(length, 0.1, &is_valid);
random_is_valid(length, 0.5, &values);
random_is_valid(length, 0.1, &is_valid);

const int chunksize = 1000;
for (int chunk = 0; chunk < length / chunksize; ++chunk) {
Expand Down Expand Up @@ -963,8 +963,8 @@ void CheckSliceApproxEquals() {
vector<T> draws2;

const uint32_t kSeed = 0;
test::random_real(kSize, kSeed, 0.0, 100.0, &draws1);
test::random_real(kSize, kSeed + 1, 0.0, 100.0, &draws2);
random_real(kSize, kSeed, 0.0, 100.0, &draws1);
random_real(kSize, kSeed + 1, 0.0, 100.0, &draws2);

// Make the draws equal in the sliced segment, but unequal elsewhere (to
// catch not using the slice offset)
Expand All @@ -973,7 +973,7 @@ void CheckSliceApproxEquals() {
}

vector<bool> is_valid;
test::random_is_valid(kSize, 0.1, &is_valid);
random_is_valid(kSize, 0.1, &is_valid);

std::shared_ptr<Array> array1, array2;
ArrayFromVector<TYPE, T>(is_valid, draws1, &array1);
Expand Down Expand Up @@ -1006,10 +1006,10 @@ class TestStringArray : public ::testing::Test {

void MakeArray() {
length_ = static_cast<int64_t>(offsets_.size()) - 1;
value_buf_ = test::GetBufferFromVector(chars_);
offsets_buf_ = test::GetBufferFromVector(offsets_);
value_buf_ = GetBufferFromVector(chars_);
offsets_buf_ = GetBufferFromVector(offsets_);
ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, default_memory_pool(), &null_bitmap_));
null_count_ = test::null_count(valid_bytes_);
null_count_ = CountNulls(valid_bytes_);

strings_ = std::make_shared<StringArray>(length_, offsets_buf_, value_buf_,
null_bitmap_, null_count_);
Expand Down Expand Up @@ -1071,7 +1071,7 @@ TEST_F(TestStringArray, TestGetString) {

TEST_F(TestStringArray, TestEmptyStringComparison) {
offsets_ = {0, 0, 0, 0, 0, 0};
offsets_buf_ = test::GetBufferFromVector(offsets_);
offsets_buf_ = GetBufferFromVector(offsets_);
length_ = static_cast<int64_t>(offsets_.size() - 1);

auto strings_a = std::make_shared<StringArray>(length_, offsets_buf_, nullptr,
Expand Down Expand Up @@ -1318,11 +1318,11 @@ class TestBinaryArray : public ::testing::Test {

void MakeArray() {
length_ = static_cast<int64_t>(offsets_.size() - 1);
value_buf_ = test::GetBufferFromVector(chars_);
offsets_buf_ = test::GetBufferFromVector(offsets_);
value_buf_ = GetBufferFromVector(chars_);
offsets_buf_ = GetBufferFromVector(offsets_);

ASSERT_OK(BitUtil::BytesToBits(valid_bytes_, default_memory_pool(), &null_bitmap_));
null_count_ = test::null_count(valid_bytes_);
null_count_ = CountNulls(valid_bytes_);

strings_ = std::make_shared<BinaryArray>(length_, offsets_buf_, value_buf_,
null_bitmap_, null_count_);
Expand Down Expand Up @@ -1610,10 +1610,10 @@ TEST_F(TestFWBinaryArray, Builder) {
int64_t nbytes = length * byte_width;

vector<uint8_t> data(nbytes);
test::random_bytes(nbytes, 0, data.data());
random_bytes(nbytes, 0, data.data());

vector<uint8_t> is_valid(length);
test::random_null_bytes(length, 0.1, is_valid.data());
random_null_bytes(length, 0.1, is_valid.data());

const uint8_t* raw_data = data.data();

Expand Down Expand Up @@ -2885,19 +2885,19 @@ TEST_F(TestListArray, TestFromArrays) {

ListArray expected1(list_type, length, offsets1->data()->buffers[1], values,
offsets1->data()->buffers[0], 0);
test::AssertArraysEqual(expected1, *list1);
AssertArraysEqual(expected1, *list1);

// Use null bitmap from offsets3, but clean offsets from non-null version
ListArray expected3(list_type, length, offsets1->data()->buffers[1], values,
offsets3->data()->buffers[0], 1);
test::AssertArraysEqual(expected3, *list3);
AssertArraysEqual(expected3, *list3);

// Check that the last offset bit is zero
ASSERT_FALSE(BitUtil::GetBit(list3->null_bitmap()->data(), length + 1));

ListArray expected4(list_type, length, offsets2->data()->buffers[1], values,
offsets4->data()->buffers[0], 1);
test::AssertArraysEqual(expected4, *list4);
AssertArraysEqual(expected4, *list4);

// Test failure modes

Expand Down Expand Up @@ -3682,7 +3682,7 @@ class DecimalTest : public ::testing::TestWithParam<int> {
ASSERT_OK(
BitUtil::BytesToBits(valid_bytes, default_memory_pool(), &expected_null_bitmap));

int64_t expected_null_count = test::null_count(valid_bytes);
int64_t expected_null_count = CountNulls(valid_bytes);
auto expected = std::make_shared<Decimal128Array>(
type, size, expected_data, expected_null_bitmap, expected_null_count);

Expand Down
10 changes: 5 additions & 5 deletions cpp/src/arrow/compute/compute-benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ struct HashParams {
std::vector<int64_t> draws;
std::vector<T> values;
std::vector<bool> is_valid;
test::randint<int64_t>(length, 0, num_unique, &draws);
randint<int64_t>(length, 0, num_unique, &draws);
for (int64_t draw : draws) {
values.push_back(static_cast<T>(draw));
}

if (this->null_percent > 0) {
test::random_is_valid(length, this->null_percent, &is_valid);
random_is_valid(length, this->null_percent, &is_valid);
ArrayFromVector<Type, T>(is_valid, values, arr);
} else {
ArrayFromVector<Type, T>(values, arr);
Expand All @@ -115,16 +115,16 @@ struct HashParams<StringType> {
void GenerateTestData(const int64_t length, const int64_t num_unique,
std::shared_ptr<Array>* arr) const {
std::vector<int64_t> draws;
test::randint<int64_t>(length, 0, num_unique, &draws);
randint<int64_t>(length, 0, num_unique, &draws);

const int64_t total_bytes = this->byte_width * num_unique;
std::vector<uint8_t> uniques(total_bytes);
const uint32_t seed = 0;
test::random_bytes(total_bytes, seed, uniques.data());
random_bytes(total_bytes, seed, uniques.data());

std::vector<bool> is_valid;
if (this->null_percent > 0) {
test::random_is_valid(length, this->null_percent, &is_valid);
random_is_valid(length, this->null_percent, &is_valid);
}

StringBuilder builder;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/compute-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,9 @@ TEST_F(TestCast, DictToNonDictNoNulls) {
std::vector<int32_t> i1 = {1, 0, 1};
std::vector<int32_t> i2 = {2, 1, 0, 1};
auto c1 = std::make_shared<NumericArray<Int32Type>>(
3, arrow::test::GetBufferFromVector<int32_t>(i1));
3, arrow::GetBufferFromVector<int32_t>(i1));
auto c2 = std::make_shared<NumericArray<Int32Type>>(
4, arrow::test::GetBufferFromVector<int32_t>(i2));
4, arrow::GetBufferFromVector<int32_t>(i2));

ArrayVector dict_arrays = {std::make_shared<DictionaryArray>(dict_type, c1),
std::make_shared<DictionaryArray>(dict_type, c2)};
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/gpu/cuda-benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static void CudaBufferWriterBenchmark(benchmark::State& state, const int64_t tot
}

std::shared_ptr<ResizableBuffer> buffer;
ASSERT_OK(test::MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer));
ASSERT_OK(MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer));

const uint8_t* host_data = buffer->data();
while (state.KeepRunning()) {
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/arrow/gpu/cuda-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TEST_F(TestCudaBuffer, CopyFromHost) {
ASSERT_OK(context_->Allocate(kSize, &device_buffer));

std::shared_ptr<ResizableBuffer> host_buffer;
ASSERT_OK(test::MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));
ASSERT_OK(MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));

ASSERT_OK(device_buffer->CopyFromHost(0, host_buffer->data(), 500));
ASSERT_OK(device_buffer->CopyFromHost(500, host_buffer->data() + 500, kSize - 500));
Expand All @@ -86,7 +86,7 @@ TEST_F(TestCudaBuffer, FromBuffer) {
std::shared_ptr<ResizableBuffer> host_buffer;
std::shared_ptr<CudaBuffer> device_buffer;
ASSERT_OK(context_->Allocate(kSize, &device_buffer));
ASSERT_OK(test::MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));
ASSERT_OK(MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));
ASSERT_OK(device_buffer->CopyFromHost(0, host_buffer->data(), 1000));
// Sanity check
AssertCudaBufferEquals(*device_buffer, host_buffer->data(), kSize);
Expand Down Expand Up @@ -133,7 +133,7 @@ TEST_F(TestCudaBuffer, DISABLED_ExportForIpc) {
ASSERT_OK(context_->Allocate(kSize, &device_buffer));

std::shared_ptr<ResizableBuffer> host_buffer;
ASSERT_OK(test::MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));
ASSERT_OK(MakeRandomByteBuffer(kSize, default_memory_pool(), &host_buffer));
ASSERT_OK(device_buffer->CopyFromHost(0, host_buffer->data(), kSize));

// Export for IPC and serialize
Expand Down Expand Up @@ -172,7 +172,7 @@ class TestCudaBufferWriter : public TestCudaBufferBase {
void TestWrites(const int64_t total_bytes, const int64_t chunksize,
const int64_t buffer_size = 0) {
std::shared_ptr<ResizableBuffer> buffer;
ASSERT_OK(test::MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer));
ASSERT_OK(MakeRandomByteBuffer(total_bytes, default_memory_pool(), &buffer));

if (buffer_size > 0) {
ASSERT_OK(writer_->SetBufferSize(buffer_size));
Expand Down Expand Up @@ -223,7 +223,7 @@ TEST_F(TestCudaBufferWriter, EdgeCases) {
Allocate(1000);

std::shared_ptr<ResizableBuffer> buffer;
ASSERT_OK(test::MakeRandomByteBuffer(1000, default_memory_pool(), &buffer));
ASSERT_OK(MakeRandomByteBuffer(1000, default_memory_pool(), &buffer));
const uint8_t* host_data = buffer->data();

ASSERT_EQ(0, writer_->buffer_size());
Expand Down Expand Up @@ -274,7 +274,7 @@ TEST_F(TestCudaBufferReader, Basics) {
ASSERT_OK(context_->Allocate(size, &device_buffer));

std::shared_ptr<ResizableBuffer> buffer;
ASSERT_OK(test::MakeRandomByteBuffer(1000, default_memory_pool(), &buffer));
ASSERT_OK(MakeRandomByteBuffer(1000, default_memory_pool(), &buffer));
const uint8_t* host_data = buffer->data();

ASSERT_OK(device_buffer->CopyFromHost(0, host_data, 1000));
Expand Down
Loading