Skip to content

Commit

Permalink
Merge pull request #6 from igalink/db_engine
Browse files Browse the repository at this point in the history
Db engine
  • Loading branch information
igalink committed Mar 3, 2020
2 parents 7fce3c4 + 5b762e8 commit d5a3364
Show file tree
Hide file tree
Showing 21 changed files with 644 additions and 4,768 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.2)
set(CMAKE_CXX_FLAGS "-fPIC ")
set(CMAKE_C_FLAGS "-fPIC ")

set(CMAKE_SHARED_LINKER_FLAGS " --no-undefined")
#set(CMAKE_SHARED_LINKER_FLAGS " --no-undefined")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
Expand Down Expand Up @@ -742,7 +742,7 @@ add_custom_target(clean-all
COMMAND ${CMAKE_BUILD_TOOL} clean
)

## mvn process for java code
# mvn process for java code
find_program(MVN_EXECUTABLE NAMES mvn)
if(NOT MVN_EXECUTABLE)
message(FATAL_ERROR "mvn not found. Install Apache Maven.")
Expand Down
12 changes: 6 additions & 6 deletions QueryEngine/ArrayOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,28 +279,28 @@ extern "C" DEVICE int8_t* array_buff(int8_t* chunk_iter_, const uint64_t row_pos

#include <set>

extern "C" ALWAYS_INLINE int64_t elem_bitcast_int8_t(const int8_t val) {
extern "C" int64_t elem_bitcast_int8_t(const int8_t val) {
return val;
}

extern "C" ALWAYS_INLINE int64_t elem_bitcast_int16_t(const int16_t val) {
extern "C" int64_t elem_bitcast_int16_t(const int16_t val) {
return val;
}

extern "C" ALWAYS_INLINE int64_t elem_bitcast_int32_t(const int32_t val) {
extern "C" int64_t elem_bitcast_int32_t(const int32_t val) {
return val;
}

extern "C" ALWAYS_INLINE int64_t elem_bitcast_int64_t(const int64_t val) {
extern "C" int64_t elem_bitcast_int64_t(const int64_t val) {
return val;
}

extern "C" ALWAYS_INLINE int64_t elem_bitcast_float(const float val) {
extern "C" int64_t elem_bitcast_float(const float val) {
const double dval{val};
return *reinterpret_cast<const int64_t*>(may_alias_ptr(&dval));
}

extern "C" ALWAYS_INLINE int64_t elem_bitcast_double(const double val) {
extern "C" int64_t elem_bitcast_double(const double val) {
return *reinterpret_cast<const int64_t*>(may_alias_ptr(&val));
}

Expand Down
2 changes: 2 additions & 0 deletions QueryEngine/ArrowResultSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ class ArrowResultSetConverter {
const std::vector<std::string>& col_names,
const int32_t first_n)
: results_(results), col_names_(col_names), top_n_(first_n) {}
public:
std::shared_ptr<arrow::RecordBatch> convertToArrow(
arrow::ipc::DictionaryMemo& memo) const;
std::shared_ptr<arrow::RecordBatch> getArrowBatch(
const std::shared_ptr<arrow::Schema>& schema) const;
private:
ArrowResult getArrowResultImpl() const;
std::shared_ptr<arrow::Field> makeField(
const std::string name,
Expand Down
6 changes: 3 additions & 3 deletions QueryEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ set(query_engine_source_files
WindowContext.cpp
WindowExpressionRewrite.cpp
WindowFunctionIR.cpp

Codec.h
Execute.h
NvidiaKernel.h
Expand Down Expand Up @@ -400,5 +400,5 @@ add_custom_command(
-c ${CMAKE_CURRENT_SOURCE_DIR}/Rendering/ee/ThrustTransform.cu
)

#add_executable(group_by_hash_test ${group_by_hash_test_files})
#target_link_libraries(group_by_hash_test gtest Shared ${Boost_LIBRARIES} ${PROFILER_LIBS})
add_executable(group_by_hash_test ${group_by_hash_test_files})
target_link_libraries(group_by_hash_test gtest Shared ${Boost_LIBRARIES} ${PROFILER_LIBS})
12 changes: 6 additions & 6 deletions QueryEngine/DecodersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <cstdint>
#include "../Shared/funcannotations.h"

extern "C" DEVICE ALWAYS_INLINE int64_t
extern "C" DEVICE inline ALWAYS_INLINE int64_t
SUFFIX(fixed_width_int_decode)(const int8_t* byte_stream,
const int32_t byte_width,
const int64_t pos) {
Expand All @@ -53,7 +53,7 @@ SUFFIX(fixed_width_int_decode)(const int8_t* byte_stream,
}
}

extern "C" DEVICE ALWAYS_INLINE int64_t
extern "C" DEVICE inline ALWAYS_INLINE int64_t
SUFFIX(fixed_width_unsigned_decode)(const int8_t* byte_stream,
const int32_t byte_width,
const int64_t pos) {
Expand Down Expand Up @@ -93,15 +93,15 @@ SUFFIX(fixed_width_unsigned_decode_noinline)(const int8_t* byte_stream,
return SUFFIX(fixed_width_unsigned_decode)(byte_stream, byte_width, pos);
}

extern "C" DEVICE ALWAYS_INLINE int64_t
extern "C" DEVICE inline ALWAYS_INLINE int64_t
SUFFIX(diff_fixed_width_int_decode)(const int8_t* byte_stream,
const int32_t byte_width,
const int64_t baseline,
const int64_t pos) {
return SUFFIX(fixed_width_int_decode)(byte_stream, byte_width, pos) + baseline;
}

extern "C" DEVICE ALWAYS_INLINE float SUFFIX(
extern "C" DEVICE inline ALWAYS_INLINE float SUFFIX(
fixed_width_float_decode)(const int8_t* byte_stream, const int64_t pos) {
#ifdef WITH_DECODERS_BOUNDS_CHECKING
assert(pos >= 0);
Expand All @@ -114,7 +114,7 @@ extern "C" DEVICE NEVER_INLINE float SUFFIX(
return SUFFIX(fixed_width_float_decode)(byte_stream, pos);
}

extern "C" DEVICE ALWAYS_INLINE double SUFFIX(
extern "C" DEVICE inline ALWAYS_INLINE double SUFFIX(
fixed_width_double_decode)(const int8_t* byte_stream, const int64_t pos) {
#ifdef WITH_DECODERS_BOUNDS_CHECKING
assert(pos >= 0);
Expand All @@ -127,7 +127,7 @@ extern "C" DEVICE NEVER_INLINE double SUFFIX(
return SUFFIX(fixed_width_double_decode)(byte_stream, pos);
}

extern "C" DEVICE ALWAYS_INLINE int64_t
extern "C" DEVICE inline ALWAYS_INLINE int64_t
SUFFIX(fixed_width_small_date_decode)(const int8_t* byte_stream,
const int32_t byte_width,
const int32_t null_val,
Expand Down
3 changes: 2 additions & 1 deletion QueryEngine/ExtensionFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#include <cmath>
#include <cstdlib>

#define EXTENSION_INLINE extern "C" ALWAYS_INLINE DEVICE
#define EXTENSION_INLINE
//extern "C" ALWAYS_INLINE DEVICE
#define EXTENSION_NOINLINE extern "C" NEVER_INLINE DEVICE

/* Example extension functions:
Expand Down
52 changes: 26 additions & 26 deletions QueryEngine/ExtensionFunctionsGeo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@
// For example 1.0 longitude compressed with GEOINT32 and then decompressed
// comes back as 0.99999994086101651, which is still within GEOINT32
// tolerance val 0.0000001
DEVICE ALWAYS_INLINE double tol(int32_t ic) {
DEVICE double tol(int32_t ic) {
if (ic == COMPRESSION_GEOINT32) {
return TOLERANCE_GEOINT32;
}
return TOLERANCE_DEFAULT;
}

// Combine tolerances for two-component calculations
DEVICE ALWAYS_INLINE double tol(int32_t ic1, int32_t ic2) {
DEVICE double tol(int32_t ic1, int32_t ic2) {
return fmax(tol(ic1), tol(ic2));
}

DEVICE ALWAYS_INLINE bool tol_zero(double x, double tolerance = TOLERANCE_DEFAULT) {
DEVICE bool tol_zero(double x, double tolerance = TOLERANCE_DEFAULT) {
return (-tolerance <= x) && (x <= tolerance);
}

DEVICE ALWAYS_INLINE bool tol_eq(double x,
DEVICE bool tol_eq(double x,
double y,
double tolerance = TOLERANCE_DEFAULT) {
auto diff = x - y;
return (-tolerance <= diff) && (diff <= tolerance);
}

DEVICE ALWAYS_INLINE bool tol_le(double x,
DEVICE bool tol_le(double x,
double y,
double tolerance = TOLERANCE_DEFAULT) {
return x <= (y + tolerance);
}

DEVICE ALWAYS_INLINE bool tol_ge(double x,
DEVICE bool tol_ge(double x,
double y,
double tolerance = TOLERANCE_DEFAULT) {
return (x + tolerance) >= y;
}

DEVICE ALWAYS_INLINE double decompress_coord(int8_t* data,
DEVICE double decompress_coord(int8_t* data,
int32_t index,
int32_t ic,
bool x) {
Expand All @@ -66,14 +66,14 @@ DEVICE ALWAYS_INLINE double decompress_coord(int8_t* data,
return double_coords[index];
}

DEVICE ALWAYS_INLINE int32_t compression_unit_size(int32_t ic) {
DEVICE int32_t compression_unit_size(int32_t ic) {
if (ic == COMPRESSION_GEOINT32) {
return 4;
}
return 8;
}

DEVICE ALWAYS_INLINE double transform_coord(double coord,
DEVICE double transform_coord(double coord,
int32_t isr,
int32_t osr,
bool x) {
Expand All @@ -91,7 +91,7 @@ DEVICE ALWAYS_INLINE double transform_coord(double coord,
}

// X coord accessor handling on-the-fly decommpression and transforms
DEVICE ALWAYS_INLINE double coord_x(int8_t* data,
DEVICE double coord_x(int8_t* data,
int32_t index,
int32_t ic,
int32_t isr,
Expand All @@ -103,7 +103,7 @@ DEVICE ALWAYS_INLINE double coord_x(int8_t* data,
}

// Y coord accessor handling on-the-fly decommpression and transforms
DEVICE ALWAYS_INLINE double coord_y(int8_t* data,
DEVICE double coord_y(int8_t* data,
int32_t index,
int32_t ic,
int32_t isr,
Expand All @@ -115,7 +115,7 @@ DEVICE ALWAYS_INLINE double coord_y(int8_t* data,
}

// Cartesian distance between points, squared
DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x,
DEVICE double distance_point_point_squared(double p1x,
double p1y,
double p2x,
double p2y) {
Expand All @@ -131,7 +131,7 @@ DEVICE ALWAYS_INLINE double distance_point_point_squared(double p1x,
}

// Cartesian distance between points
DEVICE ALWAYS_INLINE double distance_point_point(double p1x,
DEVICE double distance_point_point(double p1x,
double p1y,
double p2x,
double p2y) {
Expand Down Expand Up @@ -168,7 +168,7 @@ double distance_point_line(double px,

// Given three colinear points p, q, r, the function checks if
// point q lies on line segment 'pr'
DEVICE ALWAYS_INLINE bool on_segment(double px,
DEVICE bool on_segment(double px,
double py,
double qx,
double qy,
Expand All @@ -178,7 +178,7 @@ DEVICE ALWAYS_INLINE bool on_segment(double px,
tol_le(qy, fmax(py, ry)) && tol_ge(qy, fmin(py, ry)));
}

DEVICE ALWAYS_INLINE int16_t
DEVICE int16_t
orientation(double px, double py, double qx, double qy, double rx, double ry) {
auto val = ((qy - py) * (rx - qx) - (qx - px) * (ry - qy));
if (tol_zero(val)) {
Expand Down Expand Up @@ -565,7 +565,7 @@ bool polygon_contains_linestring(int8_t* poly,
return true;
}

DEVICE ALWAYS_INLINE bool box_contains_point(double* bounds,
DEVICE bool box_contains_point(double* bounds,
int64_t bounds_size,
double px,
double py) {
Expand All @@ -580,7 +580,7 @@ EXTENSION_NOINLINE bool Point_Overlaps_Box(double* bounds,
return box_contains_point(bounds, bounds_size, px, py);
}

DEVICE ALWAYS_INLINE bool box_contains_box(double* bounds1,
DEVICE bool box_contains_box(double* bounds1,
int64_t bounds1_size,
double* bounds2,
int64_t bounds2_size) {
Expand All @@ -591,7 +591,7 @@ DEVICE ALWAYS_INLINE bool box_contains_box(double* bounds1,
bounds1, bounds1_size, bounds2[2], bounds2[3])); // box1 <- box2: xmax, ymax
}

DEVICE ALWAYS_INLINE bool box_contains_box_vertex(double* bounds1,
DEVICE bool box_contains_box_vertex(double* bounds1,
int64_t bounds1_size,
double* bounds2,
int64_t bounds2_size) {
Expand All @@ -606,7 +606,7 @@ DEVICE ALWAYS_INLINE bool box_contains_box_vertex(double* bounds1,
bounds1, bounds1_size, bounds2[2], bounds2[1])); // box1 <- box2: xmax, ymin
}

DEVICE ALWAYS_INLINE bool box_overlaps_box(double* bounds1,
DEVICE bool box_overlaps_box(double* bounds1,
int64_t bounds1_size,
double* bounds2,
int64_t bounds2_size) {
Expand Down Expand Up @@ -734,7 +734,7 @@ double ST_YMax_Bounds(double* bounds, int64_t size, int32_t isr, int32_t osr) {
// ST_Length
//

DEVICE ALWAYS_INLINE double length_linestring(int8_t* l,
DEVICE double length_linestring(int8_t* l,
int64_t lsize,
int32_t ic,
int32_t isr,
Expand Down Expand Up @@ -824,7 +824,7 @@ double ST_Perimeter_Polygon_Geodesic(int8_t* poly,
return length_linestring(poly, exterior_ring_coords_size, ic, isr, osr, true, true);
}

DEVICE ALWAYS_INLINE double perimeter_multipolygon(int8_t* mpoly_coords,
DEVICE double perimeter_multipolygon(int8_t* mpoly_coords,
int64_t mpoly_coords_size,
int32_t* mpoly_ring_sizes,
int64_t mpoly_num_rings,
Expand Down Expand Up @@ -914,7 +914,7 @@ double ST_Perimeter_MultiPolygon_Geodesic(int8_t* mpoly_coords,
// ST_Area
//

DEVICE ALWAYS_INLINE double area_triangle(double x1,
DEVICE double area_triangle(double x1,
double y1,
double x2,
double y2,
Expand All @@ -923,7 +923,7 @@ DEVICE ALWAYS_INLINE double area_triangle(double x1,
return (x1 * y2 - x2 * y1 + x3 * y1 - x1 * y3 + x2 * y3 - x3 * y2) / 2.0;
}

DEVICE ALWAYS_INLINE double area_ring(int8_t* ring,
DEVICE double area_ring(int8_t* ring,
int64_t ringsize,
int32_t ic,
int32_t isr,
Expand All @@ -950,7 +950,7 @@ DEVICE ALWAYS_INLINE double area_ring(int8_t* ring,
return area;
}

DEVICE ALWAYS_INLINE double area_polygon(int8_t* poly_coords,
DEVICE double area_polygon(int8_t* poly_coords,
int64_t poly_coords_size,
int32_t* poly_ring_sizes,
int64_t poly_num_rings,
Expand Down Expand Up @@ -1192,7 +1192,7 @@ double ST_Distance_LineString_LineString_Geodesic(int8_t* l1,
return distance_in_meters(l1x, l1y, l2x, l2y);
}

DEVICE ALWAYS_INLINE double distance_point_linestring(int8_t* p,
DEVICE double distance_point_linestring(int8_t* p,
int64_t psize,
int8_t* l,
int64_t lsize,
Expand Down Expand Up @@ -1987,7 +1987,7 @@ double max_distance_point_line(double px,
return length2;
}

DEVICE ALWAYS_INLINE double max_distance_point_linestring(int8_t* p,
DEVICE double max_distance_point_linestring(int8_t* p,
int64_t psize,
int8_t* l,
int64_t lsize,
Expand Down
Loading

0 comments on commit d5a3364

Please sign in to comment.