Skip to content
Open
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
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ project("OceanBase"
HOMEPAGE_URL "https://www.oceanbase.ai"
LANGUAGES CXX C ASM)

option(SEEKDB_COMPACT_GIS
"Optimize template-heavy GIS translation units for binary size" OFF)

option(SEEKDB_ENABLE_GIS_MVT
"Build GIS Mapbox Vector Tile support" ON)

if(NOT SEEKDB_ENABLE_GIS_MVT)
add_compile_definitions(SEEKDB_DISABLE_GIS_MVT=1)
endif()

if(WIN32)
find_program(LLVM_LIB_PROGRAM llvm-lib)
if(LLVM_LIB_PROGRAM)
Expand All @@ -35,6 +45,11 @@ if(FALSE AND ENABLE_DEBUG_LOG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_DEBUG_LOG")
endif()

if (ENABLE_SANITY)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_SANITY")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_SANITY")
endif()

if (OB_BUILD_PACKAGE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOB_BUILD_PACKAGE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOB_BUILD_PACKAGE")
Expand Down
42 changes: 40 additions & 2 deletions deps/oblib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ if (OB_USE_CLANG)
-Wno-vla ${VLA_WARN_FLAG})
endif()
target_compile_options(oblib_base_without_pass INTERFACE ${OBLIB_COMPILE_DEFINITIONS})
if (ENABLE_SANITY)
target_compile_options(oblib_pass
INTERFACE
"$<$<COMPILE_LANGUAGE:CXX>:SHELL:-fpass-plugin=${DEVTOOLS_DIR}/lib64/libsanitypass.so>"
-fno-builtin-memset
-fno-builtin-bzero
-fno-builtin-memcpy
-fno-builtin-memmove
-fno-builtin-memcmp
-fno-builtin-strlen
-fno-builtin-strnlen
-fno-builtin-strcpy
-fno-builtin-strncpy
-fno-builtin-strcmp
-fno-builtin-strncmp
-fno-builtin-strcasecmp
-fno-builtin-strncasecmp
-fno-builtin-vsprintf
-fno-builtin-vsnprintf
-fno-builtin-sprintf
-fno-builtin-snprintf
)
endif()
else()
target_compile_options(oblib_base_without_pass
INTERFACE
Expand Down Expand Up @@ -238,9 +261,18 @@ if(OB_AIO AND OB_AIO STREQUAL "libaio1t64" AND NOT APPLE)
endif()
endif()

set(_oblib_link_protobuf_c TRUE)
if(DEFINED SEEKDB_ENABLE_GIS_MVT AND NOT SEEKDB_ENABLE_GIS_MVT)
set(_oblib_link_protobuf_c FALSE)
endif()

if(WIN32)
set(VCPKG_LIB_DIR "${OB_VCPKG_DIR}/lib")
set(OPENSSL_LIB_DIR "${OB_OPENSSL_DIR}/lib/VC/x64/MD")
set(_oblib_protobuf_c_library)
if(_oblib_link_protobuf_c)
set(_oblib_protobuf_c_library ${VCPKG_LIB_DIR}/protobuf-c.lib)
endif()
target_link_libraries(oblib_base_without_pass
INTERFACE
${VCPKG_LIB_DIR}/libcurl.lib
Expand All @@ -261,13 +293,17 @@ if(WIN32)
${VCPKG_LIB_DIR}/icuin.lib
${VCPKG_LIB_DIR}/icudt.lib
${VCPKG_LIB_DIR}/icuuc.lib
${VCPKG_LIB_DIR}/protobuf-c.lib
${_oblib_protobuf_c_library}
${VCPKG_LIB_DIR}/sqlite3.lib
${VCPKG_LIB_DIR}/pthreadVC3.lib
ws2_32 crypt32 bcrypt userenv wldap32 advapi32
${ARCH_LDFLAGS}
)
else()
set(_oblib_protobuf_c_library)
if(_oblib_link_protobuf_c)
set(_oblib_protobuf_c_library ${DEP_DIR}/lib/libprotobuf-c.a)
endif()
target_link_libraries(oblib_base_without_pass
INTERFACE
-L${DEP_DIR}/lib
Expand All @@ -283,7 +319,7 @@ else()
${DEP_DIR}/lib/libicui18n.a
${DEP_DIR}/lib/libicustubdata.a
${DEP_DIR}/lib/libicuuc.a
${DEP_DIR}/lib/libprotobuf-c.a
${_oblib_protobuf_c_library}
$<$<PLATFORM_ID:Linux>:-L${DEP_DIR}/var/usr/lib64 -L${DEP_DIR}/var/usr/lib -L${DEP_3RD_DIR}/usr/lib -L${DEP_3RD_DIR}/usr/lib64>
${LIBAIO_LINK_OPTION} $<$<NOT:$<BOOL:${ANDROID}>>:-lpthread> -ldl
$<$<BOOL:${ANDROID}>:-llog>
Expand All @@ -292,6 +328,8 @@ else()
${ARCH_LDFLAGS}
)
endif()
unset(_oblib_protobuf_c_library)
unset(_oblib_link_protobuf_c)
target_link_libraries(oblib_base INTERFACE oblib_base_without_pass oblib_pass)

function(oblib_add_library target)
Expand Down
64 changes: 57 additions & 7 deletions src/share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,18 @@ ob_set_subtarget(ob_share semistruct
semistruct/ob_sub_column_path.cpp
)

set(SEEKDB_GIS_MVT_SOURCES)
if(SEEKDB_ENABLE_GIS_MVT)
list(APPEND SEEKDB_GIS_MVT_SOURCES
geo/ob_geo_mvt_encode_visitor.cpp
geo/ob_geo_mvt.cpp
geo/ob_vector_tile.pb-c.c
geo/ob_geo_affine_visitor.cpp
geo/ob_geo_grid_visitor.cpp
geo/ob_geo_simplify_visitor.cpp
)
endif()

ob_set_subtarget(ob_share geo
geo/ob_geo_common.cpp
geo/ob_geo_bin.cpp
Expand Down Expand Up @@ -419,12 +431,7 @@ ob_set_subtarget(ob_share geo
geo/ob_geo_box_clip_visitor.cpp
geo/ob_geo_elevation_visitor.cpp
geo/ob_geo_func_length.cpp
geo/ob_geo_mvt_encode_visitor.cpp
geo/ob_geo_mvt.cpp
geo/ob_vector_tile.pb-c.c
geo/ob_geo_affine_visitor.cpp
geo/ob_geo_grid_visitor.cpp
geo/ob_geo_simplify_visitor.cpp
${SEEKDB_GIS_MVT_SOURCES}
geo/ob_geo_box_clip_visitor.cpp
geo/ob_geo_func_dissolve_polygon.cpp
geo/ob_geo_close_ring_visitor.cpp
Expand All @@ -440,7 +447,7 @@ ob_set_subtarget(ob_share geo
geo/ob_geo_point_location_visitor.cpp
)

ob_set_subtarget(ob_share ALONE
set(SEEKDB_GIS_HEAVY_SOURCES
geo/ob_geo_func_difference1.cpp
geo/ob_geo_func_difference2.cpp
geo/ob_geo_func_difference3.cpp
Expand Down Expand Up @@ -468,6 +475,49 @@ ob_set_subtarget(ob_share ALONE
geo/ob_geo_func_overlaps3.cpp
)

set(SEEKDB_GIS_RELATION_SOURCES)
if(SEEKDB_COMPACT_GIS)
list(APPEND SEEKDB_GIS_RELATION_SOURCES
geo/ob_geo_func_relation.cpp
)
set_property(SOURCE
geo/ob_geo_func_relation.cpp
geo/ob_geo_func_equals1.cpp
geo/ob_geo_func_intersects.cpp
geo/ob_geo_func_within1.cpp
geo/ob_geo_func_overlaps1.cpp
APPEND PROPERTY COMPILE_DEFINITIONS SEEKDB_COMPACT_GIS_ENABLED=1)
endif()

ob_set_subtarget(ob_share ALONE
${SEEKDB_GIS_HEAVY_SOURCES}
${SEEKDB_GIS_RELATION_SOURCES}
)

if(SEEKDB_COMPACT_GIS)
# Source-level options are appended after the build-type optimization flag,
# so this overrides the usual -O2 only for the template-heavy GIS units.
if(MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(_seekdb_gis_size_option /O1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(_seekdb_gis_size_option -Oz)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(_seekdb_gis_size_option -Os)
else()
message(WARNING
"SEEKDB_COMPACT_GIS is enabled, but ${CMAKE_CXX_COMPILER_ID} has no configured size optimization flag")
endif()

if(DEFINED _seekdb_gis_size_option)
set_property(SOURCE ${SEEKDB_GIS_HEAVY_SOURCES} ${SEEKDB_GIS_RELATION_SOURCES}
APPEND PROPERTY
COMPILE_OPTIONS "${_seekdb_gis_size_option}")
message(STATUS
"SEEKDB_COMPACT_GIS: compiling heavy GIS sources with ${_seekdb_gis_size_option}")
endif()
unset(_seekdb_gis_size_option)
endif()

ob_add_new_object_target(ob_share ob_share)
ob_add_new_object_target(ob_share_extra ob_share_extra)

Expand Down
20 changes: 20 additions & 0 deletions src/share/geo/ob_geo_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,32 @@

#define USING_LOG_PREFIX LIB
#include "share/geo/ob_geo_common.h"
#include "share/geo/ob_geo_eval_ctx.h"
#include "lib/rc/context.h"

namespace oceanbase
{
namespace common
{

ObGeoEvalCtx::ObGeoEvalCtx(lib::MemoryContext &mem_ctx)
: allocator_(&mem_ctx->get_arena_allocator()),
srs_(NULL),
g_arg_c_(0),
v_arg_c_(0),
is_called_in_pg_expr_(false),
mem_ctx_(mem_ctx)
{}

ObGeoEvalCtx::ObGeoEvalCtx(lib::MemoryContext &mem_ctx, const ObSrsItem *srs_item)
: allocator_(&mem_ctx->get_arena_allocator()),
srs_(srs_item),
g_arg_c_(0),
v_arg_c_(0),
is_called_in_pg_expr_(false),
mem_ctx_(mem_ctx)
{}

// ObGeoWkbByteOrderUtil
template<>
double ObGeoWkbByteOrderUtil::read<double>(const char* data, ObGeoWkbByteOrder bo)
Expand Down
Loading
Loading