You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/06/14 12:06:17 UTC

[arrow-adbc] branch main updated: chore(c): Changed import to common/util (#783)

This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 61505ac0 chore(c): Changed import to common/util (#783)
61505ac0 is described below

commit 61505ac066e0d09ea1372ba27ec0fdc36abdce54
Author: William Ayd <wi...@icloud.com>
AuthorDate: Wed Jun 14 05:06:11 2023 -0700

    chore(c): Changed import to common/util (#783)
---
 c/driver/common/CMakeLists.txt                               |  6 ++++--
 c/driver/flightsql/CMakeLists.txt                            |  2 +-
 c/driver/postgresql/CMakeLists.txt                           |  2 +-
 c/driver/postgresql/connection.cc                            |  2 +-
 c/driver/postgresql/database.cc                              |  2 +-
 c/driver/postgresql/postgresql.cc                            |  2 +-
 c/driver/postgresql/postgresql_test.cc                       |  2 +-
 c/driver/postgresql/statement.cc                             |  2 +-
 c/driver/postgresql/statement.h                              |  2 +-
 c/driver/snowflake/CMakeLists.txt                            |  1 +
 c/driver/sqlite/CMakeLists.txt                               |  2 +-
 c/driver/sqlite/sqlite.c                                     |  2 +-
 c/driver/sqlite/statement_reader.c                           |  2 +-
 c/driver_manager/CMakeLists.txt                              |  2 +-
 c/validation/CMakeLists.txt                                  |  3 +--
 c/validation/adbc_validation_util.h                          |  2 +-
 c/vendor/nanoarrow/nanoarrow.h                               | 11 +++++++----
 r/adbcpostgresql/bootstrap.R                                 | 12 ++++++++++--
 r/adbcpostgresql/cleanup                                     |  2 +-
 r/adbcpostgresql/src/.gitignore                              |  2 --
 r/adbcpostgresql/src/Makevars.in                             |  2 +-
 r/adbcpostgresql/src/Makevars.ucrt                           |  2 +-
 r/adbcpostgresql/src/Makevars.win                            |  2 +-
 .../cleanup => adbcpostgresql/src/common/.gitignore}         |  3 ++-
 r/adbcsqlite/bootstrap.R                                     |  6 ++++--
 r/adbcsqlite/cleanup                                         |  2 +-
 r/adbcsqlite/src/Makevars.in                                 |  2 +-
 r/adbcsqlite/{cleanup => src/common/.gitignore}              |  3 ++-
 28 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/c/driver/common/CMakeLists.txt b/c/driver/common/CMakeLists.txt
index 60516b6c..33dd1c8d 100644
--- a/c/driver/common/CMakeLists.txt
+++ b/c/driver/common/CMakeLists.txt
@@ -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
@@ -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()
diff --git a/c/driver/flightsql/CMakeLists.txt b/c/driver/flightsql/CMakeLists.txt
index 7384663a..b20a3e71 100644
--- a/c/driver/flightsql/CMakeLists.txt
+++ b/c/driver/flightsql/CMakeLists.txt
@@ -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")
@@ -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
diff --git a/c/driver/postgresql/CMakeLists.txt b/c/driver/postgresql/CMakeLists.txt
index 1b71d602..d1697941 100644
--- a/c/driver/postgresql/CMakeLists.txt
+++ b/c/driver/postgresql/CMakeLists.txt
@@ -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)
diff --git a/c/driver/postgresql/connection.cc b/c/driver/postgresql/connection.cc
index c69c3403..22451218 100644
--- a/c/driver/postgresql/connection.cc
+++ b/c/driver/postgresql/connection.cc
@@ -29,8 +29,8 @@
 #include <adbc.h>
 #include <libpq-fe.h>
 
+#include "common/utils.h"
 #include "database.h"
-#include "utils.h"
 
 namespace {
 
diff --git a/c/driver/postgresql/database.cc b/c/driver/postgresql/database.cc
index 1d9bd414..3976c4b0 100644
--- a/c/driver/postgresql/database.cc
+++ b/c/driver/postgresql/database.cc
@@ -27,7 +27,7 @@
 #include <libpq-fe.h>
 #include <nanoarrow/nanoarrow.h>
 
-#include "utils.h"
+#include "common/utils.h"
 
 namespace adbcpq {
 
diff --git a/c/driver/postgresql/postgresql.cc b/c/driver/postgresql/postgresql.cc
index 51f152ac..29fd04cd 100644
--- a/c/driver/postgresql/postgresql.cc
+++ b/c/driver/postgresql/postgresql.cc
@@ -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;
diff --git a/c/driver/postgresql/postgresql_test.cc b/c/driver/postgresql/postgresql_test.cc
index 409df8e3..fe1eb3fc 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -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"
diff --git a/c/driver/postgresql/statement.cc b/c/driver/postgresql/statement.cc
index 87431304..c9836751 100644
--- a/c/driver/postgresql/statement.cc
+++ b/c/driver/postgresql/statement.cc
@@ -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 {
 
diff --git a/c/driver/postgresql/statement.h b/c/driver/postgresql/statement.h
index 5629323c..0ff6cb89 100644
--- a/c/driver/postgresql/statement.h
+++ b/c/driver/postgresql/statement.h
@@ -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;
diff --git a/c/driver/snowflake/CMakeLists.txt b/c/driver/snowflake/CMakeLists.txt
index 9874f2b2..ca6c121e 100644
--- a/c/driver/snowflake/CMakeLists.txt
+++ b/c/driver/snowflake/CMakeLists.txt
@@ -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")
diff --git a/c/driver/sqlite/CMakeLists.txt b/c/driver/sqlite/CMakeLists.txt
index 2bec53ed..eb5a8453 100644
--- a/c/driver/sqlite/CMakeLists.txt
+++ b/c/driver/sqlite/CMakeLists.txt
@@ -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})
diff --git a/c/driver/sqlite/sqlite.c b/c/driver/sqlite/sqlite.c
index d671bc75..1eacbf39 100644
--- a/c/driver/sqlite/sqlite.c
+++ b/c/driver/sqlite/sqlite.c
@@ -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)
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index d9a0823f..504a4d80 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -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) {
diff --git a/c/driver_manager/CMakeLists.txt b/c/driver_manager/CMakeLists.txt
index e062b113..eb5a8640 100644
--- a/c/driver_manager/CMakeLists.txt
+++ b/c/driver_manager/CMakeLists.txt
@@ -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)
diff --git a/c/validation/CMakeLists.txt b/c/validation/CMakeLists.txt
index 714321ff..a7cacd60 100644
--- a/c/validation/CMakeLists.txt
+++ b/c/validation/CMakeLists.txt
@@ -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)
diff --git a/c/validation/adbc_validation_util.h b/c/validation/adbc_validation_util.h
index 3c082b6f..a239e769 100644
--- a/c/validation/adbc_validation_util.h
+++ b/c/validation/adbc_validation_util.h
@@ -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 {
 
diff --git a/c/vendor/nanoarrow/nanoarrow.h b/c/vendor/nanoarrow/nanoarrow.h
index 6bd71f05..759c969b 100644
--- a/c/vendor/nanoarrow/nanoarrow.h
+++ b/c/vendor/nanoarrow/nanoarrow.h
@@ -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_) \
+  NANOARROW_RETURN_NOT_OK((x_ <= max_) ? NANOARROW_OK : EINVAL)
+
 /// \brief Return code for success.
 /// \ingroup nanoarrow-errors
 #define NANOARROW_OK 0
