Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(c): Changed import to common/util #783

Merged
merged 10 commits into from
Jun 14, 2023
Merged
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
6 changes: 4 additions & 2 deletions c/driver/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

add_library(adbc_driver_common STATIC utils.c)
set_target_properties(adbc_driver_common PROPERTIES POSITION_INDEPENDENT_CODE ON)
include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)
target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}"
"${REPOSITORY_ROOT}/c/vendor")

if(ADBC_BUILD_TESTS)
add_test_case(driver_common_test
Expand All @@ -32,5 +32,7 @@ if(ADBC_BUILD_TESTS)
adbc_driver_common
nanoarrow)
target_compile_features(adbc-driver-common-test PRIVATE cxx_std_17)
target_include_directories(adbc-driver-common-test
PRIVATE "${REPOSITORY_ROOT}" "${REPOSITORY_ROOT}/c/vendor")
adbc_configure_target(adbc-driver-common-test)
endif()
2 changes: 1 addition & 1 deletion c/driver/flightsql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/flightsql/"

include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)

if(ADBC_TEST_LINKAGE STREQUAL "shared")
Expand All @@ -42,7 +43,6 @@ else()
endif()

if(ADBC_BUILD_TESTS)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver/common)
add_test_case(driver_flightsql_test
PREFIX
adbc
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
include_directories(SYSTEM ${LIBPQ_INCLUDE_DIRS})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver/common)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver)

