mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-01 22:20:50 +00:00
1a8e22c37f
* Trying compile under 32bit.. * PerformanceTest: use getMultiple*FromConfig, fix debug helpers * Missing file * clnag-format of Split ComplexKeyCacheDictionary * wip * Requested changes * wip * wip * Fix boost 1.64 and gcc7+ compile errors * More fixes * wip * Fix arm build * wip * wip * wip * wip * wip * wip * wip * clean * fix * wip * wip * clean * clean * wip * wip * Update MergeTreeSettings.h * Requested changes * Requested changes * Requested changes * Requested changes
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** Sampling factor in the form 0.1 or 1/10.
|
|
* It's important to save it as a rational number without converting it to IEEE-754.
|
|
*/
|
|
class ASTSampleRatio : public IAST
|
|
{
|
|
public:
|
|
#ifdef __SIZEOF_INT128__
|
|
using BigNum = __uint128_t; /// Must contain the result of multiplying two UInt64.
|
|
#else
|
|
// TODO: incomplete temporary fallback. change with boost::multiprecision
|
|
using BigNum = uint64_t;
|
|
#endif
|
|
|
|
struct Rational
|
|
{
|
|
BigNum numerator = 0;
|
|
BigNum denominator = 1;
|
|
};
|
|
|
|
Rational ratio;
|
|
|
|
ASTSampleRatio() = default;
|
|
ASTSampleRatio(const StringRange range_) : IAST(range_) {}
|
|
ASTSampleRatio(const StringRange range_, Rational & ratio_) : IAST(range_), ratio(ratio_) {}
|
|
|
|
String getID() const override { return "SampleRatio_" + toString(ratio); }
|
|
|
|
ASTPtr clone() const override { return std::make_shared<ASTSampleRatio>(*this); }
|
|
|
|
static String toString(BigNum num);
|
|
static String toString(Rational ratio);
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
{
|
|
settings.ostr << toString(ratio);
|
|
}
|
|
};
|
|
|
|
}
|