@@ -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));
diff --git a/r/adbcpostgresql/bootstrap.R b/r/adbcpostgresql/bootstrap.R
index 64687a87..1b9b84e6 100644
--- a/r/adbcpostgresql/bootstrap.R
+++ b/r/adbcpostgresql/bootstrap.R
@@ -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")
diff --git a/r/adbcpostgresql/cleanup b/r/adbcpostgresql/cleanup
index a940f2da..4dc79687 100755
--- a/r/adbcpostgresql/cleanup
+++ b/r/adbcpostgresql/cleanup
@@ -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
diff --git a/r/adbcpostgresql/src/.gitignore b/r/adbcpostgresql/src/.gitignore
index ee58a5e3..34dd9749 100644
--- a/r/adbcpostgresql/src/.gitignore
+++ b/r/adbcpostgresql/src/.gitignore
@@ -29,6 +29,4 @@ statement.cc
 postgres_type.h
 postgres_copy_reader.h
 postgres_util.h
-utils.h
-utils.c
 Makevars
diff --git a/r/adbcpostgresql/src/Makevars.in b/r/adbcpostgresql/src/Makevars.in
index cba36c46..f90db0cb 100644
--- a/r/adbcpostgresql/src/Makevars.in
+++ b/r/adbcpostgresql/src/Makevars.in
@@ -22,6 +22,6 @@ OBJECTS = init.o \
     connection.o \
     database.o \
     statement.o \
