aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2022-08-05 13:12:41 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2022-08-05 13:12:41 +0300
commitf346528af256244b692e713a8b6891957ae58dc6 (patch)
treebe4c8e1fdb0d221f23c51c07737f71f72c5b4afe
parent294266d5d66a9796d7e65205f6b9f2c98e4f652e (diff)
downloadydb-f346528af256244b692e713a8b6891957ae58dc6.tar.gz
Update contrib/restricted/fast_float to 3.5.1
-rw-r--r--contrib/restricted/fast_float/README.md85
-rw-r--r--contrib/restricted/fast_float/include/fast_float/digit_comparison.h2
-rw-r--r--contrib/restricted/fast_float/include/fast_float/float_common.h9
3 files changed, 60 insertions, 36 deletions
diff --git a/contrib/restricted/fast_float/README.md b/contrib/restricted/fast_float/README.md
index 1e1c06d0a3..92eb3a4d2b 100644
--- a/contrib/restricted/fast_float/README.md
+++ b/contrib/restricted/fast_float/README.md
@@ -1,12 +1,5 @@
## fast_float number parsing library: 4x faster than strtod
-![Ubuntu 20.04 CI (GCC 9)](https://github.com/lemire/fast_float/workflows/Ubuntu%2020.04%20CI%20(GCC%209)/badge.svg)
-![Ubuntu 18.04 CI (GCC 7)](https://github.com/lemire/fast_float/workflows/Ubuntu%2018.04%20CI%20(GCC%207)/badge.svg)
-![Alpine Linux](https://github.com/lemire/fast_float/workflows/Alpine%20Linux/badge.svg)
-![MSYS2-CI](https://github.com/lemire/fast_float/workflows/MSYS2-CI/badge.svg)
-![VS16-CLANG-CI](https://github.com/lemire/fast_float/workflows/VS16-CLANG-CI/badge.svg)
-[![VS16-CI](https://github.com/fastfloat/fast_float/actions/workflows/vs16-ci.yml/badge.svg)](https://github.com/fastfloat/fast_float/actions/workflows/vs16-ci.yml)
-
The fast_float library provides fast header-only implementations for the C++ from_chars
functions for `float` and `double` types. These functions convert ASCII strings representing
decimal values (e.g., `1.3e10`) into binary types. We provide exact rounding (including
@@ -28,8 +21,8 @@ struct from_chars_result {
```
It parses the character sequence [first,last) for a number. It parses floating-point numbers expecting
-a locale-independent format equivalent to the C++17 from_chars function.
-The resulting floating-point value is the closest floating-point values (using either float or double),
+a locale-independent format equivalent to the C++17 from_chars function.
+The resulting floating-point value is the closest floating-point values (using either float or double),
using the "round to even" convention for values that would otherwise fall right in-between two values.
That is, we provide exact parsing according to the IEEE standard.
@@ -47,7 +40,7 @@ Example:
``` C++
#include "fast_float/fast_float.h"
#include <iostream>
-
+
int main() {
const std::string input = "3.1416 xyz ";
double result;
@@ -60,15 +53,15 @@ int main() {
Like the C++17 standard, the `fast_float::from_chars` functions take an optional last argument of
-the type `fast_float::chars_format`. It is a bitset value: we check whether
+the type `fast_float::chars_format`. It is a bitset value: we check whether
`fmt & fast_float::chars_format::fixed` and `fmt & fast_float::chars_format::scientific` are set
to determine whether we allow the fixed point and scientific notation respectively.
The default is `fast_float::chars_format::general` which allows both `fixed` and `scientific`.
-The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/charconv.from.chars).(7.1)) specification.
+The library seeks to follow the C++17 (see [20.19.3](http://eel.is/c++draft/charconv.from.chars).(7.1)) specification.
* The `from_chars` function does not skip leading white-space characters.
* [A leading `+` sign](https://en.cppreference.com/w/cpp/utility/from_chars) is forbidden.
-* It is generally impossible to represent a decimal value exactly as binary floating-point number (`float` and `double` types). We seek the nearest value. We round to an even mantissa when we are in-between two binary floating-point numbers.
+* It is generally impossible to represent a decimal value exactly as binary floating-point number (`float` and `double` types). We seek the nearest value. We round to an even mantissa when we are in-between two binary floating-point numbers.
Furthermore, we have the following restrictions:
* We only support `float` and `double` types at this time.
@@ -83,16 +76,16 @@ We support Visual Studio, macOS, Linux, freeBSD. We support big and little endia
The C++ standard stipulate that `from_chars` has to be locale-independent. In
-particular, the decimal separator has to be the period (`.`). However,
-some users still want to use the `fast_float` library with in a locale-dependent
+particular, the decimal separator has to be the period (`.`). However,
+some users still want to use the `fast_float` library with in a locale-dependent
manner. Using a separate function called `from_chars_advanced`, we allow the users
-to pass a `parse_options` instance which contains a custom decimal separator (e.g.,
+to pass a `parse_options` instance which contains a custom decimal separator (e.g.,
the comma). You may use it as follows.
```C++
#include "fast_float/fast_float.h"
#include <iostream>
-
+
int main() {
const std::string input = "3,1416 xyz ";
double result;
@@ -104,6 +97,32 @@ int main() {
}
```
+You can parse delimited numbers:
+```C++
+ const std::string input = "234532.3426362,7869234.9823,324562.645";
+ double result;
+ auto answer = fast_float::from_chars(input.data(), input.data()+input.size(), result);
+ if(answer.ec != std::errc()) {
+ // check error
+ }
+ // we have result == 234532.3426362.
+ if(answer.ptr[0] != ',') {
+ // unexpected delimiter
+ }
+ answer = fast_float::from_chars(answer.ptr + 1, input.data()+input.size(), result);
+ if(answer.ec != std::errc()) {
+ // check error
+ }
+ // we have result == 7869234.9823.
+ if(answer.ptr[0] != ',') {
+ // unexpected delimiter
+ }
+ answer = fast_float::from_chars(answer.ptr + 1, input.data()+input.size(), result);
+ if(answer.ec != std::errc()) {
+ // check error
+ }
+ // we have result == 324562.645.
+```
## Reference
@@ -119,10 +138,14 @@ int main() {
## Relation With Other Work
-The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
+The fast_float library is part of GCC (as of version 12): the `from_chars` function in GCC relies on fast_float.
+
+The fastfloat algorithm is part of the [LLVM standard libraries](https://github.com/llvm/llvm-project/commit/87c016078ad72c46505461e4ff8bfa04819fe7ba).
The fast_float library provides a performance similar to that of the [fast_double_parser](https://github.com/lemire/fast_double_parser) library but using an updated algorithm reworked from the ground up, and while offering an API more in line with the expectations of C++ programmers. The fast_double_parser library is part of the [Microsoft LightGBM machine-learning framework](https://github.com/microsoft/LightGBM).
+There is a [derived implementation part of AdaCore](https://github.com/AdaCore/VSS).
+
## Users
The fast_float library is used by [Apache Arrow](https://github.com/apache/arrow/pull/8494) where it multiplied the number parsing speed by two or three times. It is also used by [Yandex ClickHouse](https://github.com/ClickHouse/ClickHouse) and by [Google Jsonnet](https://github.com/google/jsonnet).
@@ -135,14 +158,14 @@ It can parse random floating-point numbers at a speed of 1 GB/s on some systems.
<img src="http://lemire.me/blog/wp-content/uploads/2020/11/fastfloat_speed.png" width="400">
```
-$ ./build/benchmarks/benchmark
+$ ./build/benchmarks/benchmark
# parsing random integers in the range [0,1)
-volume = 2.09808 MB
-netlib : 271.18 MB/s (+/- 1.2 %) 12.93 Mfloat/s
-doubleconversion : 225.35 MB/s (+/- 1.2 %) 10.74 Mfloat/s
-strtod : 190.94 MB/s (+/- 1.6 %) 9.10 Mfloat/s
-abseil : 430.45 MB/s (+/- 2.2 %) 20.52 Mfloat/s
-fastfloat : 1042.38 MB/s (+/- 9.9 %) 49.68 Mfloat/s
+volume = 2.09808 MB
+netlib : 271.18 MB/s (+/- 1.2 %) 12.93 Mfloat/s
+doubleconversion : 225.35 MB/s (+/- 1.2 %) 10.74 Mfloat/s
+strtod : 190.94 MB/s (+/- 1.6 %) 9.10 Mfloat/s
+abseil : 430.45 MB/s (+/- 2.2 %) 20.52 Mfloat/s
+fastfloat : 1042.38 MB/s (+/- 9.9 %) 49.68 Mfloat/s
```
See https://github.com/lemire/simple_fastfloat_benchmark for our benchmarking code.
@@ -183,23 +206,23 @@ You should change the `GIT_TAG` line so that you recover the version you wish to
## Using as single header
-The script `script/amalgamate.py` may be used to generate a single header
+The script `script/amalgamate.py` may be used to generate a single header
version of the library if so desired.
-Just run the script from the root directory of this repository.
+Just run the script from the root directory of this repository.
You can customize the license type and output file if desired as described in
the command line help.
You may directly download automatically generated single-header files:
-https://github.com/fastfloat/fast_float/releases/download/v1.1.2/fast_float.h
+https://github.com/fastfloat/fast_float/releases/download/v3.4.0/fast_float.h
## Credit
-Though this work is inspired by many different people, this work benefited especially from exchanges with
-Michael Eisel, who motivated the original research with his key insights, and with Nigel Tao who provided
+Though this work is inspired by many different people, this work benefited especially from exchanges with
+Michael Eisel, who motivated the original research with his key insights, and with Nigel Tao who provided
invaluable feedback. Rémy Oudompheng first implemented a fast path we use in the case of long digits.
-The library includes code adapted from Google Wuffs (written by Nigel Tao) which was originally published
+The library includes code adapted from Google Wuffs (written by Nigel Tao) which was originally published
under the Apache 2.0 license.
## License
diff --git a/contrib/restricted/fast_float/include/fast_float/digit_comparison.h b/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
index 3202718bc1..77c710f57f 100644
--- a/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
+++ b/contrib/restricted/fast_float/include/fast_float/digit_comparison.h
@@ -86,7 +86,7 @@ fastfloat_really_inline void round(adjusted_mantissa& am, callback cb) noexcept
if (-am.power2 >= mantissa_shift) {
// have a denormal float
int32_t shift = -am.power2 + 1;
- cb(am, std::min(shift, 64));
+ cb(am, std::min<int32_t>(shift, 64));
// check for round-up: if rounding-nearest carried us to the hidden bit.
am.power2 = (am.mantissa < (uint64_t(1) << binary_format<T>::mantissa_explicit_bits())) ? 0 : 1;
return;
diff --git a/contrib/restricted/fast_float/include/fast_float/float_common.h b/contrib/restricted/fast_float/include/fast_float/float_common.h
index 9374cdffd4..55a2e4c32b 100644
--- a/contrib/restricted/fast_float/include/fast_float/float_common.h
+++ b/contrib/restricted/fast_float/include/fast_float/float_common.h
@@ -11,12 +11,11 @@
|| defined(__amd64) || defined(__aarch64__) || defined(_M_ARM64) \
|| defined(__MINGW64__) \
|| defined(__s390x__) \
- || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) \
- || defined(__EMSCRIPTEN__))
+ || (defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) || defined(__PPC64LE__)) )
#define FASTFLOAT_64BIT
#elif (defined(__i386) || defined(__i386__) || defined(_M_IX86) \
|| defined(__arm__) || defined(_M_ARM) \
- || defined(__MINGW32__))
+ || defined(__MINGW32__) || defined(__EMSCRIPTEN__))
#define FASTFLOAT_32BIT
#else
// Need to check incrementally, since SIZE_MAX is a size_t, avoid overflow.
@@ -41,7 +40,9 @@
#define FASTFLOAT_VISUAL_STUDIO 1
#endif
-#ifdef _WIN32
+#if defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__
+#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#elif defined _WIN32
#define FASTFLOAT_IS_BIG_ENDIAN 0
#else
#if defined(__APPLE__) || defined(__FreeBSD__)