Skip to content

Commit

Permalink
Try to revert back to boost to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonStoykovQC committed Oct 11, 2023
1 parent 7086bbc commit 9194ffc
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 6 deletions.
8 changes: 8 additions & 0 deletions cmake_scripts/default_build_setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,11 @@ add_custom_target(refresh_cmake_configuration
cmake -E touch ${CMAKE_PARENT_LIST_FILE} # make cmake detect configuration is changed on NEXT build
COMMENT "Forcing refreshing of the CMake configuration. This allows to use globbing safely."
)

if(WIN32)
add_definitions("-std=c++17")
link_directories("$ENV{PYTHON}/libs")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "TRUE")
set(Boost_USE_STATIC_RUNTIME "ON")
set(Boost_USE_STATIC_LIBS "ON")
endif()
3 changes: 3 additions & 0 deletions cpp/cpp_odbc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
find_package(Boost REQUIRED COMPONENTS locale)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

find_package(odbc REQUIRED)
include_directories(SYSTEM ${Odbc_INCLUDE_DIR})

Expand Down
9 changes: 8 additions & 1 deletion cpp/cpp_odbc/Library/src/level2/level1_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <locale>
#include <sstream>

#include <boost/locale.hpp>

namespace impl {

template <typename Output_Handle, typename Input_Handle>
Expand Down Expand Up @@ -430,7 +432,12 @@ column_description level1_connector::do_describe_column_wide(statement_handle co

impl::throw_on_error(return_code, *this, handle);

std::string const utf8_name = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(name);
// TODO-Simeon: throws
// throw std::invalid_argument("Simeon conversion in level1_connector");
// TODO-Simeon: throws

//std::string const utf8_name = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(name);
auto const utf8_name = boost::locale::conv::utf_to_utf<char>(static_cast<std::u16string>(name));
return {utf8_name, data_type, size, decimal_digits, allows_nullable};
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/turbodbc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_package(Boost REQUIRED COMPONENTS system date_time)
find_package(Boost REQUIRED COMPONENTS system date_time locale)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})

find_package(odbc REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions cpp/turbodbc/Library/src/connect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "turbodbc/connect.h"
#include <cpp_odbc/make_environment.h>

using namespace std;

turbodbc::connection turbodbc::connect(std::string const & connection_string, options options)
{
auto environment = cpp_odbc::make_environment();
Expand Down
11 changes: 9 additions & 2 deletions cpp/turbodbc/Library/src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
#include <sstream>
#include <codecvt>

#include <boost/locale.hpp>

namespace {

std::u16string as_utf16(std::string utf8_encoded) {
// TODO-Simeon: throws
// throw std::invalid_argument("Simeon conversion in cursor");
// TODO-Simeon: throws

// not all compilers support the new C++11 conversion facets
static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
return converter.from_bytes(utf8_encoded);
return boost::locale::conv::utf_to_utf<char16_t>(utf8_encoded);
//static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
//return converter.from_bytes(utf8_encoded);
}

}
Expand Down
6 changes: 6 additions & 0 deletions cpp/turbodbc_arrow/Library/src/arrow_result_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <codecvt>
#include <vector>

#include <boost/locale.hpp>

using arrow::default_memory_pool;
using arrow::AdaptiveIntBuilder;
using arrow::ArrayBuilder;
Expand Down Expand Up @@ -127,7 +129,11 @@ Status AppendUnicodeStringsToBuilder(size_t rows_in_batch, BuilderType& builder,
if (element.indicator == SQL_NULL_DATA) {
ARROW_RETURN_NOT_OK(builder.AppendNullProxy());
} else {
// TODO-Simeon: throws
// throw std::invalid_argument("Simeon conversion in arrow_result_set");
// TODO-Simeon: throws
std::u16string str_u16(reinterpret_cast<const char16_t*>(element.data_pointer), element.indicator / 2);
//std::string u8string = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(str_u16);
std::string u8string = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(str_u16);
ARROW_RETURN_NOT_OK(builder.AppendProxy(u8string.data(), u8string.size()));
}
Expand Down
2 changes: 2 additions & 0 deletions cpp/turbodbc_arrow/Library/src/set_arrow_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <ciso646>
#include <codecvt>

#include <boost/locale.hpp>

using arrow::BooleanArray;
using arrow::BinaryArray;
using arrow::ChunkedArray;
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- python>=3.9
- pyarrow>=7.0,<14
- sel(unix): unixodbc
# - sel(unix): unixodbc
- c-compiler
- cxx-compiler
- gmock=1.10.0
Expand Down
2 changes: 1 addition & 1 deletion x_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def mssql_connect_turbodbc() -> turbodbc.connection.Connection:
)


smoke()
# smoke()


which = input("Which query: ") if len(sys.argv) < 2 else sys.argv[-1]
Expand Down

0 comments on commit 9194ffc

Please sign in to comment.