foreach(LIB_TARGET ${ADBC_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING)
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include <adbc.h>
#include <libpq-fe.h>

#include "common/utils.h"
#include "database.h"
#include "utils.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <libpq-fe.h>
#include <nanoarrow/nanoarrow.h>

#include "utils.h"
#include "common/utils.h"

namespace adbcpq {

Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/postgresql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

#include <adbc.h>

#include "common/utils.h"
#include "connection.h"
#include "database.h"
#include "statement.h"
#include "utils.h"

using adbcpq::PostgresConnection;
using adbcpq::PostgresDatabase;
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/postgresql_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <gtest/gtest-param-test.h>
#include <gtest/gtest.h>
#include <nanoarrow/nanoarrow.h>
#include <utils.h>
#include "common/utils.h"

#include "validation/adbc_validation.h"
#include "validation/adbc_validation_util.h"
Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#include <libpq-fe.h>
#include <nanoarrow/nanoarrow.hpp>

#include "common/utils.h"
#include "connection.h"
#include "postgres_copy_reader.h"
#include "postgres_type.h"
#include "postgres_util.h"
#include "utils.h"

namespace adbcpq {

Expand Down
2 changes: 1 addition & 1 deletion c/driver/postgresql/statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <libpq-fe.h>
#include <nanoarrow/nanoarrow.h>

#include "common/utils.h"
#include "postgres_copy_reader.h"
#include "postgres_type.h"
#include "utils.h"

namespace adbcpq {
class PostgresConnection;
Expand Down
1 change: 1 addition & 0 deletions c/driver/snowflake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/snowflake/"

include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)

if(ADBC_TEST_LINKAGE STREQUAL "shared")
Expand Down
2 changes: 1 addition & 1 deletion c/driver/sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ add_arrow_lib(adbc_driver_sqlite
include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver/common)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver)
include_directories(SYSTEM ${SQLite3_INCLUDE_DIRS})

foreach(LIB_TARGET ${ADBC_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion c/driver/sqlite/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <nanoarrow/nanoarrow.h>
#include <sqlite3.h>

#include "common/utils.h"
#include "statement_reader.h"
#include "types.h"
#include "utils.h"

static const char kDefaultUri[] = "file:adbc_driver_sqlite?mode=memory&cache=shared";
// The batch size for query results (and for initial type inference)
Expand Down
2 changes: 1 addition & 1 deletion c/driver/sqlite/statement_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <nanoarrow/nanoarrow.h>
#include <sqlite3.h>

#include "utils.h"
#include "common/utils.h"

AdbcStatusCode AdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
struct AdbcError* error) {
Expand Down
2 changes: 1 addition & 1 deletion c/driver_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_arrow_lib(adbc_driver_manager
include_directories(SYSTEM ${REPOSITORY_ROOT})
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/vendor)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver/common)
include_directories(SYSTEM ${REPOSITORY_ROOT}/c/driver)

foreach(LIB_TARGET ${ADBC_LIBRARIES})
target_compile_definitions(${LIB_TARGET} PRIVATE ADBC_EXPORTING)
Expand Down
3 changes: 1 addition & 2 deletions c/validation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
add_library(adbc_validation OBJECT adbc_validation.cc adbc_validation_util.cc)
target_compile_features(adbc_validation PRIVATE cxx_std_17)
target_include_directories(adbc_validation SYSTEM
PRIVATE "${REPOSITORY_ROOT}"
"${REPOSITORY_ROOT}/c/driver/common"
PRIVATE "${REPOSITORY_ROOT}" "${REPOSITORY_ROOT}/c/driver/"
"${REPOSITORY_ROOT}/c/vendor/")
target_link_libraries(adbc_validation PUBLIC nanoarrow GTest::gtest GTest::gmock)
2 changes: 1 addition & 1 deletion c/validation/adbc_validation_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <nanoarrow/nanoarrow.h>
#include "utils.h"
#include "common/utils.h"

namespace adbc_validation {

Expand Down
11 changes: 7 additions & 4 deletions c/vendor/nanoarrow/nanoarrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ static inline void ArrowArrayStreamMove(struct ArrowArrayStream* src,
#define _NANOARROW_CHECK_RANGE(x_, min_, max_) \
NANOARROW_RETURN_NOT_OK((x_ >= min_ && x_ <= max_) ? NANOARROW_OK : EINVAL)

#define _NANOARROW_CHECK_UPPER_LIMIT(x_, max_) \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this was getting errors like:

/home/willayd/clones/arrow-adbc/c/vendor/nanoarrow/nanoarrow.h:192:31: error: comparison of unsigned expression in ‘>= 0is always true [-Werror=type-limits]
  192 |   NANOARROW_RETURN_NOT_OK((x_ >= min_ && x_ <= max_) ? NANOARROW_OK : EINVAL)
      |                               ^
/home/willayd/clones/arrow-adbc/c/vendor/nanoarrow/nanoarrow.h:187:23: note: in definition of macro_NANOARROW_RETURN_NOT_OK_IMPL187 |     const int NAME = (EXPR);                      \
      |                       ^~~~
/home/willayd/clones/arrow-adbc/c/vendor/nanoarrow/nanoarrow.h:192:3: note: in expansion of macroNANOARROW_RETURN_NOT_OK192 |   NANOARROW_RETURN_NOT_OK((x_ >= min_ && x_ <= max_) ? NANOARROW_OK : EINVAL)
      |   ^~~~~~~~~~~~~~~~~~~~~~~
/home/willayd/clones/arrow-adbc/c/vendor/nanoarrow/nanoarrow.h:2606:7: note: in expansion of macro_NANOARROW_CHECK_RANGE2606 |       _NANOARROW_CHECK_RANGE(value, 0, UINT8_MAX);

which make sense. Not sure why they are appearing now. Need to upstream this in nanoarrow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your other comment here explains why this wasn't producing warnings/errors before

NANOARROW_RETURN_NOT_OK((x_ <= max_) ? NANOARROW_OK : EINVAL)

/// \brief Return code for success.
/// \ingroup nanoarrow-errors
#define NANOARROW_OK 0
Expand Down Expand Up @@ -2595,22 +2598,22 @@ static inline ArrowErrorCode ArrowArrayAppendUInt(struct ArrowArray* array,
NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(data_buffer, &value, sizeof(uint64_t)));
break;
case NANOARROW_TYPE_UINT32:
_NANOARROW_CHECK_RANGE(value, 0, UINT32_MAX);
_NANOARROW_CHECK_UPPER_LIMIT(value, UINT32_MAX);
NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt32(data_buffer, (uint32_t)value));
break;
case NANOARROW_TYPE_UINT16:
_NANOARROW_CHECK_RANGE(value, 0, UINT16_MAX);
_NANOARROW_CHECK_UPPER_LIMIT(value, UINT16_MAX);
NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt16(data_buffer, (uint16_t)value));
break;
case NANOARROW_TYPE_UINT8:
_NANOARROW_CHECK_RANGE(value, 0, UINT8_MAX);
_NANOARROW_CHECK_UPPER_LIMIT(value, UINT8_MAX);
NANOARROW_RETURN_NOT_OK(ArrowBufferAppendUInt8(data_buffer, (uint8_t)value));
break;
case NANOARROW_TYPE_INT64:
case NANOARROW_TYPE_INT32:
case NANOARROW_TYPE_INT16:
case NANOARROW_TYPE_INT8:
_NANOARROW_CHECK_RANGE(value, 0, INT64_MAX);
_NANOARROW_CHECK_UPPER_LIMIT(value, INT64_MAX);
return ArrowArrayAppendInt(array, value);
case NANOARROW_TYPE_DOUBLE:
NANOARROW_RETURN_NOT_OK(ArrowBufferAppendDouble(data_buffer, value));
Expand Down
12 changes: 10 additions & 2 deletions r/adbcpostgresql/bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,19 @@ if (all(file.exists(files_to_vendor))) {

if (all(file.copy(files_to_vendor, "src"))) {
file.rename(
c("src/nanoarrow.c", "src/nanoarrow.h", "src/nanoarrow.hpp"),
c(
"src/nanoarrow.c",
"src/nanoarrow.h",
"src/nanoarrow.hpp",
"src/utils.c",
"src/utils.h"
),
c(
"src/nanoarrow/nanoarrow.c",
"src/nanoarrow/nanoarrow.h",
"src/nanoarrow/nanoarrow.hpp"
"src/nanoarrow/nanoarrow.hpp",
"src/common/utils.c",
"src/common/utils.h"
)
)
cat("All files successfully copied to src/\n")
Expand Down
2 changes: 1 addition & 1 deletion r/adbcpostgresql/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.

rm src/*.o src/nanoarrow/*.o || true
rm src/*.o src/nanoarrow/*.o src/common/*.o || true
2 changes: 0 additions & 2 deletions r/adbcpostgresql/src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ statement.cc
postgres_type.h
postgres_copy_reader.h
postgres_util.h
utils.h
utils.c
Makevars
2 changes: 1 addition & 1 deletion r/adbcpostgresql/src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ OBJECTS = init.o \
connection.o \
database.o \
statement.o \
utils.o \
common/utils.o \
postgresql.o \
nanoarrow/nanoarrow.o
2 changes: 1 addition & 1 deletion r/adbcpostgresql/src/Makevars.ucrt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ OBJECTS = init.o \
connection.o \
database.o \
statement.o \
utils.o \
postgresql.o \
common/utils.o \
nanoarrow/nanoarrow.o
2 changes: 1 addition & 1 deletion r/adbcpostgresql/src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ OBJECTS = init.o \
connection.o \
database.o \
statement.o \
utils.o \
postgresql.o \
common/utils.o \
nanoarrow/nanoarrow.o

$(SHLIB):
Expand Down
19 changes: 19 additions & 0 deletions r/adbcpostgresql/src/common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

utils.c
utils.h
6 changes: 4 additions & 2 deletions r/adbcsqlite/bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ if (all(file.exists(files_to_vendor))) {
if (all(file.copy(files_to_vendor, "src"))) {
file.rename(
c("src/nanoarrow.c", "src/nanoarrow.h",
"src/sqlite3.c", "src/sqlite3.h"),
"src/sqlite3.c", "src/sqlite3.h",
"src/utils.c", "src/utils.h"),
c("src/nanoarrow/nanoarrow.c", "src/nanoarrow/nanoarrow.h",
"tools/sqlite3.c", "tools/sqlite3.h")
"tools/sqlite3.c", "tools/sqlite3.h",
"src/common/utils.c", "src/common/utils.h")
)
cat("All files successfully copied to src/\n")
} else {
Expand Down
2 changes: 1 addition & 1 deletion r/adbcsqlite/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.

rm src/*.o src/nanoarrow/*.o || true
rm src/*.o src/nanoarrow/*.o src/common/*.o || true
2 changes: 1 addition & 1 deletion r/adbcsqlite/src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ PKG_LIBS=@libs@
OBJECTS = init.o \
sqlite.o \
statement_reader.o \
utils.o \
common/utils.o \
nanoarrow/nanoarrow.o @objects@
19 changes: 19 additions & 0 deletions r/adbcsqlite/src/common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

utils.c
utils.h