text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>#pragma once
#include <Common/HashTable/HashSet.h>
#include <Common/HashTable/HashTableAllocator.h>
#include <Common/HashTable/StringHashTable.h>
template <typename Key>
struct StringHashSetCell : public HashTableCell<Key, StringHashTableHash, HashTableNoState>
{
using Base = HashTableCell<Key, Stri... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/HashTable/HashMap.h>
#include <Common/HashTable/HashTable.h>
#include <bit>
#include <new>
using StringKey8 = UInt64;
using StringKey16 = UInt128;
struct StringKey24
{
UInt64 a;
UInt64 b;
UInt64 c;
bool operator==(const StringKey24 rhs) const { return a =... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/HashTable/TwoLevelHashTable.h>
#include <Common/HashTable/HashMap.h>
template
<
typename Key,
typename Cell,
typename Hash = DefaultHash<Key>,
typename Grower = TwoLevelHashTableGrower<>,
typename Allocator = HashTableAllocator,
template <typename .... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>all_once(bucket_prefix_once, [this]()
{
size_t run = 0;
for (UInt32 i = 0; i < NUM_BUCKETS; ++i)
{
bucket_cells_prefix[i] = run;
run += impls[i].getBufferSizeInCells();
}
});
return bucket_cells_prefix... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>_INLINE operator[](const Key & x)
{
bool inserted = false;
LookupResult it;
this->emplace(x, it, inserted);
if (inserted)
new (&it->getMapped()) TMapped();
return it->getMapped();
}
};
<|fim_prefix|>#pragma once
#include <Common/HashTable/String... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <Common/HashTable/StringHashTable.h>
template <typename SubMaps, typename ImplTable = StringHashTable<SubMaps>, size_t BITS_FOR_BUCKET = 8>
class TwoLevelStringHashTable : private boost::noncopyable
{
protected:
using HashValue = size_t;
using Self = TwoLevelStringHashTable;
public:
... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <Core/Types.h>
#include <Common/BitHelpers.h>
#include <base/types.h>
#include <Functions/hilbertDecode2DLUT.h>
#include <base/defines.h>
#include <array>
#include <set>
namespace HilbertDetails
{
struct Segment // represents [begin; end], all bounds are included
{
UInt64 begin... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/HistogramMetrics.h>
#include <Common/SipHash.h>
#include <algorithm>
#include <mutex>
#include <boost/container_hash/hash.hpp>
namespace HistogramMetrics
{
MetricFamily & AzureBlobConnect = Factory::instance().registerMetric(
"azure_connect_microseconds",
"Time to es... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/defines.h>
#include <base/types.h>
#include <Common/SharedMutex.h>
#include <atomic>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <unordered_map>
#include <vector>
namespace HistogramMetrics
{
using Value = Float64;
using Buckets = std::vector<... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>etFail(now))
CurrentMetrics::add(metrics.banned_count);
}
ProfileEvents::increment(metrics.failed);
update();
}
Poco::Net::IPAddress HostResolver::selectBest()
{
chassert(!records.empty());
auto random_weight_picker = std::uniform_int_distribution<size_t>(0, getTotalWeigh... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/CurrentMetrics.h>
#include <Common/HTTPConnectionPool.h>
#include <Common/ProfileEvents.h>
#include <Common/logger_useful.h>
#include <base/defines.h>
#include <Poco/Net/IPAddress.h>
#include <mutex>
#include <memory>
// That class resolves host into multiply addresses
/... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <algorithm>
#include <limits>
#include <tuple>
#include <type_traits>
/** This class provides a way to evaluate the error in the result of applying the HyperLogLog algorithm.
* Empirical observations show that large errors occur at E < 5 * 2^precision, where
* E is the return v... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <base/types.h>
#include <Common/HyperLogLogBiasEstimator.h>
#include <Common/CompactArray.h>
#include <Common/HashTable/Hash.h>
#include <Common/transformEndianness.h>
#include <IO/ReadBuffer.h>
#include <IO/WriteBuffer.h>
#include <bit>
#include <cmath>
#include <string>
namespace DB
{
namesp... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <boost/noncopyable.hpp>
#include <Common/HyperLogLogCounter.h>
#include <Common/HashTable/SmallTable.h>
namespace DB
{
/** For a small number of keys - an array of fixed size "o<|fim_suffix|> typename Hash = IntHash32<Key>,
typename DenominatorType = double>
class HyperL... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/ICachePolicyUserQuota.h>
#include <base/UUID.h>
#include <functional>
#include <memory>
#include <optional>
namespace DB
{
template <typename T>
struct EqualWeightFunction
{
size_t operator()(const T &) const
{
return 1;
}
};
template <typename TKey, ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <base/UUID.h>
#include <base/types.h>
namespace DB
{
/// Per-user quotas for usage of shared caches, used by ICachePolicy.
/// Currently allows to limit
/// - the maximum amount of cache memory a user may consume
/// - the maximum number of items a user can store in the cache
/// ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>lude <Common/Exception.h>
#include <Common/NamePrompter.h>
#include <base/types.h>
#include <Poco/String.h>
#include <unordered_map>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
/** If stored objects may have several names (aliases)
* this interface may be helpful
* ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/IO.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>
bool writeRetry(int fd, const char * data, size_t size)
{
if (!size)
size = strlen(data);
while (size != 0)
{
ssize_t res = ::write(fd, data, size);
if ((-1 == res || 0 == res) && errno ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <|fim_suffix|>turn true if write was succeed, otherwise false.
bool writeRetry(int fd, const char * data, size_t size = 0);
<|fim_middle|><cstddef>
/// IO helpers
/// Write loop with EINTR handling.
///
/// This function is safe to use in static initializers.
///
/// @param size -... | fim | ClickHouse/ClickHouse | c |
#include <Common/IPv6ToBinary.h>
#include <Poco/Net/IPAddress.h>
#include <Poco/ByteOrder.h>
#include <Common/formatIPv6.h>
#include <cstring>
#include <bit>
namespace DB
{
/// Result array could be indexed with all possible uint8 values without extra check.
/// For values greater than 128 we will store same value... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <array>
#include <base/types.h>
namespace Poco { namespace Net { class IPAddress; }}
namespace DB
{
/// Convert IP address to raw binary with IPv6 data (big endian). If it's an IPv4, map it to IPv6.
/// Saves result into the first 16 bytes of `res`.
void IPv6ToRawBinary(const Poco... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> supports preemption.
class ISlotLease : public IAcquiredSlot
{
public:
explicit ISlotLease(size_t slot_id_)
: IAcquiredSlot(slot_id_)
{}
/// This method is for CPU consumption only.
/// It should be called from a thread that started using the slot.
/// Required for obtaining ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Poco/Net/Throttler.h>
#include <Common/ProfileEvents.h>
#include <base/types.h>
#include <boost/core/noncopyable.hpp>
#include <memory>
namespace DB
{
/// Interface for throttling operations, allowing to limit the speed of operations in tokens per second.
/// Tokens are usually r... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/CounterInFile.h>
/** Allows to get an auto-increment number, storing it in a file.
* Intended for rare calls (not designed for performance).
*/
class Increment
{
pub<|fim_suffix|>atic_cast<Int64>(count), create_if_need) - count + 1);
}
/// Change the path to t... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>~InterruptListener()
{
unblock();
}
bool check()
{
if (!active)
return false;
timespec timeout = { 0, 0 };
if (-1 == sigtimedwait(&sig_set, nullptr, &timeout))
{
if (errno == EAGAIN)
return false;
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/IntervalKind.h>
#include <Common/Exception.h>
#include <base/EnumReflection.h>
#include <string_view>
#include <unordered_map>
namespace DB
{
namespace ErrorCodes
{
extern const int BAD_ARGUMENTS;
}
std::string_view IntervalKind::toString() const
{
return magic_enum::enum_nam... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> M(Day) \
M(Week) \
M(Month) \
M(Quarter) \
M(Year)
}
<|fim_prefix|>#pragma once
#include <base/types.h>
namespace DB
{
/// Kind of a temporal interval.
struct IntervalKind
{
/// note: The order and numbers are important and used in binary encoding, append new interval kinds to th... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>& node = nodes[current_index];
node.middle_element = median;
node.sorted_intervals_range_start_index = sorted_intervals_range_start_index;
node.sorted_intervals_range_size = intervals_sorted_by_left_asc.size();
size_t left_child_index = current_index * 2 + 1;
stack... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> auto & interval_right_sorted_desc = getInterval(interval_with_value_right_sorted_desc);
if (interval_right_sorted_desc.right < point)
break;
bool should_continue = callCallback(interval_with_value_right_sorted_desc, callback);
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/JSONBuilder.h>
#include <IO/WriteHelpers.h>
#include <Common/typeid_cast.h>
namespace DB::JSONBuilder
{
static bool isArrayOrMap(const IItem & item)
{
return typeid_cast<const JSONArray *>(&item) || typeid_cast<const JSONMap *>(&item);
}
static bool isSimpleArray(const std::vector<... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <type_traits>
#include <vector>
#include <IO/WriteBuffer.h>
#include <IO/WriteHelpers.h>
namespace DB
{
struct FormatSettings;
}
namespace DB::JSONBuilder
{
struct FormatSettings
{
const DB::FormatSettings & settings;
size_t indent = 2;
bool print_simple_arrays_in_single_row = true;... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ns JSON* are not supported");
}
}
<|fim_prefix|>#include <Common/Exception.h>
#include <Common/JSONParsers/DummyJSONParser.h>
namespace DB
{
namespace ErrorCodes
{
extern const int NOT_IMPLEMENTED;
}
bool DummyJSONParser::parse(std:<|fim_middle|>:string_view, Element &)
{
throw Exception(ErrorCodes... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>
/// Optional: Provides access to an object's element by index.
KeyValuePair operator[](size_t) const { return {}; }
#endif
};
/// Parses a JSON document, returns the reference to its root element if succeeded.
bool parse(std::string_view, Element &);
#if 0
/// Optional: ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
names<|fim_suffix|>djson's for fast conversion
enum class ElementType : uint8_t
{
ARRAY = '[',
OBJECT = '{',
INT64 = 'l',
UINT64 = 'u',
DOUBLE = 'd',
STRING = '"',
BOOL = 't',
NULL_VALUE = 'n'
};
}
<|fim_middle|>pace DB
{
// Enum values match sim<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> rapidjson::Value::ConstValueIterator it;
};
ALWAYS_INLINE Array(const rapidjson::Value & value_) : ptr(&value_) {} /// NOLINT
ALWAYS_INLINE Iterator begin() const { return ptr->Begin(); }
ALWAYS_INLINE Iterator end() const { return ptr->End(); }
ALWAYS_INL... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/JSONParsers/SimdJSONParser.h>
#if USE_SIMDJSON
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int CANNOT_ALLOCATE_MEMORY;
extern const int UNKNOWN_EXCEPTION;
}
void SimdJSONParser::reserve(size_t max_size)
{
auto res = parser.allocate(max_size);
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include "config.h"
#if USE_SIMDJSON
# include <base/types.h>
# include <base/defines.h>
# include <simdjson.h>
# include <Common/JSONParsers/ElementTypes.h>
# include <Common/PODArray_fwd.h>
# include <Common/PODArray.h>
# include <charconv>
namespace DB
{
/// Format... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/JSONWebKey.h>
#if USE_SSL
#include <fmt/format.h>
#include <Common/Base64.h>
#include <Common/Exception.h>
#include <Comm<|fim_suffix|>.n = n_enc,
.kty = "RSA",
};
}
}
#endif
<|fim_middle|>on/Crypto/KeyPair.h>
#include <string>
namespace DB
{
namespace ErrorCodes
{
e... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>f
<|fim_prefix|>#pragma once
#include "config.h"
#include <string>
#if USE_SSL
namespace DB
{
class KeyPair;
/// Represents a JSON Web Key (JWK) for RSA keys.
/// See RFC 7517.
struct JSONWebKey
{
/// The public exponent of the RSA key.
std::string e;
/// The modulus of the RSA key.
s... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/Jemalloc.h>
#if USE_JEMALLOC
# include <Common/Exception.h>
# include <Common/FramePointers.h>
# include <Common/MemoryTracker.h>
# include <Common/StackTrace.h>
# include <Common/Stopwatch.h>
# include <Common/TraceSender.h>
# include <Common/logger_useful.h>
# ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ds_num = "jemalloc_max_background_threads_num";
constexpr auto config_collect_global_profile_samples_in_trace_log = "jemalloc_collect_global_profile_samples_in_trace_log";
constexpr auto config_profiler_sampling_rate = "jemalloc_profiler_sampling_rate";
}
#if USE_JEMALLOC
#include <string_view>
#includ... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>
auto trace_free = CurrentMemoryTracker::free(old_size);
trace_free.onFree(buf, old_size);
trace_alloc.onAlloc(new_buf, new_size);
return new_buf;
}
#endif
<|fim_prefix|>#include "config.h"
#if USE_JEMALLOC
#include <Common/JemallocCacheAllocator.h>
#include <Common/JemallocCacheArena.... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>llocator.h>
using JemallocCacheAllocator = Allocator<false, false>;
#endif
<|fim_prefix|>#pragma once
#include "config.h"
#if USE_JEMALLOC
#include <cstddef>
/// Allocator for long-lived cache data (mark cache, uncompressed cache, page cache).
///
/// Without arena isolation, jemalloc places cache al... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>Events::increment(ProfileEvents::MemoryAllocatorPurgeTimeMicroseconds, watch.elapsedMicroseconds());
}
}
#else
namespace DB::JemallocCacheArena
{
void setEnabled(bool) {}
bool isEnabled() { return false; }
unsigned getArenaIndex() { return 0; }
void purge() {}
}
#endif
<|fim_prefix|>#include <Common... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>alloc is not available.
unsigned getArenaIndex();
/// Purge dirty pages only in the cache arena, returning memory to the OS.
/// No-op if disabled or jemalloc is not available.
void purge();
}
<|fim_prefix|>#pragma once
namespace DB::JemallocCacheArena
{
/// Enable or disable the dedicated cache aren... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>urn a transient allocator failure or any environment that disallows extra
/// arenas into hard exceptions. Fall back to arena 0 — passing 0 to
/// `ScopedJemallocThreadArena` is already a documented no-op that allocates from the
/// default arena. The cost is degraded fragmentation... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>witch the calling thread's preferred arena (via
/// `mallctl("thread.arena", ...)`) using `ScopedJemallocThreadArena` for the duration
/// of any block that calls into LLVM. See `ScopedJemallocThreadArena` in `Common/Jemalloc.h`.
unsigned getArenaIndex();
/// Whether the dedicated JIT arena is available ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/JemallocMergeTreeArena.h>
#include "config.h"
#if USE_JEMALLOC
#include <Common/Jemalloc.h>
#include <Common/ProfileEvents.h>
#include <Common/Stopwatch.h>
#include <Common/logger_useful.h>
#include <fmt/format.h>
#include <jemalloc/jemalloc.h>
#include <string>
namespace ProfileEven... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>e dirty pages only in the MergeTree arena, returning memory to the OS.
/// No-op if the arena is not available (`isEnabled()` returns false).
void purge();
}
<|fim_prefix|>#pragma once
namespace DB::JemallocMergeTreeArena
{
/// Returns the jemalloc arena index dedicated to long-lived MergeTree heap st... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/KnownObjectNames.h>
#include <Poco/String.h>
namespace DB
{
bool KnownObjectNames<|fim_suffix|>s.begin(), names.end());
}
KnownTableFunctionNames & KnownTableFunctionNames::instance()
{
static KnownTableFunctionNames the_instance;
return the_instance;
}
KnownFormatNames & Kn... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ames
{
public:
static KnownFormatNames & instance();
};
}
<|fim_prefix|>#pragma once
#include <mutex>
#include <unordered_set>
#include <vector>
#include <base/types.h>
namespace DB
{
class KnownObjectNames
{
public:
bool exists(const String & name) const;
void add(const String & name, bo... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ntinue;
/// Decode the inline coverage mapping for this function.
/// Format (all ULEB128):
/// 1. NumFileMappings — number of files in virtual file mapping
/// 2. NumFileMappings × FilenameIndex (index into FilenamesRef table)
/// 3. NumExpressions
/... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#if defined(__ELF__) && WITH_COVERAGE_DEPTH
#include <cstdint>
#include <string>
#include <vector>
namespace DB
{
struct CoverageRegion
{
uint64_t name_hash; /// Matches __llvm_profile_data::NameRef
uint64_t func_hash; /// Matches __llvm_profile_data::FuncHash
uint32_t counter_id; /... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/ICachePolicy.h>
#include <Common/CurrentMetrics.h>
#include <list>
#include <unordered_map>
namespace DB
{
/// Cache policy LRU evicts entries which are not used for a long time. Also see cache policy SLRU for reference.
/// WeightFunction is a functor that takes Mapped as... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <atomic>
#include <chrono>
#include <list>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <unordered_set>
#include <Common/logger_useful.h>
namespace DB
{
template <typename T>
struct TrivialLRUResourceCacheWeightFunction
{
size_t operator()(const T &) con... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include "config.h"
#include <Common/LibSSHInitializer.h><|fim_suffix|>rc = ssh_init();
if (rc != SSH_OK)
{
throw DB::Exception(DB::ErrorCodes::SSH_EXCEPTION, "Failed to initialize libssh");
}
}
LibSSHInitializer::~LibSSHInitializer()
{
ssh_finalize();
}
}
#else
namespace ssh
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ic LibSSHInitializer & instance();
~LibSSHInitializer();
private:
LibSSHInitializer(); // NOLINT
};
}
<|fim_prefix|>#pragma once
namespace ssh<|fim_middle|>
{
class LibSSHInitializer
{
public:
LibSSHInitializer(const LibSSHInitializer &) = delete;
LibSSHInitializer & operator=(const L... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>iority)
{
case SSH_LOG_NOLOG:
break;
case SSH_LOG_WARNING:
LOG_WARNING(logger, "{}", buffer);
break;
case SSH_LOG_PROTOCOL:
LOG_TRACE(logger, "{}", buffer);
break;
case SSH_LOG_PACKET:
LOG_TEST(logg... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pr<|fim_suffix|>oid initialize();
}
<|fim_middle|>agma once
namespace ssh::libsshLogger
{
v<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/AllocatorWithMemoryTracking.h>
#include <list>
namespace DB
{
/// We do track memory allocations from standard containers by default, but we do it through
/// non-throwing methods of the `MemoryTracker` (see `trackMemory` in src/Common/memory.h).
/// The followi<|fim_suff... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> if (length < 10)
throw std::runtime_error("Cannot parse LocalDate: " + std::string(s, length));
m_month = (s[5] - '0') * 10 + (s[6] - '0');
m_day = (s[8] - '0') * 10 + (s[9] - '0');
}
else
{
m_month = (s[4] -'0') * 10 + (s[5] -'0');
m_day = (s[... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/DateLUT.h>
#include <base/DayNum.h>
#include <strin<|fim_suffix|>teLUTImpl & time_zone = DateLUT::instance())
{
init(time, time_zone);
}
explicit LocalDate(DayNum day_num, const DateLUTImpl & time_zone = DateLUT::instance());
explicit LocalDate(Ext... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/DateLUTImpl.h>
#include <Common/LocalDateTime.h>
void LocalDateTime::init(time_t time, const DateLUTImpl & time_zone)
{
DateLUTImpl::DateTimeComponents components = time_zone.toDateTimeComponents(static_cast<DateLUTImpl::Time>(time));
m_year = components.date.year;
m_month =... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> sizeof(*this));
}
bool operator!= (const LocalDateTime & other) const
{
return !(*this == other);
}
};
static_assert(sizeof(LocalDateTime) == 8);
<|fim_prefix|>#pragma once
#include <Common/DateLUT.h>
#include <Common/LocalDate.h>
#include <string>
/** Stores calendar date an... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ator< (const LocalTime & other) const
{
return totalSeconds() < other.totalSeconds();
}
bool operator> (const LocalTime & other) const
{
return totalSeconds() > other.totalSeconds();
}
bool operator<= (const LocalTime & other) const
{
return totalSecon... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> /// Must be destroyed first.
lock.reset();
lock_watch->stop();
if (wait_watch->elapsedMilliseconds() > THRESHOLD_MILLISECONDS)
{
LOG_WARNING(log, "Lock acquisition took {} ms in [{}], Stack trace (when copying this message, always include the lines below):\n... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>= block_fault_injections_;
}
void LockMemoryExceptionInThread::removeUniqueLock()
{
chassert(counter == 1);
counter = 0;
level = VariableContext::Global;
block_fault_injections = false;
}
<|fim_prefix|>#include <Common/LockMemoryExceptionInThread.h>
#include <base/defines.h>
/// LockMemo... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <cstdint>
#include <Common/VariableContext.h>
/// To be able to avoid MEMORY_LIMIT_EXCEEDED Exception in destructors:
/// - either configured memory limit reached
/// - or fault injected
///
/// So this will simply ignore the configured memory limit (and avoid fault injection).
///... | fim | ClickHouse/ClickHouse | c |
#include <Poco/Logger.h>
#include <Common/Logger.h>
LoggerPtr getLogger(const std::string & name)
{
return Poco::Logger::getShared(name);
}
LoggerPtr createLogger(const std::string & name, Poco::Channel * channel, Poco::Message::Priority level)
{
return Poco::Logger::createShared(name, channel, level);
}
Log... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/defines.h>
#include <memory>
#include <Poco/Logger.h>
#include <Poco/Message.h>
namespace Poco
{
class Channel;
class Logger;
using LoggerPtr = std::shared_ptr<Logger>;
}
using LoggerPtr = Poco::LoggerPtr;
using LoggerRawPtr = Poco::Logger *;
/** RAII wrappers around Poco... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>std::shared_ptr<Poco::Logger>;
<|fim_prefix|>#pragma once
#include <memory>
namespace Poco
{
class Logger;
using Log<|fim_middle|>gerPtr = std::shared_ptr<Logger>;
}
using LoggerPtr = <|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>const char * error)
{
throw std::runtime_error(error);
}
<|fim_prefix|>#include <Common/LoggingFormatStringHelpers.h>
[[noreturn]] void functionThatFailsCompilationO<|fim_middle|>fConstevalFunctions(<|endoftext|> | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/EnumReflection.h>
#include <base/defines.h>
#include <fmt/base.h>
#include <type_traits>
#include <vector>
struct PreformattedMessage;
consteval void formatStringCheckArgsNumImpl(std::string_view str, size_t nargs);
template <typename T> constexpr std::string_view tryGetStat... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ssage = fmt::format(
" (LogSeriesLimiter: on interval from {} to {} accepted series {} / {} for the logger {})",
DateLUT::instance().timeToString(last_time),
DateLUT::instance().timeToString(now),
accepted_count,
total_count,
logger->... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <Common/Logger.h>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <Poco/Message.h>
/// This wrapper helps to avoid too frequent and noisy log messages.
/// For each pair (logger_name, format_string) it remembers when such a message w... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> {
macho_name = macho_mapped;
break;
}
}
if (macho_name.empty())
{
if (name[0] == '.')
{
macho_name = "__";
macho_name += (name + 1);
}
else
{
macho_name = name;
}
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>har * begin() const { return mapped; }
size_t size() const { return file_size; }
const std::string & getPath() const { return path; }
private:
std::string path;
MMapReadBufferFromFile in;
size_t file_size;
const char * mapped;
struct SectionInfo
{
std::string name... | fim | ClickHouse/ClickHouse | c |
#include <algorithm>
#include <unordered_map>
#include <Poco/Util/AbstractConfiguration.h>
#include <Common/Macros.h>
#include <Common/Exception.h>
#include <Common/logger_useful.h>
#include <Core/ServerUUID.h>
#include <Core/UUID.h>
#include <IO/WriteHelpers.h>
namespace DB
{
namespace ErrorCodes
{
extern const... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <Core/Names.h>
#include <Interpreters/StorageID.h>
#include <map>
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
}
class Logger;
}
namespace DB
{
using LoggerPtr = std::shared_ptr<Poco::Logger>;
/** Apply substitutions from the macr... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/MapToRange.h>
#include <Common/TargetSpecific.h>
namespace DB
{
/// SIMD-multi-versioned (x86_64_v4 / scalar baseline). The inner multiply is expressed as a
/// UInt32 × UInt32 → UInt64 widening product so the compiler emits vpmuludq (1 µop, 0.5c
/// throughput) instead of vpmullq (3 µo... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>Selector.
void mapToRange(const UInt32 * hashes, size_t n, UInt32 range_size, UInt64 * result);
}
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <cstddef>
namespace DB
{
/// Map each 32-bit hash<|fim_middle|> uniformly to [0, range_size) via multiply-and-shift (more uniform than
/// `h %... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/AllocatorWithMemoryTracking.h>
#include <map>
namespace DB
{
/// We do track memor<|fim_suffix|>ename Compare = std::less<K>>
using MapWithMemoryTracking = std::map<K, V, Compare, AllocatorWithMemoryTracking<std::pair<const K, V>>>;
template <typename K, typename V, type... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/re2.h>
#ifdef LOG_INFO
#undef LOG_INFO
#undef LOG_WARNING
#undef LOG_ERROR
#undef LOG_FATAL
#endif
#include <Common/MatchGenerator.h>
#include <base/EnumReflection.h>
#include <Common/Exception.h>
#include <Common/thread_local_rng.h>
#include <map>
#include <functional>
namespace DB... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> using RegexpPtr = std::unique_ptr<re2::Regexp, RegexpPtrDeleter>;
RegexpPtr regexp;
std::function<String()> generatorFunc;
};
}
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <functional>
#include <memory>
namespace re2
{
class Regexp;
}
namespace DB
{
class RandomString... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <mutex>
#include <Common/MemoryTrackerUtils.h>
#include <Common/MemorySpillScheduler.h>
#include <Processors/IProcessor.h>
namespace DB
{
void MemorySpillScheduler::checkAndSpill(IProcessor * processor)
{
chassert(processor->isSpillable());
if (!enable || !getHardLimit())
return... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <atomic>
#include <memory>
#include <mutex>
#include <unordered_map>
#include <base/types.h>
namespace DB
{
class IProcessor;
struct ProcessorMemoryStats
{
// The total spillable memory in the processor
Int64 spillable_memory_bytes = 0;
// To avoid this processor cause ... | fim | ClickHouse/ClickHouse | c |
#if defined(OS_LINUX) || defined(OS_FREEBSD)
#include <sys/types.h>
#include <sys/stat.h>
#if defined(OS_FREEBSD)
#include <sys/sysctl.h>
#include <sys/user.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#include <Common/MemoryStatisticsOS.h>
#include <Common/logger_useful.h>
#include <base/getPageSize.h>
#include... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>const;
private:
#if defined(OS_LINUX)
int fd;
#endif
#if defined(OS_FREEBSD)
size_t pagesize;
pid_t self;
#endif
};
}
#endif
<|fim_prefix|>#pragma once
#if defined(OS_LINUX) || defined(OS_FREEBSD)
#include <cstdint>
#if defined(OS_FREEBSD)
#include <unistd.h>
#endif
namespace DB
{
/** Op... | fim | ClickHouse/ClickHouse | c |
#include <Common/Jemalloc.h>
#include <Common/MemoryTracker.h>
#include <Common/StackTrace.h>
#include <IO/WriteHelpers.h>
#include <Common/Exception.h>
#include <Common/HashTable/Hash.h>
#include <Common/CurrentMetrics.h>
#include <Common/CurrentThread.h>
#include <Common/ThreadStatus.h>
#include <Common/LockMemoryEx... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <algorithm>
#include <atomic>
#include <chrono>
#include <type_traits>
#include <base/types.h>
#include <Common/AllocationTrace.h>
#include <Common/CacheLine.h>
#include <Common/CurrentMetrics.h>
#include <Common/VariableContext.h>
#if !defined(NDEBUG)
#define MEMORY_TRACKER_DEBUG_... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>emoryTrackerBlockerInThread & MemoryTrackerBlockerInThread::operator=(MemoryTrackerBlockerInThread && rhs) noexcept
{
reset();
previous_level = std::exchange(rhs.previous_level, std::nullopt);
return *this;
}
void MemoryTrackerBlockerInThread::reset()
{
if (previous_level.has_value())
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>level;
}
};
<|fim_prefix|>#pragma once
#include <optional>
#include <Common/VariableContext.h>
namespace DB
{
class PageCache;
class TraceCollector;
}
/// Temporarily stop memory tracking for the current thread.
///
/// Note, that this is more powerful way for blocking memory tracker,
/// use this ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/MemoryTrackerSwitcher.h>
#include <Common/CurrentThread.h>
#include <Common/ThreadStatus.h>
namespace DB
{
MemoryTrackerSwitcher::MemoryTrackerSwitcher(MemoryTracker * new_tracker)
{
/// current_thread is not initialized for the main thread, so simply do not switch anything
if (... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/MemoryT<|fim_suffix|>xt::Max;
};
}
<|fim_middle|>racker.h>
namespace DB
{
struct MemoryTrackerSwitcher
{
explicit MemoryTrackerSwitcher(MemoryTracker * new_tracker);
~MemoryTrackerSwitcher();
private:
MemoryTracker * prev_memory_tracker_parent = nullptr;
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/MemoryTrackerUntrackedAllocationsBlockerInThread.h>
#include <cstdint>
static t<|fim_suffix|> ++MemoryTrackerUntrackedAllocationsBlockerInThreadCounter;
}
MemoryTrackerUntrackedAllocationsBlockerInThread::~MemoryTrackerUntrackedAllocationsBlockerInThread()
{
--MemoryTrackerUntrack... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>();
static bool isBlocked();
};
<|fim_prefix|>#pr<|fim_middle|>agma once
/// Use it if you need to suppress MemoryAllocatedWithoutCheck for known big allocations.
struct MemoryTrackerUntrackedAllocationsBlockerInThread
{
public:
MemoryTrackerUntrackedAllocationsBlockerInThread();
~MemoryTrac... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>
size_t getMaxThreadsForAvailableMemory(size_t max_threads, UInt64 min_free_per_thread)
{
size_t effective_threads = getMaxThreadsForAvailableMemoryImpl(max_threads, min_free_per_thread);
if (effective_threads != max_threads)
LOG_DEBUG(getLogger("MemoryTrackerUtils"), "Lower number of thre... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>mit is set.
size_t getMaxThreadsForAvailableMemory(size_t max_threads, UInt64 min_free_per_thread);
<|fim_prefix|>#pragma once
#include <optional>
#include <b<|fim_middle|>ase/types.h>
/// Return most strict (by hard limit) system (non query-level, i.e. server/user/merges/...) memory limit
std::optional... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/MemoryWorker.h>
#include <IO/ReadBufferFromFile.h>
#include <IO/ReadBufferFromFileDescriptor.h>
#include <IO/ReadBufferFromMemory.h>
#include <IO/ReadBufferFromString.h>
#include <IO/ReadHelpers.h>
#include <base/cgroupsv2.h>
#include <base/getMemoryAmount.h>
#include <Common/Jemalloc.h>... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>he decay control state machine
std::atomic<DecayState> decay_state{DecayState::Enabled};
Jemalloc::MibCache<uint64_t> epoch_mib{"epoch"};
Jemalloc::MibCache<size_t> resident_mib{"stats.resident"};
Jemalloc::MibCache<size_t> pagesize_mib{"arenas.page"};
Jemalloc::MibCache<size_t> dirty... | fim | ClickHouse/ClickHouse | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.