-    utils.o \
+    common/utils.o \
     postgresql.o \
     nanoarrow/nanoarrow.o
diff --git a/r/adbcpostgresql/src/Makevars.ucrt b/r/adbcpostgresql/src/Makevars.ucrt
index 5194f14a..ebdc16fb 100644
--- a/r/adbcpostgresql/src/Makevars.ucrt
+++ b/r/adbcpostgresql/src/Makevars.ucrt
@@ -22,6 +22,6 @@ OBJECTS = init.o \
     connection.o \
     database.o \
     statement.o \
-    utils.o \
     postgresql.o \
+    common/utils.o \
     nanoarrow/nanoarrow.o
diff --git a/r/adbcpostgresql/src/Makevars.win b/r/adbcpostgresql/src/Makevars.win
index 59068c8f..0f039305 100644
--- a/r/adbcpostgresql/src/Makevars.win
+++ b/r/adbcpostgresql/src/Makevars.win
@@ -25,8 +25,8 @@ OBJECTS = init.o \
     connection.o \
     database.o \
     statement.o \
-    utils.o \
     postgresql.o \
+    common/utils.o \
     nanoarrow/nanoarrow.o
 
 $(SHLIB):
diff --git a/r/adbcsqlite/cleanup b/r/adbcpostgresql/src/common/.gitignore
old mode 100755
new mode 100644
similarity index 95%
copy from r/adbcsqlite/cleanup
copy to r/adbcpostgresql/src/common/.gitignore
index a940f2da..4c355d6b
--- a/r/adbcsqlite/cleanup
+++ b/r/adbcpostgresql/src/common/.gitignore
@@ -15,4 +15,5 @@
 # specific language governing permissions and limitations
 # under the License.
 
-rm src/*.o src/nanoarrow/*.o || true
+utils.c
+utils.h
diff --git a/r/adbcsqlite/bootstrap.R b/r/adbcsqlite/bootstrap.R
index 53d72cbf..0bda3275 100644
--- a/r/adbcsqlite/bootstrap.R
+++ b/r/adbcsqlite/bootstrap.R
@@ -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 {
diff --git a/r/adbcsqlite/cleanup b/r/adbcsqlite/cleanup
index a940f2da..4dc79687 100755
--- a/r/adbcsqlite/cleanup
+++ b/r/adbcsqlite/cleanup
@@ -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
diff --git a/r/adbcsqlite/src/Makevars.in b/r/adbcsqlite/src/Makevars.in
index 512f8533..81a9b749 100644
--- a/r/adbcsqlite/src/Makevars.in
+++ b/r/adbcsqlite/src/Makevars.in
@@ -21,5 +21,5 @@ PKG_LIBS=@libs@
 OBJECTS = init.o \
     sqlite.o \
     statement_reader.o \
-    utils.o \
+    common/utils.o \
     nanoarrow/nanoarrow.o @objects@
diff --git a/r/adbcsqlite/cleanup b/r/adbcsqlite/src/common/.gitignore
old mode 100755
new mode 100644
similarity index 95%
copy from r/adbcsqlite/cleanup
copy to r/adbcsqlite/src/common/.gitignore
index a940f2da..4c355d6b
--- a/r/adbcsqlite/cleanup
+++ b/r/adbcsqlite/src/common/.gitignore
@@ -15,4 +15,5 @@
 # specific language governing permissions and limitations
 # under the License.
 
-rm src/*.o src/nanoarrow/*.o || true
+utils.c
+utils.h