Skip to content

Commit

Permalink
ARROW-3289: [C++] Implement Flight DoPut
Browse files Browse the repository at this point in the history
Implements server/client side DoPut in C++ and extends the integration tests to exercise this.

We may want a different API for client-side DoPut that exposes any potential server response; I made it give the client a RecordBatchWriter to be symmetric with DoGet for now though.

Author: David Li <[email protected]>

Closes apache#3524 from lihalite/arrow-3289 and squashes the following commits:

13fb29a <David Li> Document why VectorUnloader must align batches in Flight
f32c0b2 <David Li> Indicate error to client in DoPut if no message sent
cd56782 <David Li> Warn about undefined behavior in Flight source
1f816e8 <David Li> Move serialization helpers out of gRPC namespace
21b315a <David Li> Hide FlightPutWriter from public interface for now
6edf2e2 <David Li> Introduce FlightPutWriter
58d6936 <David Li> Enable building with non-CMake c-ares
cfa4ca5 <David Li> Properly quote arguments to gRPC CMake build
302dd33 <David Li> Explicitly link Protobuf for Flight
419ad68 <David Li> Log (de)serialization failures in Flight fast-path
562b861 <David Li> Factor out FlightData->Message conversion
65d6ba2 <David Li> Clean up C++ Flight integration client
3e185cb <David Li>  Add convenience to parse JSON from file
111b3e6 <David Li> Fix style/lint issues
3cb51ba <David Li> Test all returned locations in Flight integration tests
905ef38 <David Li> Implement C++ Flight DoPut
138141f <David Li> Fix FromProto for FlightDescriptor
a11a5ac <David Li> Don't hang in Flight DoPut if server sends exception
b3ac01a <David Li> Align RecordBatch on client side in Flight DoPut
846df73 <David Li> Implement put in Java Flight integration server
  • Loading branch information
David Li authored and xhochy committed Feb 8, 2019
1 parent 716fd1f commit 842fdd8
Show file tree
Hide file tree
Showing 21 changed files with 1,039 additions and 569 deletions.
108 changes: 108 additions & 0 deletions cpp/cmake_modules/Findc-ares.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#
# Licensed 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.
#
# Tries to find c-ares headers and libraries.
#
# Usage of this module as follows:
#
# find_package(c-ares)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# CARES_HOME - When set, this path is inspected instead of standard library
# locations as the root of the c-ares installation.
# The environment variable CARES_HOME overrides this variable.
#
# - Find CARES
# This module defines
# CARES_INCLUDE_DIR, directory containing headers
# CARES_SHARED_LIB, path to c-ares's shared library
# CARES_FOUND, whether c-ares has been found

if( NOT "${CARES_HOME}" STREQUAL "")
file( TO_CMAKE_PATH "${CARES_HOME}" _native_path )
list( APPEND _cares_roots ${_native_path} )
elseif ( CARES_HOME )
list( APPEND _cares_roots ${CARES_HOME} )
endif()

if (MSVC)
set(CARES_LIB_NAME cares.lib)
else ()
set(CARES_LIB_NAME
${CMAKE_SHARED_LIBRARY_PREFIX}cares${CMAKE_SHARED_LIBRARY_SUFFIX})
set(CARES_STATIC_LIB_NAME
${CMAKE_STATIC_LIBRARY_PREFIX}cares${CMAKE_STATIC_LIBRARY_SUFFIX})
endif ()

