text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>// NOLINTBEGIN(readability-inconsistent-declaration-parameter-name,readability-else-after-return)
#include <csignal>
#include <sys/time.h>
#if defined(OS_LINUX)
# include <sys/sysinfo.h>
#endif
#include <sched.h>
#include <random>
#include <base/sleep.h>
#include <IO/ReadHelpers.h>
#include <Common... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>
static void signalHandler(int);
};
}
<|fim_prefix|>#pragma once
#include <cstdint>
#include <atomic>
#include <base/defines.h>
namespace DB
{
/** Allows to randomize thread scheduling and insert various glitches across whole program for testing purposes.
* It is done by setting up a timer that w... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>std::to_string(prev_thread->thread_id) : "nullptr", cur_thread ? std::to_string(cur_thread->thread_id) : "nullptr");
if (cur_thread_group != thread_group)
throw Exception(ErrorCodes::LOGICAL_ERROR, "ThreadGroupSwitcher-s are not properly nested: current thread group changed between sco... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
/// Convenience header that provides ThreadGroupSwitcher and getCurrentThreadGroup
/// without pulling in the full CurrentThread.h (which includes ThreadStatus.h).
#include <memory><|fim_suffix|>Status;
/// Returns the thread group of the current thread, or nullptr if not attached.
/// Thi... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ThreadPool.h>
#include <Common/StackTrace.h>
#include <Common/CurrentThread.h>
#include <Common/ProfileEvents.h>
#include <Common/ThreadStatus.h>
#include <Common/setThreadName.h>
#include <Common/Exception.h>
#include <Common/getNumberOfCPUCoresToUse.h>
#include <Common/OpenTelemetryTra... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <cstdint>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <list>
#include <optional>
#include <atomic>
#include <stack>
#include <random>
#include <boost/core/noncopyable.hpp>
#include <boost/heap/priority_queue.hpp>
#include <pcg_random.hpp>
#inc... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>_task = pt;
}
}
if (run_final_task_now)
{
scheduler([p = std::move(pt)]() mutable { (*p)(); }, Priority{});
}
}
void TaskTracker::waitTilInflightShrink()
{
if (!max_tasks_inflight)
return;
if (futures.size() >= max_tasks_inflight)
LOG_TEST(limited_... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <Common/threadPoolCallbackRunner.h>
#include <Common/logger_useful.h>
#include <list>
namespace DB
{
/// TaskTracker takes a Callback which is run by scheduler in some external shared ThreadPool.
/// TaskTracker brings the methods waitIfAny, waitAll/safeWaitAll
/// to help with coordination of ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
template <typename Thread>
class ThreadPoolImpl;
template <bool propagate_opentelemetry_context, bool global_trace_collector_allowed>
class ThreadFromGlobalPoolImpl;
using ThreadFromGlobalPoolNoTracingContextPropagation = ThreadFromGlobalPoolImpl<fals<|fim_suffix|>TracingContextPropagation... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> min_enabled_time);
profile_events.increment(ProfileEvents::PerfMinEnabledRunningTime,
running_time_for_min_enabled_time);
}
// Store current counter values for the next profiling period.
memcpy(previous_values, current_values, sizeof(current_values));
}
void Per... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>s & last_counters, ProfileEvents::Counters & profile_events)
{
auto current_counters = current();
incrementProfileEvents(last_counters, current_counters, profile_events);
last_counters = current_counters;
}
private:
static UInt64 getClockMonotonic()
{
struc... | fim | ClickHouse/ClickHouse | c |
#pragma once
#include <cstddef>
namespace DB
{
/// Desired stack size (in bytes) for the worker threads we create ourselves.
///
/// macOS gives secondary threads only a 512 KiB stack by default (the main thread gets 8 MiB),
/// and there is no process-wide knob to change that default - unlike Linux, where the defau... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ThreadStatus.h>
#include <Core/Settings.h>
#include <Interpreters/Context.h>
#include <base/getPageSize.h>
#include <Common/CurrentThread.h>
#include <Common/ErrnoException.h>
#include <Common/Exception.h>
#include <Common/MemoryTrackerBlockerInThread.h>
#include <Common/QueryProfiler.h>... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>dlers.
static_assert(std::atomic<bool>::is_always_lock_free);
[[maybe_unused]] bool jemalloc_profiler_enabled = false;
struct TimePoint
{
void setUp();
UInt64 nanoseconds() const;
UInt64 microseconds() const;
UInt64 seconds() const;
UInt64 elapsed... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/ThreadStackSize.h>
#if defined(OS_DARWI<|fim_suffix|>e = std::make_unique<Closure>(std::forward<Function>(f), std::forward<Args>(args)...);
pthread_attr_t attr;
if (int err = pthread_attr_init(&attr); err != 0)
throw std::system_error(err, std::... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>g() const
{
return block_count.load(std::memory_order_relaxed) > 0 || (parent && parent->isThrottling());
}
Int64 Throttler::getAvailable()
{
// To update bucket state and receive current number of token in a thread-safe way
size_t count_value = 0;
double tokens_value = 0.0;
throttleI... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <Common/IThrottler.h>
#include <Common/ProfileEvents.h>
#include <mutex>
#include <base/sleep.h>
#include <base/types.h>
#include <atomic>
namespace DB
{
/** Allows you to limit the speed of something (in tokens per second) using sleep.
* Implemented using Token Bucket Throttling algorithm.
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/IThrottler.h>
#include <array>
#include <limits>
namespace DB
{
/// A throttler that combines multiple throttlers into a single interface.
/// It allows you to create an array of throttlers with a fixed size and use them collec<|fim_suffix|> override
{
for (con... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> if a rogue 3rd-party library closed our file descriptor by mistake
* (for example by double closing due to the lack of exception safety or if it is a crappy code in plain C)
* and then another file descriptor is opened in its place.
*
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#if defined(OS_LINUX)
#include <Poco/Timespan.h>
namespace DB
{
/// Wrapper over timerfd.
class TimerD<|fim_suffix|>onst;
};
}
#endif
<|fim_middle|>escriptor
{
private:
int timer_fd;
public:
TimerDescriptor();
~TimerDescriptor();
TimerDescriptor(const TimerDescriptor &) =... | fim | ClickHouse/ClickHouse | c |
#include <IO/WriteBufferFromFileDescriptorDiscardOnFailure.h>
#include <IO/WriteHelpers.h>
#include <Common/CPUID.h>
#include <Common/CurrentThread.h>
#include <Common/ThreadStatus.h>
#include <Common/MemoryTracker.h>
#include <Common/MemoryTrackerBlockerInThread.h>
#include <Common/StackTrace.h>
#include <Common/Trace... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>
/// Coordinate shutdown with concurrent `send()` callers (which may run from
/// profiler signal handlers on any thread). `TraceCollector::~TraceCollector`
/// sets `shutdown = true` and waits for `in_flight` to reach zero before
/// closing the pipe, so `close()` cannot race with any in... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/TransactionID.h>
#include <Common/SipHash.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
namespace DB
{
TIDHash TransactionID::getHash() const
{
SipHash hash;
hash.update(start_csn);
hash.update(local_tid);
hash.update(host_id);
return hash.get64();
}
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Core/Types.h>
#include <Core/UUID.h>
#include <IO/WriteHelpers.h>
#include <fmt/format.h>
namespace DB
{
class IDataType;
using DataTypePtr = std::shared_ptr<const IDataType>;
class MergeTreeTransaction;
class ReadBuffer;
class WriteBuffer;
/// This macro is useful for places w... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/typeid_cast.h>
namespace DB
{
/* This base class adds public methods:
* - Derived * as<Derived>()
* - const Derived * as<Derived>() const
* - Derived & as<Derived &>()
* - const Derived & as<Derived &>() const
*/
template <class Base>
class TypePromot... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> if (executable_finished)
return;
/// Wall time from sampler construction to `ShellCommandSource` cleanup (includes
/// spawn, output parsing, and IO). The executable path spawns a fresh child per
/// invocation, so there is no pool-wait interval to subtract.
elapsed_us = entry_w... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <Common/Stopwatch.h>
#include <atomic>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <sys/types.h>
namespace DB
{
/** Per-invocation resource accounting for executable UDF calls.
*
* Created by `UserDefinedExecutableFun... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>OFTWARE.
static const UInt8 TABLE[] =
{
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 00..1f
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 20..3f
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 40..5f
0,0,0,0,0,0,0,0,0,0,0,0,... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <optional>
#include <base/types.h>
#include <base/simd.h>
#include <Common/BitHelpers.h>
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#if defined(__aarch64__) && defined(__ARM_NEON)
# include <arm_neon.h>
# pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
... | fim | ClickHouse/ClickHouse | c |
#include <cstring>
#include <cmath>
#include <string>
#include <base/types.h>
#include <base/arithmeticOverflow.h>
#include <Common/Exception.h>
#include <Common/UnicodeBar.h>
#include <Common/NaNUtils.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
}
namespace UnicodeB... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ax_width);
size_t getWidthInBytes(double width);
/// In `dst` there must be a space for barWidthInBytes(width) characters and a trailing zero.
void render(double width, char * dst, const char * dst_end);
std::string render(double width);
}
<|fim_prefix|>#pragma once
#inc<|fim_middle|>lud... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>licit LockAndOverCommitTrackerBlocker(Mutex & mutex_) TSA_ACQUIRE(mutex_) : lock(TUniqueLock(mutex_)) {}
~LockAndOverCommitTrackerBlocker() TSA_RELEASE() = default;
TUniqueLock<Mutex> & getUnderlyingLock() { return lock; }
private:
TUniqueLock<Mutex> lock;
OvercommitTrackerBlockerInThrea... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ion succeeds (potentially, OS overcommits memory)
/// 4. We go over the limit
/// 5. OOM killer rightfully kills the server process
/// To prevent this, we provide these `-WithMemoryTracking` aliases to standard containers that use the
/// `AllocatorWithMemoryTracking`, which tracks memory using t... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ryTracker`.
template <typename K, typename Hash = std::hash<K>, typename KeyEqual = std::equal_to<K>>
using UnorderedSetWithMemoryTracking = std::unordered_set<K, Hash, KeyEqual, AllocatorWithMemoryTracking<K>>;
template <typename K, typename Hash = std::hash<K>, typename KeyEqual = std::equal_to<K>>
us... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <cstdint>
/// Used in ProfileEvents and Mem<|fim_suffix|>
User, /// Group of processes
Process, /// For example, a query or a merge
Thread, /// A thread of a process
Max, /// size of the enum, not a real level
};
<|fim_middle|>oryTracker to... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Common/Allocator<|fim_suffix|>ult, but we do it through
/// non-throwing methods of the `MemoryTracker` (see `trackMemory` in src/Common/memory.h).
/// The following scenario is possible:
/// 1. Memory consumption is already very close to the limit
/// 2. We're trying to cr... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/VersionNumber.h>
#include <IO/ReadBufferFromString.h>
#include <IO/ReadHelpers.h>
#include <fmt/format.h>
namespace DB
{
VersionNumber::VersionNumber(std::string version_string)
{
if (version_string.empty())
return;
ReadBufferFromString rb(version_string);
Int64 * ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <string>
#include <base/types.h>
namespace DB
{
/// Simple numeric version representation.
struct VersionNumber
{
constexpr VersionNumber() = default;
constexpr VersionNumber(Int64 major_, Int64 minor_ = 0, Int64 patch_ = 0) // NOLINT(google-explicit-constructor)
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <base/demangle.h>
#include <base/TypeList.h>
#include <Common/Exception.h>
#include <typeinfo>
/* Generic utils which are intended for visitor pattern implementation.
* The original purpose is to provide possibility to get concrete template specialisation for type in list.
*
* U... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|> second_u_u32 = Poco::Unicode::toUpper(*second_u32);
}
/// both symbols are case-independent
if (first_l_u32 == first_u_u32 && second_l_u32 == second_u_u32)
{
putNGramBase(n, offset);
}
... | fim | ClickHouse/ClickHouse | c |
#include <bit>
#include <memory>
#include <variant>
#include <Common/Exception.h>
#include <Common/WKB.h>
#include <IO/WriteBuffer.h>
#include <IO/WriteBufferFromString.h>
#include <IO/WriteHelpers.h>
#include <Core/Field.h>
#include <Functions/geometryConverters.h>
#include <base/types.h>
#include <IO/ReadBuffer.h>
#... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <variant>
#include <vector>
#include <IO/ReadBuffer.h>
#include <Functions/geometryConverters.h>
#include <Core/Field.h>
#include <IO/WriteBuffer.h>
namespace DB
{
enum class WKBGeometry : UInt32
{
Point = 1,
LineString = 2,
Polygon = 3,
MultiLineString = 5,
MultiPolygon = ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/WakeupFd.h>
#include <Common/Exception.h>
#include <Common/ErrnoException.h>
#include <unistd.h>
#include <cerrno>
namespace DB
{
namespace ErrorCodes
{
extern const int CANNOT_READ_FROM_FILE_DESCRIPTOR;
extern const int CANNOT_WRITE_TO_FILE_DESCRIPTOR;
}
WakeupFd::WakeupFd(... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/PipeFDs.h>
namespace DB
{
/// Portable async wakeup primitive backed by a non-blocking self-pipe.
/// Works on every Unix. Designed for use with IProcessor::schedule().
class WakeupFd
{
public:
WakeupFd();
WakeupFd(const WakeupFd &) = delete;
WakeupFd & operat... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>
return selected;
}
}
<|fim_prefix|>#pragma once
#include <random>
#include <Common/thread_local_rng.h>
#include <base/defines.h>
#include <base/sort.h>
namespace DB
{
/// Weighted Random Sampling algorithm.
///
/// The implementation uses the A-ES method from the paper https://arxiv.org/pdf/1... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ocal/share";
constexpr const char* ENV_XDG_STATE_HOME = "XDG_STATE_HOME";
constexpr const char* STATE_PATH_PREFIX = ".local/state";
constexpr const char* ENV_XDG_CACHE_HOME = "XDG_STATE_HOME";
constexpr const char* CACHE_PATH_PREFIX = ".cache";
constexpr const char* ENV_HOME = "HOME... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#includ<|fim_suffix|>tDataHome();
static fs::path getStateHome();
static fs::path getCacheHome();
};
}
<|fim_middle|>e <cstdlib>
#include <string>
#include <filesystem>
namespace fs = std::filesystem;
namespace DB
{
/// https://specifications.freedesktop.org/basedir-spec/latest/... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <string>
#include <Common/XMLUtils.h>
#include <Poco/DOM/Document.h>
#include <Poco/Util/AbstractConfiguration.h>
namespace DB::XMLUtils
{
using namespace Poco::XML;
using XMLDocumentPtr = Poco::AutoPtr<Document>;
Node * getRootNode(Document * document)
{
for (Node * child = document->fir... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>n if path is not found.
std::string getString(const Poco::XML::Node * node, const std::string & path);
Int64 getInt64(const Poco::XML::Node * node, const std::string & path);
UInt64 getUInt64(const Poco::XML::Node * node, const std::string & path);
int getInt(const Poco::XML::Node * node, const std::strin... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#inc<|fim_suffix|>tional>
#include <Common/ZooKeeper/ZooKeeper.h>
namespace zkutil
{
using GetZooKeeper = std::function<ZooKeeperPtr()>;
}
<|fim_middle|>lude <func<|endoftext|> | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>id increment(Coordination::Error error)
{
error_counts[errorToIndex(error)].fetch_add(1, std::memory_order_relaxed);
}
void dumpToMapColumn(DB::ColumnMap * column) const
{
auto & offsets = column->getNestedColumn().getOffsets();
auto & tuple_column = column->getNes... | fim | ClickHouse/ClickHouse | c |
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/thread_local_rng.h>
#include <random>
namespace Coordination
{
SimpleFaultInjection::SimpleFaultInjection(Float64 probability_before, Float64 probability_after_, const String & description_)
{
if (likely(probabili... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> result += pathesSize(exist_watches);
result += pathesSize(child_watches);
return result;
}
protected:
static size_t pathesSize(const std::vector<String> & paths)
{
size_t result = sizeof(Int32);
for (const auto & elem : paths)
result += size... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ursive(path, static_cast<UInt32>(remove_nodes_limit)); });
}
bool ReconfigCommand::parse(IParser::Pos & pos, boost::intrusive_ptr<ASTKeeperQuery> & node, DB::Expected & expected) const
{
ParserKeyword s_add(Keyword::ADD);
ParserKeyword s_remove(Keyword::REMOVE);
ParserKeyword s_set(Keyword::S... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ecute(const ASTKeeperQuery * query, KeeperClientBase * client) const override;
String getHelpMessage() const override { return "{} <path> [version] -- Removes the node only if version matches (default: -1)"; }
};
class RMRCommand : public IKeeperClientCommand
{
String getName() const override { ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/StringUtils.h>
#include <Common/filesystemHelpers.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Parsers/parseQuery.h>
#include <Common/ZooKeeper/KeeperClientCLI/KeeperClient.h>
#include <Common/ZooKeeper/KeeperClientCLI/Commands.h>
namespace DB
{
namespace ErrorCodes
{
exter... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>lesystem::path cwd = "/";
std::function<void()> confirmation_callback;
bool ask_confirmation = true;
inline static std::map<String, Command> commands;
std::unordered_map<String, std::future<Coordination::WatchResponse>> watches;
std::ostream & cout;
std::ostream & cerr;
voi... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>e keeper server can potentially have different version we don't want to match this command with embedded list
command = std::make_shared<FourLetterWordCommand>();
command_name = command->getName();
/// We also don't move the position, so the command will be parsed as an... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Core/Field.h>
#include <Parsers/IAST.h>
#include <Parsers/IParserBase.h>
namespace DB
{
bool parseKeeperArg(IParser::Po<|fim_suffix|>d & expected, String & path);
class ASTKeeperQuery : public IAST
{
public:
String getID(char) const override { return "KeeperQuery"; }
A... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ProfileEvents.h>
#include <Common/ZooKeeper/KeeperException.h>
namespace DB::ErrorCodes
{
extern const int KEEPER_EXCEPTION;
}
namespace ProfileEvents
{
extern const Event ZooKeeperUserExceptions;
extern const Event ZooKeeperHardwareExceptions;
extern const Event ZooKeeperOtherException... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <utility>
#include <Common/Exception.h>
#include <Common/ZooKeeper/Types.h>
namespace DB::ErrorCodes
{
extern const int KEEPER_EXCEPTION;
}
namespace Coordination
{
class Exception : public DB::Exception
{
private:
/// Delegate constructor, used to minimize repetition; last p... | fim | ClickHouse/ClickHouse | c |
#include <Common/ZooKeeper/KeeperFeatureFlags.h>
#include <Common/ErrorCodes.h>
#include <Common/Exception.h>
#include <Common/logger_useful.h>
namespace DB
{
namespace
{
std::pair<size_t, size_t> getByteAndBitIndex(size_t num)
{
size_t byte_idx = num / 8;
auto bit_idx = (7 - num % 8);
return {byte_idx, ... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Coordination/KeeperConstants.h>
#include <Core/LogsLevel.h>
#include <memory>
namespace Poco
{
class Logger;
}
using LoggerPtr = std::shared_ptr<Poco::Logger>;
namespace DB
{
/// these values cannot be reordered or removed, only new values can be added
enum class KeeperFeature... | fim | ClickHouse/ClickHouse | c |
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
#include "config.h"
#if USE_NURAFT
#include <Common/Exception.h>
#include <Common/logger_useful.h>
#include <Common/ZooKeeper/KeeperOverDispatcher.h>
#include <Common/ZooKeeper/KeeperSpans.h>
namespace DB::ErrorCodes
{
extern con... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include "config.h"
#if USE_NURAFT
#include <atomic>
#include <mutex>
#include <unordered_map>
#include <Poco/Timespan.h>
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
#include <Coordination/KeeperDispatcher.h>
namespace Coordination
{
class Keeper... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/KeeperSpans.h>
#include <Coordination/KeeperDispatcher.h>
#include <Interpreters/Context.h>
namespace DB
{
namespace
{
std::shared_ptr<OpenTelemetrySpanLog> getSpanLog()
{
static std::shared_ptr<OpenTelemetrySpanLog> span_log;
if (auto maybe_spa<|fim_s... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/HistogramMetrics.h>
#include <Common/OpenTelemetryTraceContext.h>
#include <Common/thread_local_rng.h>
#include <Core/Types.h>
#include <Interpreters/OpenTelemetrySpanLog.h>
#include <array>
#include <chrono>
#include <memory>
namespace HistogramMetrics
{
extern Metric ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <base/types.h>
#include <Common/thread_local_rng.h>
#include <Common/Priority.h>
#include <Poco/Net/SocketAddress.h>
#include <string>
<|fim_suffix|>1,
OTHER = 2,
};
std::string host;
bool secure = false;
UInt8 original_index = 0;
AvailabilityZoneInfo... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/ZooKeeperConstants.h>
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/SystemTablesDataTypes.h>
#include <DataTypes/DataTypeEnum.h>
namespace Coordination
{
DB::DataTypePtr SystemTablesDataTypes::errorCodeEnum()
{
static DB::DataTypePtr result = std::make_s... | fim | ClickHouse/ClickHouse | cpp |
#pragma once
#include <DataTypes/Serializations/ISerialization.h>
namespace Coordination
{
/// Factory of different data types that are needed in ZooKeeper-related system tables
/// (e.g. system.zookeeper_log, system.aggregated_zookeeper_log).
struct SystemTablesDataTypes
{
static DB::DataTypePtr errorCodeEnum()... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/ZooKeeper/KeeperFeatureFlags.h>
#include <Common/ZooKeeper/TestKeeper.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
#include <Common/setThreadName.h>
#include <Common/StringUtils.h>
#include <base/types... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>llback) override;
void finalize(const String & reason) override;
struct Node
{
String data;
ACLs acls;
bool is_ephemeral = false;
bool is_sequental = false;
Stat stat{};
int32_t seq_num = 0;
};
using Container = std::map<std::string, N... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <future>
#include <vector>
#include <base/types.h>
#include <Poco/Event.h>
#include <Common/ZooKeeper/IKeeper.h>
namespace zkutil
{
using Strings = std::vector<std::string>;
namespace CreateMode
{
extern const int Persistent;
extern const int Ephemeral;
extern const ... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/OpenTelemetryTracingContext.h>
#include <Common/OpenTelemetryTraceContext.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeeper/KeeperFeatureFlags.h>
#include <Common/ZooKeeper/ZooKeeperImpl.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/ZooKeeper/TestKe... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Core/Types.h>
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/logger_useful.h>
#include <Common/ProfileEvents.h>
#include <Common/CurrentMetrics.h>
#include <Common/ZooKeeper/ZooKeeperArgs.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Coordination/KeeperConstan... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/ZooKeeperArgs.h>
#include <IO/S3/Credentials.h>
#include <Server/CloudPlacementInfo.h>
#include <base/find_symbols.h>
#include <base/getFQDNOrHostName.h>
#include <Poco/String.h>
#include <Poco/Util/AbstractConfiguration.h>
#include <Common/StringUtils.h>
#include <Common/ZooKe... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>ep_ms = 0;
bool use_compression = false;
bool use_xid_64 = false;
bool pass_opentelemetry_tracing_context = false;
bool prefer_local_availability_zone = false;
bool availability_zone_autodetect = false;
String password;
bool enforce_component_tracking = false;
/// Linux n... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/ZooKeeperCachingGetter.h>
namespace DB
{
namespace ErrorCodes
{
extern const int N<|fim_suffix|>tter::SessionStatus> ZooKeeperCachingGetter::getZooKeeperNoLock()
{
if (!cached_zookeeper_ptr || cached_zookeeper_ptr->expired())
{
auto zookeeper = get_zookeepe... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> ZooKeeperCachingGetter(const ZooKeeperCachingGetter &) = delete;
ZooKeeperCachingGetter & operator=(const ZooKeeperCachingGetter &) = delete;
/// Returns the ZooKeeper session and the status whether it was taken from the cache or opened new,
/// because the session has expired or the cach... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/ZooKeeper/ZooKeeperConstants.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
#include <Common/ZooKeeper/ZooKeeperIO.h>
#include <Common/Stopwatch.h>
#include <IO/WriteHelpers.h>
#include <IO/WriteBufferFr... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/OpenTelemetryTraceContext.h>
#include <Common/OpenTelemetryTracingContext.h>
#include <Common/ZooKeeper/IKeeper.h>
#include <Common/ZooKeeper/ZooKeeperConstants.h>
#include <Common/ZooKeeper/KeeperSpans.h>
#include <Common/StaticString.h>
#include <Interpreters/ZooKeeperLog.... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>se OpNum::List: return "List";
case OpNum::Check: return "Check";
case OpNum::Multi: return "Multi";
case OpNum::Reconfig: return "Reconfig";
case OpNum::MultiRead: return "MultiRead";
case OpNum::Auth: return "Auth";
case OpNum::FilteredList: return "Filter... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>c constexpr int32_t PASSWORD_LENGTH = 16;
/// ZooKeeper has 1 MB node size and serialization limit by default,
/// but it can be raised up, so we have a slightly larger limit on our side.
static constexpr int32_t MAX_STRING_OR_ARRAY_SIZE = 1 << 28; /// 256 MiB
static constexpr int32_t DEFAULT_SESSION_TI... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/ZooKeeperIO.h>
namespace Coordination
{
void write(OpNum x, WriteBuffer & out)
{
write(static_cast<int32_t>(x), out);
}
void write(const std::string & s, WriteBuffer & out)
{
write(static_cast<int32_t>(s.size()), out);
out.write(s.data(), s.size());
}
void write... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>w Exception::fromMessage(Error::ZMARSHALLINGERROR, "Unexpected array size while reading from ZooKeeper");
in.readStrict(s.data(), N);
}
template <typename T>
void read(std::vector<T> & arr, ReadBuffer & in)
{
int32_t size = 0;
read(size, in);
if (size < 0)
throw Exception::fromMes... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <atomic>
#include <chrono>
#include <ranges>
#include <Common/OpenTelemetryTracingContext.h>
#include <Common/OpenTelemetryTraceContext.h>
#include <Common/ZooKeeper/KeeperFeatureFlags.h>
#include <Common/Stopwatch.h>
#include <Common/StackTrace.h>
#include <Common/ZooKeeper/ZooKeeperConstants.h... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>dZooKeeperLog> getAggregatedZooKeeperLog();
void setServerCompletelyStarted();
const KeeperFeatureFlags * getKeeperFeatureFlags() const override { return &keeper_feature_flags; }
int64_t getLastZXIDSeen() const override { return last_zxid_seen.load(std::memory_order_relaxed); }
Int64 g... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>);
else if (throw_if_lost)
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Lock is lost, node does not exist. Path: {}, message: {}, our id: {}",
lock_path, lock_message, zookeeper->getClientID());
else
LOG_INFO(log, "Lock is lost, node does not exis... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <memory>
#include <string>
namespace Poco { class Logger; }
namespace zkutil
{
/** Caveats: usage of locks in ZooKeeper is incorrect in 99% of cases,
* and highlights your poor understanding o... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>lt;
}
/// Node doesn't exist. We must set a watch on node creation (because it wasn't set by tryGetWatch).
result.exists = zookeeper->existsWatch(path, &result.stat, wrapped_watch_callback);
if (!result.exists)
{
path_to_cached_znode.emplace(path, result);
return resu... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <unordered_map>
#include <unordered_set>
#include <mutex>
#include <memory>
#include <base/defines.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeep<|fim_suffix|>de
{
bool exists = false;
std::string contents;
Coordination::Stat stat{};
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#pragma once
#include <Interpreters/ProcessList.h>
#include <base/sleep.h>
#include <Common/Exception.h>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/logger_useful.h>
namespace DB
{
namespace ErrorCodes
{
extern const int OK;
}
struct ZooKeeperRetriesInfo
{
ZooKeeperRetriesInf... | fim | ClickHouse/ClickHouse | c |
<|fim_suffix|>ultSync(__func__, !paths.empty() ? paths.front() : "", [&]() { return keeper->tryGet(paths); });
}
void ZooKeeperWithFaultInjection::set(const String & path, const String & data, int32_t version, Coordination::Stat * stat)
{
executeWithFaultSync(__func__, path, [&]() { keeper->set(path, data, version... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#pragma once
#include <random>
#include <Common/ZooKeeper/KeeperException.h>
#include <Common/ZooKeeper/Types.h>
#include <Common/ZooKeeper/ZooKeeper.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
#include <Common/logger_useful.h>
#include <Common/randomSeed.h>
#include <pcg_random.hpp>
namespace DB
{
... | fim | ClickHouse/ClickHouse | c |
<|fim_prefix|>#include <Common/ZooKeeper/ZooKeeper.h>
#include <IO/ReadHelpers.h>
#include <iostream>
#include <Examples/clickhouse_examples.h>
int mainEntryExampleZkutilTestAsync(int argc, char ** argv)
try
{
auto zookeeper = zkutil::ZooKeeper::createWithoutKil<|fim_suffix|> futures.reserve(nodes.size());
... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|> Coordination::Stat stat;
Coordination::EventPtr watch = std::make_shared<Poco::Event>();
std::cout << "get path" << std::endl;
zk->get("/test", &stat, watch);
std::cout << "set path" << std::endl;
zk->set("/test", "new");
watch->wait();
std::cout << "watch happened" << std::e... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>;
else
std::cerr << "Exists\n";
//event.set();
},
std::make_shared<Coordination::WatchCallback>(
[](const WatchResponse & response)
{
if (response.error != Coordination::Error::ZOK)
std::ce... | fim | ClickHouse/ClickHouse | cpp |
<|fim_prefix|>#include <gtest/gtest.h>
#include <Common/ZooKeeper/ZooKeeperCommon.h>
TEST(ZooKeeperTest, TestMatchPath)
{
using namespace Coordination;
<|fim_suffix|>th("/path/", "/path"), PathMatchResult::EXACT);
}
<|fim_middle|> ASSERT_EQ(matchPath("/path/file", "/path"), PathMatchResult::IS_CHILD);
ASS... | fim | ClickHouse/ClickHouse | cpp |
#include <Common/assertProcessUserMatchesDataOwner.h>
#include <Common/Exception.h>
#include <Common/ErrnoException.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
namespace DB
{
namespace ErrorCodes
{
extern const int FAILED_TO_GETPWUID;
extern const int MISMATCHING_USERS_FOR_PROCESS_AND_DATA;... | fim | ClickHouse/ClickHouse | cpp |
<|fim_suffix|>Message &)> on_warning);
}
<|fim_prefix|>#pragma once
#include <functional>
#include <Common/LoggingFormatStringHelpers.h>
namespace DB
{
<|fim_middle|>void assertProcessUserMatchesDataOwner(
const std::string & path, std::function<void(const Preformatted<|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.