text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>#include <base/Decimal.h>
#include <base/defines.h>
#include <base/extended_types.h>
namespace DB
{
/// Explicit template instantiations.
#define FOR_EACH_UNDERLYING_DECIMAL_TYPE(M) \
M(Int32) \
M(Int64) \
M(Int128) \
M(Int256)
#define FOR_EACH_UNDERLYING_DECIMAL_TYPE_PASS(M, X) \
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>h<DB::Decimal256>
{
size_t operator()(const DB::Decimal256 & x) const
{
// FIXME temp solution
return std::hash<Int64>()(static_cast<Int64>(x.value >> 64 & max_uint_mask))
^ std::hash<Int64>()(static_cast<Int64>(x.value & max_uint_mask));
... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>same_v<T, UInt256>
|| std::is_same_v<T, Decimal128>
|| std::is_same_v<T, Decimal256>;
template <class T>
concept is_over_big_decimal = is_decimal<T> && is_over_big_int<typename T::NativeType>;
}
template <> struct is_signed<DB::Decimal32> { static constexpr bool value = true; };
template <> str... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> ? -1 : 1;
/// Float has no fractional part means that the numbers are equal.
if (large_and_always_integer)
return 0;
/// Make clang-tidy happy
/// We know normalizedExponent() is positive from a check at the start at the function
/// We know normalize... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ormatter<T> : fmt::formatter<std::string_view>
{
constexpr auto format(T value, auto& format_context) const
{
return formatter<string_view>::format(magic_enum::enum_name(value), format_context);
}
};
<|fim_prefix|>#pragma once
#include <magic_enum.hpp>
#include <fmt/format.h>
templat... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
// On illumos, <sys/regset.h> defines FS as a macro (x86 segment register).
// Undef it to allow use of FS as a template parameter below.
#ifdef FS
# undef FS
#endif
#include "TypeList.h"
namespace detail
{
template <class T>
struct FnTraits { template <class> static constexpr bool value ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>().items)
) > 0;
}
bool IPv6::operator==(const IPv6 & rhs) const
{
return
memcmp16(
reinterpret_cast<const unsigned char *>(toUnderType().items),
reinterpret_cast<const unsigned char *>(rhs.toUnderType().items)
) == 0;
}
}
<|fim_prefix|>#include <base/... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>;
}
};
}
<|fim_prefix|>#pragma once
#include <base/extended_types.h>
#include <base/strong_typedef.h>
namespace DB
{
struct IPv4 : StrongTypedef<UInt32, struct IPv4Tag>
{
using StrongTypedef::StrongTypedef;
using StrongTypedef::operator=;
constexpr explicit ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> case 'f':
buf += '\f';
break;
case 'n':
buf += '\n';
break;
case 'r':
buf += '\r';
break;
... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <Poco/Exception.h>
#include <base/types.h>
/** A very simple class for reading JSON (or its fragments).
* Represents a reference to a piece of memory that contains JSON (or its fragment).
* Does not create any data structures in memory. Does not allocate memory (except for std::string).
*... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>adow(X, Y) /// NOLINT
#define __msan_unpoison_string(X) /// NOLINT
#if defined(ch_has_feature)
# if ch_has_feature(memory_sanitizer)
# undef __msan_unpoison
# undef __msan_test_shadow
# undef __msan_print_shadow
# undef __msan_unpoison_string
# include <sanitizer/msa... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>
struct MoveOrCopyIfThrow<T, true>
{
void operator()(T && src, T & dst) const
{
dst = std::forward<T>(src);
}
};
template <typename T>
struct MoveOrCopyIfThrow<T, false>
{
void operator()(T && src, T & dst) const
{
ds... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> *total_memory += numa_node_size(i, nullptr);
}
}
numa_bitmask_free(membind);
}
#endif
return total_memory;
}
}
<|fim_prefix|>#include <base/Numa.h>
#include "config.h"
#if USE_NUMACTL
# include <numa.h>
#endif
namespace DB
{
std::optional<size_t> ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <optional>
namespace DB
{
/// return total memory of NUMA nodes the process is bound to
/// if NUMA is not<|fim_suffix|><size_t> getNumaNodesTotalMemory();
}
<|fim_middle|> supported or process can use all nodes, std::nullopt is returned
std::optional<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>CRC32Hash
{
size_t operator() (std::string_view x) const
{
const char * pos = x.data();
size_t size = x.size();
if (size == 0)
return 0;
chassert(pos);
if (size < 8)
{
return static_cast<unsigned>(hashLessThan8(x.data(), x.... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>Args...>) { return {}; }
template <typename F, typename ...Args>
constexpr void forEach(TypeList<Args...>, F && f) { (f(TypeList<Args>{}), ...); }
}
template <typename TypeListLeft, typename TypeListRight>
using TypeListConcat = decltype(TypeListUtils::concat(TypeListLeft{}, TypeListRight{}));
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include "TypeList.h"
#include "extended_<|fim_suffix|>tFloat>;
using TypeListDecimal = TypeList<Decimal32, Decimal64, Decimal128, Decimal256>;
using TypeListNumber = TypeListConcat<TypeListIntAndFloat, TypeListDecimal>;
using TypeListNumberWithUUID = TypeListAppend<UUID, TypeListNumber>;
}... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include "Decimal_fwd.h"
#include "UUID.h"
#include "IPv4andIPv6.h"
namespace DB
{
struct Array;
struct Tuple;
struct Map;
struct AggregateFunctionStateData;
/**
* Obtain type string representation from real type if possible.
* @example TypeName<UInt8> == "UInt8"
*/
template <class T> constexpr inlin... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <base/strong_typedef.h>
#include <base/extended_types.h>
namespace DB
{
using UUID = StrongTypedef<UInt128, struct UUIDTag>;
}
<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>f (key.empty())
continue;
std::string value;
if (arg.size() > pos_eq)
value = arg.substr(pos_eq + 1);
add_arg(key, value);
key = "";
}
Poco::Util::MapConfiguration::Keys keys;
map_config->keys(keys);
config.add(map_config, priority... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Poco/Util/Application.h>
#include <string>
#include <unordered_set>
namespace Poco::Util
{
class LayeredConfiguration; // NOLINT(cppcoreguidelines-virtual-class-destructor)
}
/// Import <|fim_suffix|>names = nullptr);
<|fim_middle|>extra command line arguments to configuration. T... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>IgnoreOverflow(x, y);
return false;
}
template <>
inline bool mulOverflow(UInt256 x, UInt256 y, UInt256 & res)
{
res = mulIgnoreOverflow(x, y);
return false;
}
}
// NOLINTEND(google-runtime-int)
<|fim_prefix|>#pragma once
#include <base/extended_types.h>
#inc... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <bit>
#include <cstring>
#include <algorithm>
#include <type_traits>
/** Returns value `from` converted to type `To` while retaining bit repres<|fim_suffix|>eof(res) - sizeof(from)) : 0;
uint32_t offset_from = (sizeof(from) > sizeof(res)) ? (sizeof(from) - sizeof(res)) : 0... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>e: It is valid to have an empty name as 'root' cgroup v2.
static const std::string v2_prefix = "0::/";
std::string cgroup;
while (std::getline(cgroup_name_file, cgroup))
{
if (cgroup.starts_with(v2_prefix))
{
cgroup = cgroup.substr(v2_prefix.length());
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ed();
/// Detects which cgroup v2 the process belongs to and returns its filesystem path.
/// Assumes that cgroupsV2Enabled() was called prior and returned true.
/// If the cgroup cannot be determined, an empty path is returned.
std::filesystem::path cgroupV2PathOfProcess();
/// Returns the most nested ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>Rep, Period>> : fmt::formatter<std::string>
{
template <typename FormatCtx>
auto format(const std::chrono::duration<Rep, Period> & duration, FormatCtx & ctx) const
{
return fmt::formatter<std::string>::format(::to_string(duration), ctx);
}
};
<|fim_prefix|>#pragma once
#include <c... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <type_traits>
#include <utility>
template <auto Val, decltype(Val)... List>
inline constexpr bool static_in_v = std::disjunction_v<std::bool_constant<Val == List>...>;
template <typename Func, typename Arg>
bool func_wrapper(Func && func, Arg && arg)
{
if constexpr (std::is_void_v<std::invo... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include "coverage.h"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#if WITH_COVERAGE && !WITH_COVERAGE_DEPTH
/// Regular coverage build (WITH_COVERAGE=ON, WITH_COVERAGE_DEPTH=OFF), the build
/// that produces the published HTML/lcov reports. The full depth machinery below
/// is not compile... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <string_view>
/// Flush coverage report to file, depending on coverage system
/// proposed by compiler (llvm for clang and gcov for gcc).
///
/// Noop if build without coverage (WITH_COVERAGE_DEPTH=0).
/// Thread safe (use exclusive lock).
/// Idempotent, may be called multiple times.
void dumpC... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <crc32-s390x.h>
inline uint32_t s390x_crc32c_u8(uint32_t crc, uint8_t <|fim_suffix|>rn crc32c_le_vx(crc, reinterpret_cast<unsigned char *>(&v), sizeof(v));
}
inline uint32_t s390x_crc32c_u16(uint32_t crc, uint16_t v)
{
v = __builtin_bswap16(v);
return crc32c_le_vx(crc, rei... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> /// function acquires a capability, but does not release it
#define TSA_TRY_ACQUIRE(...) __attribute__((try_acquire_capability(__VA_ARGS__))) /// function tries to acquire a capability and returns a boolean value indicating success or failure
#define TSA_RELEASE(...) _... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <base/demangle.h>
#include <cstdlib>
#include <cxxabi.h>
static DemangleResult tryDemangle(const char * name, int & status)
{
return DemangleResult(abi::__cxa_demangle(name, nullptr, nullptr, &status));
}
DemangleResult tryDemangle(const char * name)
{
int status = 0;
return tryDem... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <cstdlib>
#include <memory>
#include <string>
/** Demangles C++ symbol name.
* When demangling fails, returns the original name and sets status to non-zero.
* TODO: Write msvc version (now returns the same stri<|fim_suffix|>;
DemangleResult tryDemangle(const char * name);
<|f... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include "errnoToString.h"
#include <fmt/format.h>
std::string errnoToString(int the_errno)
{
const size_t buf_size = 128;
char buf[buf_size];
#ifndef _GNU_SOURCE
int rc = strerror_r(the_errno, buf, buf_size);
#ifdef OS_<|fim_suffix|>d::to_string(the_errno);
const char * code_str =... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pr<|fim_suffix|>ng errnoToString(int the_errno = errno);
<|fim_middle|>agma once
#include <cerrno>
#include <string>
std::stri<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <type_traits>
#include <base/types.h>
#include <base/wide_integer.h>
#include <base/BFloat16.h>
using Int128 = wide::integer<128, signed>;
using UInt128 = wide::integer<128, unsigned>;
using Int256 = wide::integer<256, signed>;
using UInt256 = wide::integer<256, unsigned>;
stati... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> vorrq + shrn + ctz)
/// exceeds what a handful of byte compares would do, so an unguarded
/// SIMD body regresses such workloads. An 8-byte scalar pre-check
/// covers the common short-distance hit and leaves the SIMD body for
/// the sparse case.
if (maybe_negate<positive>(is_in<symb... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <stdexcept>
#include <fstream>
#include <base/getAvailableMemoryAmount.h>
#include <base/getPageSize.h>
#include <unis<|fim_suffix|>size_t vmt_size = sizeof(vmt);
if (sysctlbyname("vm.vmtotal", &vmt, &vmt_size, NULL, 0) == 0)
return getPageSize() * vmt.t_avm;
else
return ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>vailableMemoryAmountOrZero();
/** Throws exception if it cannot determine the size of physical memory.
*/
uint64_t getAvailableMemoryAmount();
<|fim_prefix|>#pragma once
#include <cstdint>
/** Returns the size of currently available physical memory (RAM) in bytes.
* Returns 0 on unsupported platfor... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>tFQDNOrHostName()
{
static std::string result = getFQDNOrHostNameImpl();
return result;
}
<|fim_prefix|>#include <Poco/Exception.h>
#include <Poco/Net/DNS.h>
#include <base/getFQDNOrHostName.h>
<|fim_middle|>
namespace
{
std::string getFQDNOrHostNameImpl()
{
#if defined(OS_DARWIN) || defi... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <string>
/** Get the FQDN for the local server by resolving DNS hostname - similar to calling the 'hostname' tool with the -f flag.
* If it does not work, return hostname - similar to <|fim_suffix|>lags or 'uname -n'.
*/
const std::string & getFQDNOrHostName();
<|fim_middle|>c... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>nt");
return res;
}
<|fim_prefix|>#include <base/getMemoryAmount.h>
#include <base/cgroupsv2.h>
#include <base/getPageSize.h>
#include <base/Numa.h>
#include <fstream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
namespace
{
std::optio<|fim_middle|>nal<uint64_t> getCgroupsV2M... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <cstdint>
/// Returns the size in bytes of physical memory (RAM) available to the process. The value can
/// be smaller than the total available RAM available to the system due to cgroups settings.
/// Returns 0 on unsupported platform or if it cannot determine the size<|fim_suffix... | fim | ClickHouse/ClickHouse | c |
#include <base/getPageSize.h>
#include <unistd.h>
#include <cstdlib>
namespace
{
Int64 getPageSizeImpl()
{
Int64 page_size = sysconf(_SC_PAGESIZE);
if (page_size < 0)
abort();
return page_size;
}
}
Int64 staticPageSize = getPageSizeImpl();
<|endoftext|> | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>y page size
Int64 inline ALWAYS_INLINE getPageSize()
{
return staticPageSize;
}
<|fim_prefix|>#pra<|fim_middle|>gma once
#include <base/defines.h>
#include <base/types.h>
extern Int64 staticPageSize;
/// Get memor<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <base/getThreadId.h>
#if defined(OS_ANDROID)
#include <sys/types.h>
#i<|fim_suffix|>rent_tid))
throw std::logic_error("pthread_threadid_np returned error");
#endif
}
uint64_t getThreadId()
{
if (!current_tid)
setCurrentThreadId();
return current_tid;
}
void upd... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <cstdint>
/// Obtain thread id from OS. The value is cached in thread local variable.
uint64_t <|fim_suffix|>rk();
<|fim_middle|>getThreadId();
void updateCurrentThreadIdAfterFo<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> typename CityHash_v1_0_2::uint128>)
struct HexConversion<CityHashUInt128>
{
static const constexpr size_t num_hex_digits = 32;
static void hex(const CityHashUInt128 & uint_, char * out, std::string_view table)
{
HexConversion<UInt64>::hex(uint_.high64, out, ta... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>clear();
}
template <typename Container>
void insertAtEnd(Container & dest, const Container & src)
{
if (src.empty())
return;
dest.insert(dest.end(), src.begin(), src.end());
}
template <typename Container>
void insertAtEnd(Container & dest, Container && src)
{
if (src.empty())
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <|fim_suffix|>to_string.h>
namespace std
{
std::string to_string(Int8 v) /// NOLINT (cert-dcl58-cpp)
{
return to_string(int8_t{v});
}
}
<|fim_middle|><base/int8_<|endoftext|> | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <<|fim_suffix|>r<Int8> : fmt::formatter<int8_t>
{
};
namespace std
{
std::string to_string(Int8 v); /// NOLINT (cert-dcl58-cpp)
}
<|fim_middle|>base/defines.h>
#include <base/types.h>
#include <fmt/format.h>
template <>
struct fmt::formatte<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>polateExponential(double min, double max, double ratio)
{
chassert(min > 0 && ratio >= 0 && ratio <= 1);
return min * std::pow(max / min, ratio);
}
constexpr double interpolateLinear(double min, double max, double ratio)
{
return std::lerp(min, max, ratio);
}
<|fim_prefix|>#pragma once
#inclu... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <memory>
template <typename T>
bool isSharedPtrUnique(const std::shared_ptr<T> & ptr)
{
return ptr.use_count() == 1;
}
<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <type_traits>
#include <base/defines.h>
#include <base/extended_types.h>
#include <base/itoa.h>
namespace
{
ALWAYS_INLINE inline char * outOneDigit(char * p, uint8_t value)
{
*p = '0' + value;
return p + 1;
}
// Using a lookup table to convert binary numbers from 0 to 99
// into ascii c... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>nt64) \
M(Int128) \
M(Int256)
#define INSTANTIATION(T) char * itoa(T i, char * p);
FOR_INTEGER_TYPES(INSTANTIATION)
#if defined(OS_DARWIN)
INSTANTIATION(unsigned long)
INSTANTIATION(long)
#endif
#undef FOR_INTEGER_TYPES
#undef INSTANTIATION
<|fim_prefix|>#pragma once
#include <base/extended_ty... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> std::abort();
}
<|fim_prefix|>#include <version>
/// Custom assertion handler for hardened libcxx
/// See https://prereleases.llvm.org/16.0.0/rc3/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
void std::__libcpp_verbose_abort(char const * format, ...)
{
va_list list;
va_start... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <algorithm>
#include <bit>
#include <cstdint>
#include <base/MemorySanitizer.h>
#include <base/simd.h>
namespace detail
{
template <typename T>
inline int cmp(T a, T b)
{
if (a < b)
return -1;
if (a > b)
return 1;
return 0;
}
}
/// We can process un... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ents.
template <class To, class From>
typename To::iterator moveExtend(To & to, From && from)
{
return to.insert(to.end(), std::make_move_iterator(from.begin()), std::make_move_iterator(from.end()));
}
<|fim_prefix|>#pragma once
/// Extend @p <|fim_middle|>to by moving elements from @p from to @p to ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>= mmap(nullptr, new_size, mmap_prot, mmap_flags, mmap_fd, mmap_offset);
if (MAP_FAILED == new_address)
return MAP_FAILED;
memcpy(new_address, old_address, old_size);
if (munmap(old_address, old_size))
abort();
return new_address;
}
<|fim_prefix|><|fim_middle|>#include <b... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ed]] off_t mmap_offset = 0)
{
#if DISABLE_MREMAP
return mremap_fallback(old_address, old_size, new_size, flags, mmap_prot, mmap_flags, mmap_fd, mmap_offset);
#else
return mremap(
old_address,
old_size,
new_size,
flags
#if !defined(MREMAP_FIXED)
,
mm... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <base/openpty.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <|fim_suffix|> & ws)
{
int m = posix_openpt(O_RDWR | O_NOCTTY);
if (m < 0)
return -1;
if (grantpt(m) != 0 || unlockpt(m) != 0)
{
close(m);
return -1;
}
/// `ptsname` is not threa... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>npt`/`grantpt`/`unlockpt`.
/// Opens a new pseudo-terminal pair, applies the window size to the slave side,
/// and writes the master/slave file descriptors into the output references.
/// Returns 0 on success, -1 on failure with `errno` set.
int openPty(int & master_fd, int & slave_fd, const winsize & ws... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma clang diagnostic ignored "-Wreserved-identifier"
/// This code was based on the code by Fedor Korotkiy https://www.linkedin.com/in/fedor-korotkiy-659a1838/
#include <base/defines.h>
#include <base/phdr_cache.h>
#if defined(OS_LINUX) && !defined(THREAD_SANITIZER) && !defined(USE_MUSL)
#defin... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> * NOTE: It is disabled with Thread Sanitizer because TSan can only use original "dl_iterate_phdr" function.
*/
void updatePHDRCache();
/** Check if "dl_iterate_phdr" will be lock-free
* to determine if some features like Query Profiler can be used.
*/
bool hasPHDRCache();
<|fim_prefix|>#pragma onc... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>/** Origin: musl-libc /src/math/exp10.c
* https://www.musl-libc.org/
* http://git.musl-libc.org/cgit/musl/tree/src/math/exp10.c
*/
/*
musl as a whole is licensed under the following standard MIT license:
----------------------------------------------------------------------
Copyright © 2005-2014 Ri... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
/** exp10 from GNU libm fails to give precise result for integer arguments.
* For example, exp10(3) gives 1000.0000000000001
* despite t<|fim_suffix|>bols from the system libm.
*/
double preciseExp10(double x);
<|fim_middle|>he fact that 1000 is exactly representable in double and fl... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <boost/range/counting_range.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <type_traits>
namespace collections
<|fim_suffix|>::is_integral_v<Type> || std::is_enum_v<Type>)
inline auto range(Type end)
{
if constexpr (std::is_integral_v<Type>)
return interna... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> new_begin = end;
for (auto current = end; current != begin;)
{
--current;
if (std::find(new_begin, end, *current) == end)
{
--new_begin;
if (new_begin != current)
*new_begin = *current;
}
}
vec.erase(begin, new_begin)... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#if defined(OS_LINUX)
# include <sys/syscall.h>
#endif
#include <cstdlib>
#include <unistd.h>
#include <base/safeExit.h>
#include <base/defines.h> /// for THREAD_SANITIZER
#if defined(ADDRESS_SANITIZER)
# include <sanitizer/lsan_interface.h>
#endif
[[noreturn]] void safeExit(int code)
{
#if define... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
/// _exit() with a workaround for TSan.
[[noreturn]] void safeExit(int code);
<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
/// __has_feature supported only by clang.
///
/// But libcxx/libcxxabi overrides it to 0,
/// thus the checks for __has_feature will be wrong.
///
/// NOTE:
/// - __has_feature cannot be simply undefined,
/// since this will be broken if some C++ header will be included after
/// includ... | fim | ClickHouse/ClickHouse | c |
#pragma once
/// Default sanitizer runtime options and LSan suppressions shared across ClickHouse executables.
///
/// The sanitizer runtime resolves the `__{asan,lsan,msan,tsan,ubsan}_default_*` hooks by symbol
/// name, so they must be defined with external "C" linkage exactly once per binary. Include this
/// heade... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>opeGuard<F> make_scope_guard(F && function_) { return std::forward<F>(function_); }
#define SCOPE_EXIT_CONCAT(n, ...) \
const auto scope_exit##n = make_scope_guard([&] { __VA_ARGS__; })
#define SCOPE_EXIT_FWD(n, ...) SCOPE_EXIT_CONCAT(n, __VA_ARGS__)
#define SCOPE_EXIT(...) SCOPE_EXIT_FWD(__LINE__, __VA_... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <base/shift10.h>
#include "defines.h"
#include <limits>
template <typename T>
static T shift10Impl(T x, int exponent)
{
static constexpr ssize_t min_exponent = -323;
static constexpr ssize_t max_exponent = 308;
static const long double powers10[] =
{
1e-323L, 1e-322L,... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <base/types.h>
/** Almost the same as x = x * exp10(exponent), but gives more accurate result.
* Example:
* 5 * 1e-11 = 4.9999999999999995e-11
* !=
* 5e-11 = shift10(5.0, -11)
*/
double shift10(double x, int exponent);
float shift10(float x, int exponent);
long double shift10(UInt... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>4)), 0);
}
#endif
<|fim_prefix|>#pragma once
#if defined(__aarch64__) && defined(__ARM_NEON)
# include <arm_neon.h>
# pragma clang diagnostic ignored "-Wreserved-identifier"
/// Returns a 64 bit <|fim_middle|>mask of nibbles (4 bits for each byte).
inline uint64_t getNibbleMask(uint8x16_t res)... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <base/sleep.h>
#include <base/defines.h>
#include <ctime>
#include <cerrno>
#include <system_error>
#if defined(OS_DARWIN)
#include <mach/mach.h>
#include <mach/mach_time.h>
#endif
/**
* Sleep with nanoseconds precision. Tolerant to signal interruptions
*
* In case query profiler is turn... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>rMilliseconds(uint64_t milliseconds);
void sleepForSeconds(uint64_t seconds);
<|fim_prefix|>#pragma once
#include <cstdint>
/**
* Sleep functions tolerant to signal interruptio<|fim_middle|>ns (which can happen
* when query profiler is turned on for example)
*/
void sleepForNanoseconds(uint64_t ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>st, comparator());
}
/** Try to fast sort elements for common sorting patterns:
* 1. If elements are already sorted.
* 2. If elements are already almost sorted.
* 3. If elements are already sorted in reverse order.
*
* Returns true if fast sort was performed or elements were already sorted, fal... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <functional>
#include <|fim_suffix|> using UnderlyingType = T;
template <class Enable = typename std::is_copy_constructible<T>::type>
constexpr explicit StrongTypedef(const T & t_) : t(t_) {}
template <class Enable = typename std::is_move_constructible<T>::type>
con... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>;31m", /// Warning
"\033[0;33m", /// Notice
"\033[1m", /// Information
"", /// Debug
"\033[2m", /// Trace
};
return colors[priority];
}
const char * resetColor()
{
return "\033[0m";
}
<|fim_prefix|>#include <string>
#include <base/ter... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <string>
#include <base/types.h>
/** Set color in terminal based on 64-bit hash value.
* It can be used to choose some random color deterministically based on some other value.
* Hash value should <|fim_suffix|>ing setColor(UInt64 hash);
/** Set color for logger priority valu... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>time_error(err);
}
<|fim_prefix|>#include <base/throwError.h>
#include <stdexcept>
[[n<|fim_middle|>oreturn]] void throwError(const char * err)
{
throw std::run<|endoftext|> | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>:exception instead in the hope its catch block is the same as DB::Exception one.
[[noreturn]] void throwError(const char * err);
<|fim_prefix|>#pragma once
/// Throw DB::Exception-like exception before its definition.
/// DB::Exception derived from Poco::Exception derived from std::exception.
/// DB::Exc... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>OCK_MONOTONIC_FAST
#endif
<|fim_prefix|>#pragma once
#include <ctime>
#if defined (OS_DARWIN) || defined (OS_SUNOS)
# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
#elif def<|fim_middle|>ined (OS_FREEBSD)
# define CLOCK_MONOTONIC_COARSE CL<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>int64_t;
using Int16 = int16_t;
using Int32 = int32_t;
using Int64 = int64_t;
using Float32 = float;
using Float64 = double;
using String = std::string;
<|fim_prefix|>#pragma once
#include <cstdint>
#include <string>
/// Using char8_t more strict aliasing (https://stackoverflow.com/a/57453713)
using ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>, T & src)
{
static_assert(std::is_trivially_copyable_v<T>);
if constexpr (std::endian::native == endian)
memcpy(address, &src, sizeof(src));
else
reverseMemcpy(address, &src, sizeof(src));
}
template <typename T>
inline T unalignedLoadLittleEndian(const void * address)
{
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <cstddef>
conste<|fim_suffix|>NTBEGIN(google-runtime-int)
constexpr size_t operator""_KiB(unsigned long long val) { return val * KiB; }
constexpr size_t operator""_MiB(unsigned long long val) { return val * MiB; }
constexpr size_t operator""_GiB(unsigned long long val) { return val ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ed, size_t Bits2, typename Signed2>
std::common_type_t<integer<Bits, Signed>, integer<Bits2, Signed2>> constexpr
operator/(const integer<Bits, Signed> & lhs, const integer<Bits2, Signed2> & rhs);
template <typename Arithmetic, typename Arithmetic2, class = _only_arithmetic<Arithmetic, Arithmetic2>>
std::c... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
/// Original is here https://github.com/cerevra/int
/// Distributed under the Boost Software License, Version 1.0.
/// (See at http://www.boost.org/LICENSE_1_0.txt)
#include "throwError.h"
#include "defines.h"
#include <bit>
#include <cmath>
#incl<|fim_suffix|>pleLike>)
sel... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>rmatter<wide::integer<256, signed>>;
template struct fmt::formatter<wide::integer<256, unsigned>>;
<|fim_prefix|>#include <base/wide_integer.h>
#include <base/wide_integer_to_string.h>
#include <string>
#include <fmt/format.h>
namespace wide
{
template <size_t Bits, typename Signed>
inline std::string... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <string>
#include <fmt/format.h>
namespace wide
{
template <size_t Bits, typename Signed>
class integer;
}
using Int128 = wide::integer<128, signed>;
using UInt128 = wide::integer<128, unsigned>;
using Int256 = wide::integer<256, signed>;
using UInt256 = wide::integer<256, unsigned>;
namespace... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>/ providing it here prevents pulling in GLIBC_2.30.
pid_t gettid(void)
{
return syscall(__NR_gettid);
}
#if defined (__cplusplus)
}
#endif
<|fim_prefix|>/** Allows to build programs with libc 2.27 and run on systems with at least libc 2.4,
* such as Ubuntu Hardy or CentOS 5.
*
* Also look at h... | fim | ClickHouse/ClickHouse | c |
#include "memcpy.h"
__attribute__((no_sanitize("coverage")))
extern "C" void * memcpy(void * __restrict dst, const void * __restrict src, size_t size)
{
return inline_memcpy(dst, src, size);
}
<|endoftext|> | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#include <stddef.h>
#include <emmintrin.h>
/** Custom memcpy implementation for ClickHouse.
* It has the following benefits over using glibc's implementation:
* 1. Avoiding dependency on specific version of glibc's symbol, like memcpy@@GLIBC_2.14 for portability.
* 2. Avoiding indirect call via P... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>.0 : 1.0) / 0.0;
}
<|fim_prefix|>#include<|fim_middle|> "libm.h"
double __math_divzero(uint32_t sign)
{
return fp_barrier(sign ? -1<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ierf(sign ? -1.0f : 1.0f) / 0.0f;
}
<|fim_prefix|>#include "<|fim_middle|>libm.h"
float __math_divzerof(uint32_t sign)
{
return fp_barr<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> return (x - x) / (x - x);
}
<|fim_prefix|>#inclu<|fim_middle|>de "libm.h"
double __math_invalid(double x)
{
<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>/ (x - x);
}
<|fim_prefix|>#include "libm.h"
float __math_invalidf(float <|fim_middle|>x)
{
return (x - x) <|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>return __math_xflow(sign, 0x1p769);
}
<|fim_prefix|>#include "lib<|fim_middle|>m.h"
double __math_oflow(uint32_t sign)
{
<|endoftext|> | fim | ClickHouse/ClickHouse | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.