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
12 changes: 6 additions & 6 deletions dev/benchmarks/c/array_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void BenchmarkArrayViewGetString(benchmark::State& state) {

int64_t n_alphabets = n_values / alphabet.size() + 1;
std::vector<char> data(alphabet.size() * n_alphabets);
for (int64_t data_pos = 0; data_pos < data.size(); data_pos += alphabet.size()) {
for (size_t data_pos = 0; data_pos < data.size(); data_pos += alphabet.size()) {
memcpy(data.data() + data_pos, alphabet.data(), alphabet.size());
}

Expand Down Expand Up @@ -262,7 +262,7 @@ static ArrowErrorCode CreateAndAppendToArrayInt(ArrowArray* array,
NANOARROW_RETURN_NOT_OK(ArrowArrayInitFromType(array, type));
NANOARROW_RETURN_NOT_OK(ArrowArrayStartAppending(array));

for (int64_t i = 0; i < values.size(); i++) {
for (size_t i = 0; i < values.size(); i++) {
NANOARROW_RETURN_NOT_OK(ArrowArrayAppendInt(array, values[i]));
}

Expand All @@ -289,11 +289,11 @@ static ArrowErrorCode CreateAndAppendToArrayString(
static void BenchmarkArrayAppendString(benchmark::State& state) {
nanoarrow::UniqueArray array;

int64_t n_values = kNumItemsPrettyBig;
int64_t value_size = 7;
const int64_t n_values = kNumItemsPrettyBig;
const size_t value_size = 7;

std::vector<std::string> values(n_values);
int64_t alphabet_pos = 0;
size_t alphabet_pos = 0;
for (std::string& value : values) {
if ((alphabet_pos + value_size) >= kAlphabet.size()) {
alphabet_pos = 0;
Expand Down Expand Up @@ -361,7 +361,7 @@ static ArrowErrorCode CreateAndAppendIntWithNulls(ArrowArray* array,
NANOARROW_RETURN_NOT_OK(ArrowArrayStartAppending(array));
CType non_null_value = std::numeric_limits<CType>::max() / 2;

for (int64_t i = 0; i < validity.size(); i++) {
for (size_t i = 0; i < validity.size(); i++) {
if (validity[i]) {
NANOARROW_RETURN_NOT_OK(ArrowArrayAppendInt(array, non_null_value));
} else {
Expand Down
9 changes: 6 additions & 3 deletions src/nanoarrow/buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
static uint8_t* TestAllocatorReallocate(struct ArrowBufferAllocator* allocator,
uint8_t* ptr, int64_t old_size,
int64_t new_size) {
NANOARROW_UNUSED(allocator);
uint8_t* new_ptr = reinterpret_cast<uint8_t*>(malloc(new_size));

int64_t copy_size = std::min<int64_t>(old_size, new_size);
Expand All @@ -45,6 +46,8 @@ static uint8_t* TestAllocatorReallocate(struct ArrowBufferAllocator* allocator,

static void TestAllocatorFree(struct ArrowBufferAllocator* allocator, uint8_t* ptr,
int64_t size) {
NANOARROW_UNUSED(allocator);
NANOARROW_UNUSED(size);
free(ptr);
}

Expand Down Expand Up @@ -168,7 +171,7 @@ TEST(BufferTest, BufferTestError) {
ArrowBufferInit(&buffer);
EXPECT_EQ(ArrowBufferResize(&buffer, std::numeric_limits<int64_t>::max(), false),
ENOMEM);
EXPECT_EQ(ArrowBufferAppend(&buffer, nullptr, std::numeric_limits<int64_t>::max()),
EXPECT_EQ(ArrowBufferAppend(nullptr, nullptr, std::numeric_limits<int64_t>::max()),
ENOMEM);

ASSERT_EQ(ArrowBufferAppend(&buffer, "abcd", 4), NANOARROW_OK);
Expand Down Expand Up @@ -241,7 +244,7 @@ TEST(BitmapTest, BitmapTestElement) {
uint8_t bitmap[10];

memset(bitmap, 0xff, sizeof(bitmap));
for (int i = 0; i < sizeof(bitmap) * 8; i++) {
for (size_t i = 0; i < sizeof(bitmap) * 8; i++) {
EXPECT_EQ(ArrowBitGet(bitmap, i), 1);
}

Expand All @@ -256,7 +259,7 @@ TEST(BitmapTest, BitmapTestElement) {
EXPECT_EQ(ArrowBitGet(bitmap, 16 + 7), 1);

memset(bitmap, 0x00, sizeof(bitmap));
for (int i = 0; i < sizeof(bitmap) * 8; i++) {
for (size_t i = 0; i < sizeof(bitmap) * 8; i++) {
EXPECT_EQ(ArrowBitGet(bitmap, i), 0);
}

Expand Down
2 changes: 2 additions & 0 deletions src/nanoarrow/integration/c_data_integration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static int64_t kBytesAllocated = 0;

static uint8_t* IntegrationTestReallocate(ArrowBufferAllocator* allocator, uint8_t* ptr,
int64_t old_size, int64_t new_size) {
NANOARROW_UNUSED(allocator);
ArrowBufferAllocator default_allocator = ArrowBufferAllocatorDefault();
kBytesAllocated -= old_size;
uint8_t* out =
Expand All @@ -41,6 +42,7 @@ static uint8_t* IntegrationTestReallocate(ArrowBufferAllocator* allocator, uint8

static void IntegrationTestFree(struct ArrowBufferAllocator* allocator, uint8_t* ptr,
int64_t size) {
NANOARROW_UNUSED(allocator);
ArrowBufferAllocator default_allocator = ArrowBufferAllocatorDefault();
kBytesAllocated -= size;
default_allocator.free(&default_allocator, ptr, size);
Expand Down
2 changes: 2 additions & 0 deletions src/nanoarrow/nanoarrow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class Unique {
template <typename T>
static inline void DeallocateWrappedBuffer(struct ArrowBufferAllocator* allocator,
uint8_t* ptr, int64_t size) {
NANOARROW_UNUSED(ptr);
NANOARROW_UNUSED(size);
auto obj = reinterpret_cast<T*>(allocator->private_data);
delete obj;
}
Expand Down
21 changes: 13 additions & 8 deletions src/nanoarrow/nanoarrow_testing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ class TestingJSONReader {
} else if (num_batch == kNumBatchReadAll) {
batch_ids.resize(batches.size());
std::iota(batch_ids.begin(), batch_ids.end(), 0);
} else if (num_batch >= 0 && num_batch < batches.size()) {
} else if (num_batch >= 0 && static_cast<size_t>(num_batch) < batches.size()) {
batch_ids.push_back(num_batch);
} else {
ArrowErrorSet(error, "Expected num_batch between 0 and %d but got %d",
Expand Down Expand Up @@ -1887,8 +1887,9 @@ class TestingJSONReader {
const auto& columns = value["columns"];
NANOARROW_RETURN_NOT_OK(
Check(columns.is_array(), error, "RecordBatch columns must be array"));
NANOARROW_RETURN_NOT_OK(Check(columns.size() == array_view->n_children, error,
"RecordBatch children has incorrect size"));
NANOARROW_RETURN_NOT_OK(Check(
columns.size() == static_cast<decltype(columns.size())>(array_view->n_children),
error, "RecordBatch children has incorrect size"));

for (int64_t i = 0; i < array_view->n_children; i++) {
NANOARROW_RETURN_NOT_OK(SetArrayColumn(columns[i], schema->children[i],
Expand Down Expand Up @@ -1987,8 +1988,10 @@ class TestingJSONReader {
const auto& children = value["children"];
NANOARROW_RETURN_NOT_OK(
Check(children.is_array(), error, error_prefix + "children must be array"));
NANOARROW_RETURN_NOT_OK(Check(children.size() == array_view->n_children, error,
error_prefix + "children has incorrect size"));
NANOARROW_RETURN_NOT_OK(
Check(children.size() ==
static_cast<decltype(children.size())>(array_view->n_children),
error, error_prefix + "children has incorrect size"));

for (int64_t i = 0; i < array_view->n_children; i++) {
NANOARROW_RETURN_NOT_OK(SetArrayColumn(children[i], schema->children[i],
Expand Down Expand Up @@ -2272,7 +2275,8 @@ class TestingJSONReader {
// Check offsets against values
const T* expected_offset = reinterpret_cast<const T*>(offsets->data);
NANOARROW_RETURN_NOT_OK(Check(
offsets->size_bytes == ((value.size() + 1) * sizeof(T)), error,
static_cast<size_t>(offsets->size_bytes) == ((value.size() + 1) * sizeof(T)),
error,
"Expected offset buffer with " + std::to_string(value.size()) + " elements"));
NANOARROW_RETURN_NOT_OK(
Check(*expected_offset++ == 0, error, "first offset must be zero"));
Expand Down Expand Up @@ -2310,7 +2314,8 @@ class TestingJSONReader {
// Check offsets against values if not fixed size
const T* expected_offset = reinterpret_cast<const T*>(offsets->data);
NANOARROW_RETURN_NOT_OK(Check(
offsets->size_bytes == ((value.size() + 1) * sizeof(T)), error,
static_cast<size_t>(offsets->size_bytes) == ((value.size() + 1) * sizeof(T)),
error,
"Expected offset buffer with " + std::to_string(value.size()) + " elements"));
NANOARROW_RETURN_NOT_OK(
Check(*expected_offset++ == 0, error, "first offset must be zero"));
Expand Down Expand Up @@ -2355,7 +2360,7 @@ class TestingJSONReader {
Check(item.is_string(), error, "binary data buffer item must be string"));
auto item_str = item.get<std::string>();

int64_t item_size_bytes = item_str.size() / 2;
size_t item_size_bytes = item_str.size() / 2;
NANOARROW_RETURN_NOT_OK(Check((item_size_bytes * 2) == item_str.size(), error,
"binary data buffer item must have even size"));

Expand Down
Loading