DragonBox integration

This commit is contained in:
Maksim Kita 2020-12-06 00:32:03 +03:00
parent 67c82eb61b
commit 64549702a2
8 changed files with 18 additions and 4 deletions

3
.gitmodules vendored
View File

@ -209,3 +209,6 @@
path = contrib/abseil-cpp path = contrib/abseil-cpp
url = https://github.com/ClickHouse-Extras/abseil-cpp.git url = https://github.com/ClickHouse-Extras/abseil-cpp.git
branch = lts_2020_02_25 branch = lts_2020_02_25
[submodule "contrib/dragonbox"]
path = contrib/dragonbox
url = https://github.com/kitaisreal/dragonbox.git

View File

@ -322,3 +322,5 @@ endif()
if (USE_INTERNAL_ROCKSDB_LIBRARY) if (USE_INTERNAL_ROCKSDB_LIBRARY)
add_subdirectory(rocksdb-cmake) add_subdirectory(rocksdb-cmake)
endif() endif()
add_subdirectory(dragonbox)

1
contrib/dragonbox vendored Submodule

@ -0,0 +1 @@
Subproject commit 17d07b00f9c70d61c60c3bd1046c2ef6814d14c6

View File

@ -155,6 +155,7 @@ function clone_submodules
contrib/croaring contrib/croaring
contrib/miniselect contrib/miniselect
contrib/xz contrib/xz
contrib/dragonbox
) )
git submodule sync git submodule sync

View File

@ -243,6 +243,7 @@ target_link_libraries (clickhouse_common_io
common common
${DOUBLE_CONVERSION_LIBRARIES} ${DOUBLE_CONVERSION_LIBRARIES}
ryu ryu
dragonbox_to_chars
) )
if(RE2_LIBRARY) if(RE2_LIBRARY)

View File

@ -29,7 +29,7 @@
#include <IO/DoubleConverter.h> #include <IO/DoubleConverter.h>
#include <IO/WriteBufferFromString.h> #include <IO/WriteBufferFromString.h>
#include <ryu/ryu.h> #include <dragonbox/dragonbox_to_chars.h>
#include <Formats/FormatSettings.h> #include <Formats/FormatSettings.h>
@ -228,14 +228,14 @@ inline size_t writeFloatTextFastPath(T x, char * buffer)
if (DecomposedFloat64(x).is_inside_int64()) if (DecomposedFloat64(x).is_inside_int64())
result = itoa(Int64(x), buffer) - buffer; result = itoa(Int64(x), buffer) - buffer;
else else
result = d2s_buffered_n(x, buffer); result = jkj::dragonbox::to_chars_n(x, buffer) - buffer;
} }
else else
{ {
if (DecomposedFloat32(x).is_inside_int32()) if (DecomposedFloat32(x).is_inside_int32())
result = itoa(Int32(x), buffer) - buffer; result = itoa(Int32(x), buffer) - buffer;
else else
result = f2s_buffered_n(x, buffer); result = jkj::dragonbox::to_chars_n(x, buffer) - buffer;
} }
if (result <= 0) if (result <= 0)

View File

@ -82,6 +82,7 @@ target_link_libraries (zlib_ng_bug PRIVATE ${ZLIB_LIBRARIES})
add_executable (ryu_test ryu_test.cpp) add_executable (ryu_test ryu_test.cpp)
target_link_libraries (ryu_test PRIVATE ryu) target_link_libraries (ryu_test PRIVATE ryu)
target_link_libraries (ryu_test PRIVATE dragonbox_to_chars)
add_executable (zstd_buffers zstd_buffers.cpp) add_executable (zstd_buffers zstd_buffers.cpp)
target_link_libraries (zstd_buffers PRIVATE clickhouse_common_io) target_link_libraries (zstd_buffers PRIVATE clickhouse_common_io)

View File

@ -2,7 +2,7 @@
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <ryu/ryu.h> #include <ryu/ryu.h>
#include <dragonbox/dragonbox_to_chars.h>
struct DecomposedFloat64 struct DecomposedFloat64
{ {
@ -84,9 +84,14 @@ int main(int argc, char ** argv)
double x = argc > 1 ? std::stod(argv[1]) : 0; double x = argc > 1 ? std::stod(argv[1]) : 0;
char buf[32]; char buf[32];
std::cout << "ryu output" << std::endl;
d2s_buffered(x, buf); d2s_buffered(x, buf);
std::cout << buf << "\n"; std::cout << buf << "\n";
std::cout << "dragonbox output" << std::endl;
jkj::dragonbox::to_chars(x, buf);
std::cout << buf << "\n";
std::cout << DecomposedFloat64(x).isInsideInt64() << "\n"; std::cout << DecomposedFloat64(x).isInsideInt64() << "\n";
return 0; return 0;