# Try the parameterized roots, if they exist
if (_cares_roots)
find_path(CARES_INCLUDE_DIR NAMES ares.h
PATHS ${_cares_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "include")
find_library(CARES_SHARED_LIB
NAMES ${CARES_LIB_NAME}
PATHS ${_cares_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "lib")
find_library(CARES_STATIC_LIB
NAMES ${CARES_STATIC_LIB_NAME}
PATHS ${_cares_roots} NO_DEFAULT_PATH
PATH_SUFFIXES "lib")
else ()
pkg_check_modules(PKG_CARES cares)
if (PKG_CARES_FOUND)
set(CARES_INCLUDE_DIR ${PKG_CARES_INCLUDEDIR})
find_library(CARES_SHARED_LIB
NAMES ${CARES_LIB_NAME}
PATHS ${PKG_CARES_LIBDIR} NO_DEFAULT_PATH)
else ()
find_path(CARES_INCLUDE_DIR NAMES cares.h)
find_library(CARES_SHARED_LIB NAMES ${CARES_LIB_NAME})
endif ()
endif ()

if (CARES_INCLUDE_DIR AND CARES_SHARED_LIB)
set(CARES_FOUND TRUE)
else ()
set(CARES_FOUND FALSE)
endif ()

if (CARES_FOUND)
if (NOT CARES_FIND_QUIETLY)
if (CARES_SHARED_LIB)
message(STATUS "Found the c-ares shared library: ${CARES_SHARED_LIB}")
endif ()
endif ()
else ()
if (NOT CARES_FIND_QUIETLY)
set(CARES_ERR_MSG "Could not find the c-ares library. Looked in ")
if ( _cares_roots )
set(CARES_ERR_MSG "${CARES_ERR_MSG} ${_cares_roots}.")
else ()
set(CARES_ERR_MSG "${CARES_ERR_MSG} system search paths.")
endif ()
if (CARES_FIND_REQUIRED)
message(FATAL_ERROR "${CARES_ERR_MSG}")
else (CARES_FIND_REQUIRED)
message(STATUS "${CARES_ERR_MSG}")
endif (CARES_FIND_REQUIRED)
endif ()
endif ()

mark_as_advanced(
CARES_INCLUDE_DIR
CARES_LIBRARIES
CARES_SHARED_LIB
CARES_STATIC_LIB
)
25 changes: 10 additions & 15 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1347,12 +1347,7 @@ if (ARROW_WITH_GRPC)
BUILD_BYPRODUCTS "${CARES_STATIC_LIB}")
else()
set(CARES_VENDORED 0)
find_package(c-ares REQUIRED
PATHS ${CARES_HOME}
NO_DEFAULT_PATH)
if(TARGET c-ares::cares)
get_property(CARES_STATIC_LIB TARGET c-ares::cares_static PROPERTY LOCATION)
endif()
find_package(c-ares REQUIRED)
endif()
message(STATUS "c-ares library: ${CARES_STATIC_LIB}")

Expand Down Expand Up @@ -1406,15 +1401,15 @@ if (ARROW_WITH_GRPC)

set(GRPC_CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_PREFIX_PATH="${GRPC_PREFIX_PATH_ALT_SEP}"
"-DgRPC_CARES_PROVIDER=package"
"-DgRPC_GFLAGS_PROVIDER=package"
"-DgRPC_PROTOBUF_PROVIDER=package"
"-DgRPC_SSL_PROVIDER=package"
"-DgRPC_ZLIB_PROVIDER=package"
"-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}"
"-DCMAKE_C_FLAGS=${EP_C_FLAGS}"
"-DCMAKE_INSTALL_PREFIX=${GRPC_PREFIX}"
-DCMAKE_PREFIX_PATH='${GRPC_PREFIX_PATH_ALT_SEP}'
'-DgRPC_CARES_PROVIDER=package'
'-DgRPC_GFLAGS_PROVIDER=package'
'-DgRPC_PROTOBUF_PROVIDER=package'
'-DgRPC_SSL_PROVIDER=package'
'-DgRPC_ZLIB_PROVIDER=package'
'-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}'
'-DCMAKE_C_FLAGS=${EP_C_FLAGS}'
'-DCMAKE_INSTALL_PREFIX=${GRPC_PREFIX}'
-DCMAKE_INSTALL_LIBDIR=lib
-DBUILD_SHARED_LIBS=OFF)

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_custom_target(arrow_flight)
ARROW_INSTALL_ALL_HEADERS("arrow/flight")

SET(ARROW_FLIGHT_STATIC_LINK_LIBS
protobuf_static
grpc_grpcpp_static
grpc_grpc_static
grpc_gpr_static
Expand Down Expand Up @@ -69,6 +70,7 @@ set(ARROW_FLIGHT_SRCS
Flight.pb.cc
Flight.grpc.pb.cc
internal.cc
serialization-internal.cc
server.cc
types.cc
)
Expand Down
Loading

0 comments on commit 842fdd8

Please sign in to comment.