summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-10-06 11:26:09 +0300
committervvvv <[email protected]>2025-10-06 11:53:26 +0300
commit60f45e69a4d7dbc6131208e16c45faf35aa5a985 (patch)
tree4daa45b52c295a178c7620e4c93921465fcf7950
parent1bded1a65a7e6e9171418f3e1c691d390125b64e (diff)
YQL-20086 utils
init commit_hash:54feccd520ebd0ab23612bc0cb830914dff9d0e8
-rw-r--r--yql/essentials/utils/backtrace/backtrace.cpp223
-rw-r--r--yql/essentials/utils/backtrace/backtrace.h2
-rw-r--r--yql/essentials/utils/backtrace/backtrace_dummy.cpp12
-rw-r--r--yql/essentials/utils/backtrace/backtrace_lib.cpp99
-rw-r--r--yql/essentials/utils/backtrace/backtrace_lib.h24
-rw-r--r--yql/essentials/utils/backtrace/backtrace_linux.cpp90
-rw-r--r--yql/essentials/utils/backtrace/backtrace_ut.cpp30
-rw-r--r--yql/essentials/utils/backtrace/symbolize.cpp88
-rw-r--r--yql/essentials/utils/backtrace/symbolizer.h16
-rw-r--r--yql/essentials/utils/backtrace/symbolizer_linux.cpp122
-rw-r--r--yql/essentials/utils/backtrace/ut/ya.make1
-rw-r--r--yql/essentials/utils/backtrace/ya.make5
-rw-r--r--yql/essentials/utils/cast.h2
-rw-r--r--yql/essentials/utils/chunked_buffer.cpp2
-rw-r--r--yql/essentials/utils/chunked_buffer.h7
-rw-r--r--yql/essentials/utils/debug_info.cpp15
-rw-r--r--yql/essentials/utils/debug_info.h1
-rw-r--r--yql/essentials/utils/docs/link.cpp142
-rw-r--r--yql/essentials/utils/docs/link.h22
-rw-r--r--yql/essentials/utils/docs/link_page.cpp168
-rw-r--r--yql/essentials/utils/docs/link_page.h4
-rw-r--r--yql/essentials/utils/docs/markdown.cpp190
-rw-r--r--yql/essentials/utils/docs/markdown.h28
-rw-r--r--yql/essentials/utils/docs/markdown_ut.cpp72
-rw-r--r--yql/essentials/utils/docs/name.cpp56
-rw-r--r--yql/essentials/utils/docs/name.h10
-rw-r--r--yql/essentials/utils/docs/page.cpp102
-rw-r--r--yql/essentials/utils/docs/page.h8
-rw-r--r--yql/essentials/utils/docs/page_ut.cpp46
-rw-r--r--yql/essentials/utils/docs/resource.cpp60
-rw-r--r--yql/essentials/utils/docs/resource.h14
-rw-r--r--yql/essentials/utils/docs/ut/ya.make2
-rw-r--r--yql/essentials/utils/docs/verification.cpp178
-rw-r--r--yql/essentials/utils/docs/verification.h32
-rw-r--r--yql/essentials/utils/docs/ya.make2
-rw-r--r--yql/essentials/utils/exceptions.cpp10
-rw-r--r--yql/essentials/utils/exceptions.h14
-rw-r--r--yql/essentials/utils/failure_injector/failure_injector.cpp8
-rw-r--r--yql/essentials/utils/failure_injector/failure_injector.h2
-rw-r--r--yql/essentials/utils/failure_injector/failure_injector_ut.cpp104
-rw-r--r--yql/essentials/utils/failure_injector/ut/ya.make2
-rw-r--r--yql/essentials/utils/failure_injector/ya.make2
-rw-r--r--yql/essentials/utils/fetch/fetch.cpp31
-rw-r--r--yql/essentials/utils/fetch/fetch.h2
-rw-r--r--yql/essentials/utils/fetch/ya.make2
-rw-r--r--yql/essentials/utils/fp_bits.h16
-rw-r--r--yql/essentials/utils/fp_bits_ut.cpp26
-rw-r--r--yql/essentials/utils/future_action.h6
-rw-r--r--yql/essentials/utils/hash.cpp5
-rw-r--r--yql/essentials/utils/hash.h59
-rw-r--r--yql/essentials/utils/limiting_allocator.cpp11
-rw-r--r--yql/essentials/utils/limiting_allocator.h2
-rw-r--r--yql/essentials/utils/log/context.cpp42
-rw-r--r--yql/essentials/utils/log/context.h41
-rw-r--r--yql/essentials/utils/log/format.cpp258
-rw-r--r--yql/essentials/utils/log/format.h8
-rw-r--r--yql/essentials/utils/log/fwd_backend.cpp64
-rw-r--r--yql/essentials/utils/log/fwd_backend.h32
-rw-r--r--yql/essentials/utils/log/log.cpp174
-rw-r--r--yql/essentials/utils/log/log.h63
-rw-r--r--yql/essentials/utils/log/log_component.h217
-rw-r--r--yql/essentials/utils/log/log_level.h91
-rw-r--r--yql/essentials/utils/log/log_ut.cpp1184
-rw-r--r--yql/essentials/utils/log/profile.cpp12
-rw-r--r--yql/essentials/utils/log/profile.h34
-rw-r--r--yql/essentials/utils/log/tls_backend.cpp13
-rw-r--r--yql/essentials/utils/log/tls_backend.h5
-rw-r--r--yql/essentials/utils/log/tls_backend_ut.cpp115
-rw-r--r--yql/essentials/utils/log/ut/log_parser.cpp114
-rw-r--r--yql/essentials/utils/log/ut/log_parser.h4
-rw-r--r--yql/essentials/utils/log/ut/ya.make2
-rw-r--r--yql/essentials/utils/log/ya.make2
-rw-r--r--yql/essentials/utils/md5_stream.cpp4
-rw-r--r--yql/essentials/utils/md5_stream.h4
-rw-r--r--yql/essentials/utils/md5_stream_ut.cpp46
-rw-r--r--yql/essentials/utils/mem_limit.cpp28
-rw-r--r--yql/essentials/utils/memory_profiling/ya.make2
-rw-r--r--yql/essentials/utils/method_index.cpp2
-rw-r--r--yql/essentials/utils/method_index.h4
-rw-r--r--yql/essentials/utils/network/bind_in_range.cpp2
-rw-r--r--yql/essentials/utils/network/bind_in_range.h2
-rw-r--r--yql/essentials/utils/network/ya.make2
-rw-r--r--yql/essentials/utils/oom_helper/inject.cpp12
-rw-r--r--yql/essentials/utils/oom_helper/ya.make1
-rw-r--r--yql/essentials/utils/parse_double.cpp6
-rw-r--r--yql/essentials/utils/parse_double.h2
-rw-r--r--yql/essentials/utils/parse_double_ut.cpp70
-rw-r--r--yql/essentials/utils/proc_alive.cpp4
-rw-r--r--yql/essentials/utils/proc_alive.h2
-rw-r--r--yql/essentials/utils/rand_guid.cpp2
-rw-r--r--yql/essentials/utils/rand_guid.h4
-rw-r--r--yql/essentials/utils/range_walker.h2
-rw-r--r--yql/essentials/utils/range_walker_ut.cpp42
-rw-r--r--yql/essentials/utils/resetable_setting.h2
-rw-r--r--yql/essentials/utils/retry.h2
-rw-r--r--yql/essentials/utils/retry_ut.cpp79
-rw-r--r--yql/essentials/utils/signals/signals.cpp114
-rw-r--r--yql/essentials/utils/signals/signals.h1
-rw-r--r--yql/essentials/utils/signals/utils.cpp8
-rw-r--r--yql/essentials/utils/signals/utils.h2
-rw-r--r--yql/essentials/utils/signals/ya.make2
-rw-r--r--yql/essentials/utils/sort.cpp2
-rw-r--r--yql/essentials/utils/sort.h2
-rw-r--r--yql/essentials/utils/swap_bytes.h5
-rw-r--r--yql/essentials/utils/sys/become_user.cpp46
-rw-r--r--yql/essentials/utils/sys/become_user.h2
-rw-r--r--yql/essentials/utils/sys/become_user_dummy.cpp2
-rw-r--r--yql/essentials/utils/sys/linux_version.cpp58
-rw-r--r--yql/essentials/utils/sys/linux_version.h12
-rw-r--r--yql/essentials/utils/sys/ya.make2
-rw-r--r--yql/essentials/utils/test_http_server/test_http_server.cpp32
-rw-r--r--yql/essentials/utils/test_http_server/test_http_server.h2
-rw-r--r--yql/essentials/utils/test_http_server/ya.make2
-rw-r--r--yql/essentials/utils/threading/async_queue.cpp2
-rw-r--r--yql/essentials/utils/threading/async_queue.h2
-rw-r--r--yql/essentials/utils/threading/ya.make2
-rw-r--r--yql/essentials/utils/tty.cpp30
-rw-r--r--yql/essentials/utils/url_builder.cpp4
-rw-r--r--yql/essentials/utils/url_builder.h4
-rw-r--r--yql/essentials/utils/url_builder_ut.cpp98
-rw-r--r--yql/essentials/utils/ut/ya.make2
-rw-r--r--yql/essentials/utils/utf8.cpp104
-rw-r--r--yql/essentials/utils/utf8.h2
-rw-r--r--yql/essentials/utils/utf8_ut.cpp168
-rw-r--r--yql/essentials/utils/ya.make2
-rw-r--r--yql/essentials/utils/yql_panic.cpp4
-rw-r--r--yql/essentials/utils/yql_panic.h15
-rw-r--r--yql/essentials/utils/yql_paths.cpp2
-rw-r--r--yql/essentials/utils/yql_paths.h2
129 files changed, 2968 insertions, 2747 deletions
diff --git a/yql/essentials/utils/backtrace/backtrace.cpp b/yql/essentials/utils/backtrace/backtrace.cpp
index 938ac90501a..5d289454210 100644
--- a/yql/essentials/utils/backtrace/backtrace.cpp
+++ b/yql/essentials/utils/backtrace/backtrace.cpp
@@ -18,7 +18,7 @@
#include <util/system/mlock.h>
#ifdef _linux_
-#include <signal.h>
+ #include <signal.h>
#endif
#include <functional>
@@ -38,16 +38,16 @@ bool SetSignalHandler(int signo, void (*handler)(int)) {
}
namespace {
-#if defined(_linux_) && defined(_x86_64_)
- bool SetSignalAction(int signo, void (*handler)(int, siginfo_t*, void*)) {
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
- sa.sa_flags = SA_RESETHAND | SA_SIGINFO;
- sa.sa_sigaction = (decltype(sa.sa_sigaction))handler;
- sigfillset(&sa.sa_mask);
- return sigaction(signo, &sa, nullptr) != -1;
- }
-#endif
+ #if defined(_linux_) && defined(_x86_64_)
+bool SetSignalAction(int signo, void (*handler)(int, siginfo_t*, void*)) {
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_flags = SA_RESETHAND | SA_SIGINFO;
+ sa.sa_sigaction = (decltype(sa.sa_sigaction))handler;
+ sigfillset(&sa.sa_mask);
+ return sigaction(signo, &sa, nullptr) != -1;
+}
+ #endif
} // namespace
#endif // _win_
@@ -56,7 +56,7 @@ TAtomic BacktraceStarted = 0;
void SetFatalSignalHandler(void (*handler)(int)) {
Y_UNUSED(handler);
#ifndef _win_
- for (int signo: {SIGSEGV, SIGILL, SIGABRT, SIGFPE}) {
+ for (int signo : {SIGSEGV, SIGILL, SIGABRT, SIGFPE}) {
if (!SetSignalHandler(signo, handler)) {
ythrow TSystemError() << "Cannot set handler for signal " << strsignal(signo);
}
@@ -67,7 +67,7 @@ void SetFatalSignalHandler(void (*handler)(int)) {
#if defined(_linux_) && defined(_x86_64_)
void SetFatalSignalAction(void (*sigaction)(int, siginfo_t*, void*))
{
- for (int signo: {SIGSEGV, SIGILL, SIGABRT, SIGFPE}) {
+ for (int signo : {SIGSEGV, SIGILL, SIGABRT, SIGFPE}) {
if (!SetSignalAction(signo, sigaction)) {
ythrow TSystemError() << "Cannot set sigaction for signal " << strsignal(signo);
}
@@ -76,140 +76,139 @@ void SetFatalSignalAction(void (*sigaction)(int, siginfo_t*, void*))
#endif
namespace {
- std::vector<std::function<void(int)>> Before, After;
- bool KikimrSymbolize = false;
- NYql::NBacktrace::TCollectedFrame Frames[NYql::NBacktrace::Limit];
-
- void CallCallbacks(decltype(Before)& where, int signum) {
- for (const auto &fn: where) {
- if (fn) {
- fn(signum);
- }
+std::vector<std::function<void(int)>> Before, After;
+bool KikimrSymbolize = false;
+NYql::NBacktrace::TCollectedFrame Frames[NYql::NBacktrace::Limit];
+
+void CallCallbacks(decltype(Before)& where, int signum) {
+ for (const auto& fn : where) {
+ if (fn) {
+ fn(signum);
}
}
+}
- void PrintFrames(IOutputStream* out, const NYql::NBacktrace::TCollectedFrame* frames, size_t cnt);
+void PrintFrames(IOutputStream* out, const NYql::NBacktrace::TCollectedFrame* frames, size_t cnt);
- void DoBacktrace(IOutputStream* out, void* data) {
- auto cnt = NYql::NBacktrace::CollectFrames(Frames, data);
- PrintFrames(out, Frames, cnt);
- }
+void DoBacktrace(IOutputStream* out, void* data) {
+ auto cnt = NYql::NBacktrace::CollectFrames(Frames, data);
+ PrintFrames(out, Frames, cnt);
+}
- void DoBacktrace(IOutputStream* out, void** stack, size_t cnt) {
- Y_UNUSED(NYql::NBacktrace::CollectFrames(Frames, stack, cnt));
- PrintFrames(out, Frames, cnt);
- }
-
-
- void SignalHandler(int signum) {
- CallCallbacks(Before, signum);
-
- if (!NMalloc::IsAllocatorCorrupted) {
- if (!AtomicTryLock(&BacktraceStarted)) {
- return;
- }
-
- UnlockAllMemory();
- DoBacktrace(&Cerr, nullptr);
+void DoBacktrace(IOutputStream* out, void** stack, size_t cnt) {
+ Y_UNUSED(NYql::NBacktrace::CollectFrames(Frames, stack, cnt));
+ PrintFrames(out, Frames, cnt);
+}
+
+void SignalHandler(int signum) {
+ CallCallbacks(Before, signum);
+
+ if (!NMalloc::IsAllocatorCorrupted) {
+ if (!AtomicTryLock(&BacktraceStarted)) {
+ return;
}
-
- CallCallbacks(After, signum);
- raise(signum);
+
+ UnlockAllMemory();
+ DoBacktrace(&Cerr, nullptr);
}
-#if defined(_linux_) && defined(_x86_64_)
- void SignalAction(int signum, siginfo_t*, void* context) {
- Y_UNUSED(SignalHandler);
- CallCallbacks(Before, signum);
+ CallCallbacks(After, signum);
+ raise(signum);
+}
- if (!NMalloc::IsAllocatorCorrupted) {
- if (!AtomicTryLock(&BacktraceStarted)) {
- return;
- }
+#if defined(_linux_) && defined(_x86_64_)
+void SignalAction(int signum, siginfo_t*, void* context) {
+ Y_UNUSED(SignalHandler);
+ CallCallbacks(Before, signum);
- UnlockAllMemory();
- DoBacktrace(&Cerr, context);
+ if (!NMalloc::IsAllocatorCorrupted) {
+ if (!AtomicTryLock(&BacktraceStarted)) {
+ return;
}
-
- CallCallbacks(After, signum);
- raise(signum);
+
+ UnlockAllMemory();
+ DoBacktrace(&Cerr, context);
}
-#endif
+
+ CallCallbacks(After, signum);
+ raise(signum);
}
+#endif
+} // namespace
namespace NYql {
- namespace NBacktrace {
- THashMap<TString, TString> Mapping;
+namespace NBacktrace {
+THashMap<TString, TString> Mapping;
- void SetModulesMapping(const THashMap<TString, TString>& mapping) {
- Mapping = mapping;
- }
+void SetModulesMapping(const THashMap<TString, TString>& mapping) {
+ Mapping = mapping;
+}
- void AddBeforeFatalCallback(const std::function<void(int)>& before) {
- Before.push_back(before);
- }
+void AddBeforeFatalCallback(const std::function<void(int)>& before) {
+ Before.push_back(before);
+}
- void AddAfterFatalCallback(const std::function<void(int)>& after) {
- After.push_back(after);
- }
+void AddAfterFatalCallback(const std::function<void(int)>& after) {
+ After.push_back(after);
+}
- void RegisterKikimrFatalActions() {
+void RegisterKikimrFatalActions() {
#if defined(_linux_) && defined(_x86_64_)
- SetFatalSignalAction(SignalAction);
+ SetFatalSignalAction(SignalAction);
#else
- SetFatalSignalHandler(SignalHandler);
+ SetFatalSignalHandler(SignalHandler);
#endif
- }
-
- void EnableKikimrSymbolize() {
- KikimrSymbolize = true;
- }
+}
- void KikimrBackTrace() {
- FormatBackTrace(&Cerr);
- }
+void EnableKikimrSymbolize() {
+ KikimrSymbolize = true;
+}
- void KikimrBackTraceFormatImpl(IOutputStream* out) {
- KikimrSymbolize = true;
- UnlockAllMemory();
- DoBacktrace(out, nullptr);
- }
+void KikimrBackTrace() {
+ FormatBackTrace(&Cerr);
+}
- void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize) {
- KikimrSymbolize = true;
- DoBacktrace(out, (void**)stack, stackSize);
- }
+void KikimrBackTraceFormatImpl(IOutputStream* out) {
+ KikimrSymbolize = true;
+ UnlockAllMemory();
+ DoBacktrace(out, nullptr);
+}
- }
+void KikimrBacktraceFormatImpl(IOutputStream* out, void* const* stack, size_t stackSize) {
+ KikimrSymbolize = true;
+ DoBacktrace(out, (void**)stack, stackSize);
}
+} // namespace NBacktrace
+} // namespace NYql
+
void EnableKikimrBacktraceFormat() {
SetFormatBackTraceFn(NYql::NBacktrace::KikimrBacktraceFormatImpl);
}
namespace {
- NYql::NBacktrace::TStackFrame SFrames[NYql::NBacktrace::Limit];
- void PrintFrames(IOutputStream* out, const NYql::NBacktrace::TCollectedFrame* frames, size_t count) {
- auto& outp = *out;
- Y_UNUSED(SFrames);
+NYql::NBacktrace::TStackFrame SFrames[NYql::NBacktrace::Limit];
+void PrintFrames(IOutputStream* out, const NYql::NBacktrace::TCollectedFrame* frames, size_t count) {
+ auto& outp = *out;
+ Y_UNUSED(SFrames);
#if defined(_linux_) && defined(_x86_64_)
- if (KikimrSymbolize) {
- for (size_t i = 0; i < count; ++i) {
- SFrames[i] = NYql::NBacktrace::TStackFrame{frames[i].File, frames[i].Address};
- }
- NYql::NBacktrace::Symbolize(SFrames, count, out);
- return;
+ if (KikimrSymbolize) {
+ for (size_t i = 0; i < count; ++i) {
+ SFrames[i] = NYql::NBacktrace::TStackFrame{frames[i].File, frames[i].Address};
}
+ NYql::NBacktrace::Symbolize(SFrames, count, out);
+ return;
+ }
#endif
- outp << "StackFrames: " << count << "\n";
- for (size_t i = 0; i < count; ++i) {
- auto& frame = frames[i];
- auto fileName = frame.File;
- if (!strcmp(fileName, "/proc/self/exe")) {
- fileName = "EXE";
- }
- auto it = NYql::NBacktrace::Mapping.find(fileName);
- outp << "StackFrame: " << (it == NYql::NBacktrace::Mapping.end() ? fileName : it->second) << " " << frame.Address << " 0\n";
+ outp << "StackFrames: " << count << "\n";
+ for (size_t i = 0; i < count; ++i) {
+ auto& frame = frames[i];
+ auto fileName = frame.File;
+ if (!strcmp(fileName, "/proc/self/exe")) {
+ fileName = "EXE";
}
+ auto it = NYql::NBacktrace::Mapping.find(fileName);
+ outp << "StackFrame: " << (it == NYql::NBacktrace::Mapping.end() ? fileName : it->second) << " " << frame.Address << " 0\n";
}
-} \ No newline at end of file
+}
+} // namespace
diff --git a/yql/essentials/utils/backtrace/backtrace.h b/yql/essentials/utils/backtrace/backtrace.h
index cd843d8cb41..c401392cfed 100644
--- a/yql/essentials/utils/backtrace/backtrace.h
+++ b/yql/essentials/utils/backtrace/backtrace.h
@@ -29,6 +29,6 @@ void SetModulesMapping(const THashMap<TString, TString>& mapping);
TString Symbolize(const TString& input, const THashMap<TString, TString>& mapping);
-} /* namespace Backtrace */
+} // namespace NBacktrace
} /* namespace NYql */
diff --git a/yql/essentials/utils/backtrace/backtrace_dummy.cpp b/yql/essentials/utils/backtrace/backtrace_dummy.cpp
index ec54e55dcab..5035aa918e7 100644
--- a/yql/essentials/utils/backtrace/backtrace_dummy.cpp
+++ b/yql/essentials/utils/backtrace/backtrace_dummy.cpp
@@ -3,9 +3,9 @@
#include <util/system/backtrace.h>
namespace NYql {
- namespace NBacktrace {
- size_t CollectBacktrace(void** addresses, size_t limit, void*) {
- return BackTrace(addresses, limit);
- }
- }
-} \ No newline at end of file
+namespace NBacktrace {
+size_t CollectBacktrace(void** addresses, size_t limit, void*) {
+ return BackTrace(addresses, limit);
+}
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/backtrace_lib.cpp b/yql/essentials/utils/backtrace/backtrace_lib.cpp
index dd2d295dc30..473b227cc4a 100644
--- a/yql/essentials/utils/backtrace/backtrace_lib.cpp
+++ b/yql/essentials/utils/backtrace/backtrace_lib.cpp
@@ -6,74 +6,73 @@
#include <algorithm>
#if defined(_linux_) && defined(_x86_64_)
-#include <dlfcn.h>
-#include <link.h>
+ #include <dlfcn.h>
+ #include <link.h>
#endif
namespace {
- const size_t Limit = 400;
- void* Stack[Limit];
+const size_t Limit = 400;
+void* Stack[Limit];
- struct TDllInfo {
- const char* Path;
- ui64 BaseAddress;
- };
+struct TDllInfo {
+ const char* Path;
+ ui64 BaseAddress;
+};
- const size_t MaxDLLCnt = 100;
- TDllInfo DLLs[MaxDLLCnt];
- size_t DLLCount = 0;
+const size_t MaxDLLCnt = 100;
+TDllInfo DLLs[MaxDLLCnt];
+size_t DLLCount = 0;
#if defined(_linux_) && defined(_x86_64_)
- int DlIterCallback(struct dl_phdr_info *info, size_t, void *data) {
- if (*info->dlpi_name) {
- if (DLLCount + 1 < MaxDLLCnt) {
- reinterpret_cast<std::remove_reference_t<decltype(DLLs[0])>*>(data)[DLLCount++] = { info->dlpi_name, (ui64)info->dlpi_addr };
- }
+int DlIterCallback(struct dl_phdr_info* info, size_t, void* data) {
+ if (*info->dlpi_name) {
+ if (DLLCount + 1 < MaxDLLCnt) {
+ reinterpret_cast<std::remove_reference_t<decltype(DLLs[0])>*>(data)[DLLCount++] = {info->dlpi_name, (ui64)info->dlpi_addr};
}
- return 0;
}
+ return 0;
+}
#endif
- bool Comp(const TDllInfo& a, const TDllInfo& b) {
- return strcmp(a.Path, b.Path) < 0;
- }
-
+bool Comp(const TDllInfo& a, const TDllInfo& b) {
+ return strcmp(a.Path, b.Path) < 0;
}
+} // namespace
+
namespace NYql {
- namespace NBacktrace {
- TCollectedFrame::TCollectedFrame(uintptr_t addr) {
- File = GetPersistentExecPath().c_str();
- Address = addr;
+namespace NBacktrace {
+TCollectedFrame::TCollectedFrame(uintptr_t addr) {
+ File = GetPersistentExecPath().c_str();
+ Address = addr;
#if defined(_linux_) && defined(_x86_64_)
- Dl_info dlInfo;
- memset(&dlInfo, 0, sizeof(dlInfo));
- auto ret = dladdr(reinterpret_cast<void*>(addr), &dlInfo);
- if (ret) {
- auto it = std::lower_bound(DLLs, DLLs + DLLCount, std::remove_reference_t<decltype(DLLs[0])> {dlInfo.dli_fname, {}}, Comp);
- if (it != DLLs + DLLCount && !strcmp(it->Path, dlInfo.dli_fname)) {
- File = it->Path;
- Address -= it->BaseAddress;
- }
- }
-#endif
+ Dl_info dlInfo;
+ memset(&dlInfo, 0, sizeof(dlInfo));
+ auto ret = dladdr(reinterpret_cast<void*>(addr), &dlInfo);
+ if (ret) {
+ auto it = std::lower_bound(DLLs, DLLs + DLLCount, std::remove_reference_t<decltype(DLLs[0])>{dlInfo.dli_fname, {}}, Comp);
+ if (it != DLLs + DLLCount && !strcmp(it->Path, dlInfo.dli_fname)) {
+ File = it->Path;
+ Address -= it->BaseAddress;
}
+ }
+#endif
+}
- size_t CollectFrames(TCollectedFrame* frames, void* data) {
+size_t CollectFrames(TCollectedFrame* frames, void* data) {
#if defined(_linux_) && defined(_x86_64_)
- DLLCount = 0;
- dl_iterate_phdr(DlIterCallback, &DLLs);
+ DLLCount = 0;
+ dl_iterate_phdr(DlIterCallback, &DLLs);
#endif
- std::stable_sort(DLLs, DLLs + DLLCount, Comp);
- size_t cnt = CollectBacktrace(Stack, Limit, data);
- return CollectFrames(frames, Stack, cnt);
- }
+ std::stable_sort(DLLs, DLLs + DLLCount, Comp);
+ size_t cnt = CollectBacktrace(Stack, Limit, data);
+ return CollectFrames(frames, Stack, cnt);
+}
- size_t CollectFrames(TCollectedFrame* frames, void** stack, size_t cnt) {
- for (size_t i = 0; i < cnt; ++i) {
- new (frames + i)TCollectedFrame(reinterpret_cast<uintptr_t>(stack[i]));
- }
- return cnt;
- }
+size_t CollectFrames(TCollectedFrame* frames, void** stack, size_t cnt) {
+ for (size_t i = 0; i < cnt; ++i) {
+ new (frames + i) TCollectedFrame(reinterpret_cast<uintptr_t>(stack[i]));
}
+ return cnt;
}
-
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/backtrace_lib.h b/yql/essentials/utils/backtrace/backtrace_lib.h
index 3404716da68..d0a390bf9ea 100644
--- a/yql/essentials/utils/backtrace/backtrace_lib.h
+++ b/yql/essentials/utils/backtrace/backtrace_lib.h
@@ -4,15 +4,15 @@
#include <util/generic/vector.h>
namespace NYql {
- namespace NBacktrace {
- size_t CollectBacktrace(void** addresses, size_t limit, void* data);
- struct TCollectedFrame {
- TCollectedFrame(uintptr_t addr);
- TCollectedFrame() = default;
- const char* File;
- size_t Address;
- };
- size_t CollectFrames(TCollectedFrame* frames, void* data);
- size_t CollectFrames(TCollectedFrame* frames, void** stack, size_t cnt);
- }
-} \ No newline at end of file
+namespace NBacktrace {
+size_t CollectBacktrace(void** addresses, size_t limit, void* data);
+struct TCollectedFrame {
+ TCollectedFrame(uintptr_t addr);
+ TCollectedFrame() = default;
+ const char* File;
+ size_t Address;
+};
+size_t CollectFrames(TCollectedFrame* frames, void* data);
+size_t CollectFrames(TCollectedFrame* frames, void** stack, size_t cnt);
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/backtrace_linux.cpp b/yql/essentials/utils/backtrace/backtrace_linux.cpp
index c9a1bd5a225..f819a04ae90 100644
--- a/yql/essentials/utils/backtrace/backtrace_linux.cpp
+++ b/yql/essentials/utils/backtrace/backtrace_linux.cpp
@@ -6,57 +6,57 @@
#include <util/system/backtrace.h>
namespace {
- size_t BackTrace(void** p, size_t len, ucontext_t* con) {
- unw_context_t context;
- unw_cursor_t cursor;
- if (unw_getcontext(&context)) {
- return 0;
- }
+size_t BackTrace(void** p, size_t len, ucontext_t* con) {
+ unw_context_t context;
+ unw_cursor_t cursor;
+ if (unw_getcontext(&context)) {
+ return 0;
+ }
- if (unw_init_local(&cursor, &context)) {
- return 0;
- }
- const sigcontext* signal_mcontext = (const sigcontext*)&(con->uc_mcontext);
- unw_set_reg(&cursor, UNW_X86_64_RSI, signal_mcontext->rsi);
- unw_set_reg(&cursor, UNW_X86_64_RDI, signal_mcontext->rdi);
- unw_set_reg(&cursor, UNW_X86_64_RBP, signal_mcontext->rbp);
- unw_set_reg(&cursor, UNW_X86_64_RAX, signal_mcontext->rax);
- unw_set_reg(&cursor, UNW_X86_64_RBX, signal_mcontext->rbx);
- unw_set_reg(&cursor, UNW_X86_64_RCX, signal_mcontext->rcx);
- unw_set_reg(&cursor, UNW_X86_64_R8, signal_mcontext->r8);
- unw_set_reg(&cursor, UNW_X86_64_R9, signal_mcontext->r9);
- unw_set_reg(&cursor, UNW_X86_64_R10, signal_mcontext->r10);
- unw_set_reg(&cursor, UNW_X86_64_R11, signal_mcontext->r11);
- unw_set_reg(&cursor, UNW_X86_64_R12, signal_mcontext->r12);
- unw_set_reg(&cursor, UNW_X86_64_R13, signal_mcontext->r13);
- unw_set_reg(&cursor, UNW_X86_64_R14, signal_mcontext->r14);
- unw_set_reg(&cursor, UNW_X86_64_R15, signal_mcontext->r15);
- unw_set_reg(&cursor, UNW_X86_64_RSP, signal_mcontext->rsp);
+ if (unw_init_local(&cursor, &context)) {
+ return 0;
+ }
+ const sigcontext* signal_mcontext = (const sigcontext*)&(con->uc_mcontext);
+ unw_set_reg(&cursor, UNW_X86_64_RSI, signal_mcontext->rsi);
+ unw_set_reg(&cursor, UNW_X86_64_RDI, signal_mcontext->rdi);
+ unw_set_reg(&cursor, UNW_X86_64_RBP, signal_mcontext->rbp);
+ unw_set_reg(&cursor, UNW_X86_64_RAX, signal_mcontext->rax);
+ unw_set_reg(&cursor, UNW_X86_64_RBX, signal_mcontext->rbx);
+ unw_set_reg(&cursor, UNW_X86_64_RCX, signal_mcontext->rcx);
+ unw_set_reg(&cursor, UNW_X86_64_R8, signal_mcontext->r8);
+ unw_set_reg(&cursor, UNW_X86_64_R9, signal_mcontext->r9);
+ unw_set_reg(&cursor, UNW_X86_64_R10, signal_mcontext->r10);
+ unw_set_reg(&cursor, UNW_X86_64_R11, signal_mcontext->r11);
+ unw_set_reg(&cursor, UNW_X86_64_R12, signal_mcontext->r12);
+ unw_set_reg(&cursor, UNW_X86_64_R13, signal_mcontext->r13);
+ unw_set_reg(&cursor, UNW_X86_64_R14, signal_mcontext->r14);
+ unw_set_reg(&cursor, UNW_X86_64_R15, signal_mcontext->r15);
+ unw_set_reg(&cursor, UNW_X86_64_RSP, signal_mcontext->rsp);
- unw_set_reg(&cursor, UNW_REG_SP, signal_mcontext->rsp);
- unw_set_reg(&cursor, UNW_REG_IP, signal_mcontext->rip);
+ unw_set_reg(&cursor, UNW_REG_SP, signal_mcontext->rsp);
+ unw_set_reg(&cursor, UNW_REG_IP, signal_mcontext->rip);
- size_t pos = 0;
- p[pos++] = (void*)signal_mcontext->rip;
- while (pos < len && unw_step(&cursor) > 0) {
- unw_word_t ip = 0;
- unw_get_reg(&cursor, UNW_REG_IP, &ip);
- if (unw_is_signal_frame(&cursor)) {
- continue;
- }
- p[pos++] = (void*)ip;
+ size_t pos = 0;
+ p[pos++] = (void*)signal_mcontext->rip;
+ while (pos < len && unw_step(&cursor) > 0) {
+ unw_word_t ip = 0;
+ unw_get_reg(&cursor, UNW_REG_IP, &ip);
+ if (unw_is_signal_frame(&cursor)) {
+ continue;
}
- return pos;
+ p[pos++] = (void*)ip;
}
+ return pos;
}
+} // namespace
namespace NYql {
- namespace NBacktrace {
- size_t CollectBacktrace(void** addresses, size_t limit, void* data) {
- if (!data) {
- return BackTrace(addresses, limit);
- }
- return BackTrace(addresses, limit, reinterpret_cast<ucontext_t*>(data));
- }
+namespace NBacktrace {
+size_t CollectBacktrace(void** addresses, size_t limit, void* data) {
+ if (!data) {
+ return BackTrace(addresses, limit);
}
-} \ No newline at end of file
+ return BackTrace(addresses, limit, reinterpret_cast<ucontext_t*>(data));
+}
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/backtrace_ut.cpp b/yql/essentials/utils/backtrace/backtrace_ut.cpp
index 7cf363325e2..741af647ba8 100644
--- a/yql/essentials/utils/backtrace/backtrace_ut.cpp
+++ b/yql/essentials/utils/backtrace/backtrace_ut.cpp
@@ -3,26 +3,26 @@
#include <util/generic/string.h>
#include <library/cpp/testing/unittest/registar.h>
namespace {
- Y_NO_INLINE void TestTrace394() {
- TStringStream ss;
- NYql::NBacktrace::KikimrBackTraceFormatImpl(&ss);
+Y_NO_INLINE void TestTrace394() {
+ TStringStream ss;
+ NYql::NBacktrace::KikimrBackTraceFormatImpl(&ss);
#if !defined(_hardening_enabled_) && !defined(_win_)
- UNIT_ASSERT_STRING_CONTAINS(ss.Str(), "TestTrace394");
+ UNIT_ASSERT_STRING_CONTAINS(ss.Str(), "TestTrace394");
#endif
- }
- Y_NO_INLINE void TestTrace39114() {
- TStringStream ss;
- NYql::NBacktrace::KikimrBackTraceFormatImpl(&ss);
+}
+Y_NO_INLINE void TestTrace39114() {
+ TStringStream ss;
+ NYql::NBacktrace::KikimrBackTraceFormatImpl(&ss);
#if !defined(_hardening_enabled_) && !defined(_win_)
- UNIT_ASSERT_STRING_CONTAINS(ss.Str(), "TestTrace39114");
+ UNIT_ASSERT_STRING_CONTAINS(ss.Str(), "TestTrace39114");
#endif
- }
}
+} // namespace
Y_UNIT_TEST_SUITE(TEST_BACKTRACE_AND_SYMBOLIZE) {
- Y_UNIT_TEST(TEST_NO_KIKIMR) {
- NYql::NBacktrace::EnableKikimrSymbolize();
- TestTrace394();
- TestTrace39114();
- }
+Y_UNIT_TEST(TEST_NO_KIKIMR) {
+ NYql::NBacktrace::EnableKikimrSymbolize();
+ TestTrace394();
+ TestTrace39114();
}
+} // Y_UNIT_TEST_SUITE(TEST_BACKTRACE_AND_SYMBOLIZE)
diff --git a/yql/essentials/utils/backtrace/symbolize.cpp b/yql/essentials/utils/backtrace/symbolize.cpp
index 360ff408c7d..e96c0a313dd 100644
--- a/yql/essentials/utils/backtrace/symbolize.cpp
+++ b/yql/essentials/utils/backtrace/symbolize.cpp
@@ -7,56 +7,56 @@
namespace NYql {
- namespace NBacktrace {
- TString Symbolize(const TString& input, const THashMap<TString, TString>& mapping) {
+namespace NBacktrace {
+TString Symbolize(const TString& input, const THashMap<TString, TString>& mapping) {
#if defined(__linux__) && defined(__x86_64__)
- TString output;
- TStringOutput out(output);
-
- i64 stackSize = -1;
- TVector<TStackFrame> frames;
- TVector<TString> usedFilenames;
- for (TStringBuf line: StringSplitter(input).SplitByString("\n")) {
- if (line.StartsWith("StackFrames:")) {
- TVector<TString> parts;
- Split(TString(line), " ", parts);
- if (parts.size() > 1) {
- TryFromString<i64>(parts[1], stackSize);
- frames.reserve(stackSize);
- }
- } else if (line.StartsWith("StackFrame:")) {
- TVector<TString> parts;
- Split(TString(line), " ", parts);
- TString modulePath;
- ui64 address;
- ui64 offset;
- if (parts.size() > 3) {
- modulePath = parts[1];
- TryFromString<ui64>(parts[2], address);
- TryFromString<ui64>(parts[3], offset);
- auto it = mapping.find(modulePath);
- if (it != mapping.end()) {
- modulePath = it->second;
- }
- usedFilenames.emplace_back(std::move(modulePath));
- frames.emplace_back(TStackFrame{usedFilenames.back().c_str(), address - offset});
- }
- } else {
- out << line << "\n";
+ TString output;
+ TStringOutput out(output);
+
+ i64 stackSize = -1;
+ TVector<TStackFrame> frames;
+ TVector<TString> usedFilenames;
+ for (TStringBuf line : StringSplitter(input).SplitByString("\n")) {
+ if (line.StartsWith("StackFrames:")) {
+ TVector<TString> parts;
+ Split(TString(line), " ", parts);
+ if (parts.size() > 1) {
+ TryFromString<i64>(parts[1], stackSize);
+ frames.reserve(stackSize);
+ }
+ } else if (line.StartsWith("StackFrame:")) {
+ TVector<TString> parts;
+ Split(TString(line), " ", parts);
+ TString modulePath;
+ ui64 address;
+ ui64 offset;
+ if (parts.size() > 3) {
+ modulePath = parts[1];
+ TryFromString<ui64>(parts[2], address);
+ TryFromString<ui64>(parts[3], offset);
+ auto it = mapping.find(modulePath);
+ if (it != mapping.end()) {
+ modulePath = it->second;
}
+ usedFilenames.emplace_back(std::move(modulePath));
+ frames.emplace_back(TStackFrame{usedFilenames.back().c_str(), address - offset});
}
+ } else {
+ out << line << "\n";
+ }
+ }
- if (stackSize == 0) {
- out << "Empty stack trace\n";
- }
- Symbolize(frames.data(), frames.size(), &out);
- return output;
+ if (stackSize == 0) {
+ out << "Empty stack trace\n";
+ }
+ Symbolize(frames.data(), frames.size(), &out);
+ return output;
#else
- Y_UNUSED(mapping);
- return input;
+ Y_UNUSED(mapping);
+ return input;
#endif
- }
+}
- } /* namespace NBacktrace */
+} /* namespace NBacktrace */
} /* namespace NYql */
diff --git a/yql/essentials/utils/backtrace/symbolizer.h b/yql/essentials/utils/backtrace/symbolizer.h
index 0d32ba25d35..a3fcb0e6054 100644
--- a/yql/essentials/utils/backtrace/symbolizer.h
+++ b/yql/essentials/utils/backtrace/symbolizer.h
@@ -5,11 +5,11 @@
#include <util/generic/vector.h>
namespace NYql {
- namespace NBacktrace {
- struct TStackFrame {
- const char* File;
- size_t Address;
- };
- void Symbolize(const TStackFrame* frames, size_t count, IOutputStream* out);
- }
-} \ No newline at end of file
+namespace NBacktrace {
+struct TStackFrame {
+ const char* File;
+ size_t Address;
+};
+void Symbolize(const TStackFrame* frames, size_t count, IOutputStream* out);
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/symbolizer_linux.cpp b/yql/essentials/utils/backtrace/symbolizer_linux.cpp
index 222bc5df2e3..d92e9fc7c03 100644
--- a/yql/essentials/utils/backtrace/symbolizer_linux.cpp
+++ b/yql/essentials/utils/backtrace/symbolizer_linux.cpp
@@ -23,9 +23,12 @@ const size_t MaxStrLen = 512;
const size_t MaxDemangleLen = 1024 * 1024;
char Buff[MaxDemangleLen];
-class TNoThrowingMemoryOutput : public TMemoryOutput {
+class TNoThrowingMemoryOutput: public TMemoryOutput {
public:
- TNoThrowingMemoryOutput(void* c, size_t l) : TMemoryOutput(c, l) {}
+ TNoThrowingMemoryOutput(void* c, size_t l)
+ : TMemoryOutput(c, l)
+ {
+ }
void Truncate() {
*(Buf_ - 1) = '.';
*(Buf_ - 2) = '.';
@@ -84,67 +87,66 @@ int HandleLibBacktraceFrame(void* data, uintptr_t, const char* filename, int lin
out << functionName << " at " << fileName << ":" << lineno << ":0";
return 0;
}
-}
+} // namespace
namespace NYql {
- namespace NBacktrace {
- namespace {
- std::mutex Mutex;
- char* Result[Limit];
- size_t Order[Limit];
- char TmpBuffer[MaxStrLen * Limit]{};
- auto CreateState(const char* filename) {
- return backtrace_create_state(
- filename,
- 0,
- HandleLibBacktraceError,
- nullptr
- );
- }
+namespace NBacktrace {
+namespace {
+std::mutex Mutex;
+char* Result[Limit];
+size_t Order[Limit];
+char TmpBuffer[MaxStrLen * Limit]{};
+auto CreateState(const char* filename) {
+ return backtrace_create_state(
+ filename,
+ 0,
+ HandleLibBacktraceError,
+ nullptr);
+}
+} // namespace
+
+void Symbolize(const TStackFrame* frames, size_t count, IOutputStream* out) {
+ if (!count) {
+ return;
+ }
+ memset(TmpBuffer, 0, sizeof(TmpBuffer));
+ Result[0] = TmpBuffer;
+ for (size_t i = 1; i < Limit; ++i) {
+ Result[i] = Result[i - 1] + MaxStrLen;
+ }
+ const std::lock_guard lock{Mutex};
+
+ std::iota(Order, Order + count, 0u);
+ std::sort(Order, Order + count, [&frames](auto a, auto b) { return strcmp(frames[a].File, frames[b].File) < 0; });
+
+ struct backtrace_state* state = nullptr;
+ for (size_t i = 0; i < count; ++i) {
+ if (!i || frames[Order[i - 1]].File != frames[Order[i]].File) {
+ state = CreateState(frames[Order[i]].File);
+ }
+
+ if (!state) {
+ Result[Order[i]] = nullptr; // File not found
+ continue;
}
- void Symbolize(const TStackFrame* frames, size_t count, IOutputStream* out) {
- if (!count) {
- return;
- }
- memset(TmpBuffer, 0, sizeof(TmpBuffer));
- Result[0] = TmpBuffer;
- for (size_t i = 1; i < Limit; ++i) {
- Result[i] = Result[i - 1] + MaxStrLen;
- }
- const std::lock_guard lock{Mutex};
-
- std::iota(Order, Order + count, 0u);
- std::sort(Order, Order + count, [&frames](auto a, auto b) { return strcmp(frames[a].File, frames[b].File) < 0; });
-
- struct backtrace_state* state = nullptr;
- for (size_t i = 0; i < count; ++i) {
- if (!i || frames[Order[i - 1]].File != frames[Order[i]].File) {
- state = CreateState(frames[Order[i]].File);
- }
-
- if (!state) {
- Result[Order[i]] = nullptr; // File not found
- continue;
- }
-
- int status = backtrace_pcinfo(
- state,
- reinterpret_cast<uintptr_t>(frames[Order[i]].Address) - 1, // last byte of the call instruction
- HandleLibBacktraceFrame,
- HandleLibBacktraceError,
- reinterpret_cast<void*>(Result[Order[i]]));
- if (0 != status) {
- break;
- }
- }
- for (size_t i = 0; i < count; ++i) {
- if (Result[i]) {
- *out << Result[i] << "\n";
- } else {
- *out << "File `" << frames[i].File << "` not found\n";
- }
- }
+ int status = backtrace_pcinfo(
+ state,
+ reinterpret_cast<uintptr_t>(frames[Order[i]].Address) - 1, // last byte of the call instruction
+ HandleLibBacktraceFrame,
+ HandleLibBacktraceError,
+ reinterpret_cast<void*>(Result[Order[i]]));
+ if (0 != status) {
+ break;
}
}
-} \ No newline at end of file
+ for (size_t i = 0; i < count; ++i) {
+ if (Result[i]) {
+ *out << Result[i] << "\n";
+ } else {
+ *out << "File `" << frames[i].File << "` not found\n";
+ }
+ }
+}
+} // namespace NBacktrace
+} // namespace NYql
diff --git a/yql/essentials/utils/backtrace/ut/ya.make b/yql/essentials/utils/backtrace/ut/ya.make
index c54c56275a9..f81359303ce 100644
--- a/yql/essentials/utils/backtrace/ut/ya.make
+++ b/yql/essentials/utils/backtrace/ut/ya.make
@@ -1,5 +1,6 @@
UNITTEST_FOR(yql/essentials/utils/backtrace)
+ENABLE(YQL_STYLE_CPP)
IF (OS_LINUX AND ARCH_X86_64)
SRCS(
diff --git a/yql/essentials/utils/backtrace/ya.make b/yql/essentials/utils/backtrace/ya.make
index 30c2dd1cc11..c9457e772b7 100644
--- a/yql/essentials/utils/backtrace/ya.make
+++ b/yql/essentials/utils/backtrace/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
backtrace.cpp
backtrace_lib.cpp
@@ -31,4 +33,5 @@ ENDIF()
END()
-RECURSE_FOR_TESTS(ut) \ No newline at end of file
+RECURSE_FOR_TESTS(ut)
+
diff --git a/yql/essentials/utils/cast.h b/yql/essentials/utils/cast.h
index dac85080922..5d8dd124d8e 100644
--- a/yql/essentials/utils/cast.h
+++ b/yql/essentials/utils/cast.h
@@ -3,7 +3,7 @@
namespace NYql {
-template<class T, class F>
+template <class T, class F>
[[nodiscard]]
inline T EnsureDynamicCast(F from) {
YQL_ENSURE(from, "source should not be null");
diff --git a/yql/essentials/utils/chunked_buffer.cpp b/yql/essentials/utils/chunked_buffer.cpp
index 7ae66d04efc..75b86c2ad42 100644
--- a/yql/essentials/utils/chunked_buffer.cpp
+++ b/yql/essentials/utils/chunked_buffer.cpp
@@ -114,4 +114,4 @@ TChunkedBuffer CopyData(TChunkedBuffer&& src) {
return result;
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/chunked_buffer.h b/yql/essentials/utils/chunked_buffer.h
index 684e185fbee..8794ab8f5af 100644
--- a/yql/essentials/utils/chunked_buffer.h
+++ b/yql/essentials/utils/chunked_buffer.h
@@ -50,11 +50,12 @@ private:
size_t Size_ = 0;
};
-class TChunkedBufferOutput : public IOutputStream {
+class TChunkedBufferOutput: public IOutputStream {
public:
explicit TChunkedBufferOutput(TChunkedBuffer& dst);
+
private:
- virtual void DoWrite(const void *buf, size_t len) override;
+ virtual void DoWrite(const void* buf, size_t len) override;
TChunkedBuffer& Dst_;
};
@@ -62,4 +63,4 @@ private:
TChunkedBuffer CopyData(const TChunkedBuffer& src);
TChunkedBuffer CopyData(TChunkedBuffer&& src);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/debug_info.cpp b/yql/essentials/utils/debug_info.cpp
index ff56166695e..bfb390864fe 100644
--- a/yql/essentials/utils/debug_info.cpp
+++ b/yql/essentials/utils/debug_info.cpp
@@ -7,25 +7,22 @@
#include <string.h>
-
namespace NYql {
static const size_t OPERATION_ID_MAX_LENGTH = 24;
static const size_t THREAD_NAME_MAX_LENGTH = 16;
-
struct TDebugInfo {
char OperationId[OPERATION_ID_MAX_LENGTH + 1];
};
Y_POD_THREAD(TDebugInfo) TlsDebugInfo;
-
void SetCurrentOperationId(const char* operationId) {
size_t len = strlcpy(
- (&TlsDebugInfo)->OperationId,
- operationId,
- OPERATION_ID_MAX_LENGTH);
+ (&TlsDebugInfo)->OperationId,
+ operationId,
+ OPERATION_ID_MAX_LENGTH);
const char* threadName = nullptr;
if (len > THREAD_NAME_MAX_LENGTH) {
@@ -38,11 +35,11 @@ void SetCurrentOperationId(const char* operationId) {
long GetRunnigThreadsCount() {
TString procStat = TFileInput("/proc/self/stat").ReadAll();
- long num_threads = -2; // Number of threads in this process (since Linux 2.6)
+ long num_threads = -2; // Number of threads in this process (since Linux 2.6)
int n = sscanf(procStat.data(),
- "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld",
- &num_threads);
+ "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %ld",
+ &num_threads);
return n == 1 ? num_threads : -2;
}
diff --git a/yql/essentials/utils/debug_info.h b/yql/essentials/utils/debug_info.h
index 3e2a55140b1..40502060426 100644
--- a/yql/essentials/utils/debug_info.h
+++ b/yql/essentials/utils/debug_info.h
@@ -1,6 +1,5 @@
#pragma once
-
namespace NYql {
void SetCurrentOperationId(const char* operationId);
diff --git a/yql/essentials/utils/docs/link.cpp b/yql/essentials/utils/docs/link.cpp
index 2fd5321ff12..af3d648db9e 100644
--- a/yql/essentials/utils/docs/link.cpp
+++ b/yql/essentials/utils/docs/link.cpp
@@ -11,102 +11,102 @@
namespace NYql::NDocs {
- TLinkTarget TLinkTarget::Parse(TStringBuf string) {
- static const RE2 Regex(R"re(([^#?()]*)(#[^?()]*)?)re");
-
- TString path;
- TString anchor;
- if (RE2::FullMatch(string, Regex, &path, &anchor)) {
- if (!anchor.empty()) {
- YQL_ENSURE(anchor.StartsWith('#'));
- anchor.erase(0, 1);
- }
-
- return {
- .RelativePath = path,
- .Anchor = !anchor.empty() ? TMaybe<TString>(anchor) : Nothing(),
- };
+TLinkTarget TLinkTarget::Parse(TStringBuf string) {
+ static const RE2 Regex(R"re(([^#?()]*)(#[^?()]*)?)re");
+
+ TString path;
+ TString anchor;
+ if (RE2::FullMatch(string, Regex, &path, &anchor)) {
+ if (!anchor.empty()) {
+ YQL_ENSURE(anchor.StartsWith('#'));
+ anchor.erase(0, 1);
}
- throw yexception()
- << "invalid link target '" << string << "': "
- << "does not match regex '" << Regex.pattern() << "'";
+ return {
+ .RelativePath = path,
+ .Anchor = !anchor.empty() ? TMaybe<TString>(anchor) : Nothing(),
+ };
}
- TMaybe<TLinkTarget> LookupUDF(const TLinks& links, TStringBuf name) {
- const auto udf = SplitUDF(TString(name));
- YQL_ENSURE(udf, "Invalid UDF: " << name);
+ throw yexception()
+ << "invalid link target '" << string << "': "
+ << "does not match regex '" << Regex.pattern() << "'";
+}
- const auto [module, function] = *udf;
+TMaybe<TLinkTarget> LookupUDF(const TLinks& links, TStringBuf name) {
+ const auto udf = SplitUDF(TString(name));
+ YQL_ENSURE(udf, "Invalid UDF: " << name);
- if (const TLinkTarget* target = nullptr;
- (target = links.FindPtr(module + "::" + function)) ||
- (target = links.FindPtr(module + "::" + "*"))) {
- return *target;
- }
+ const auto [module, function] = *udf;
- return Nothing();
+ if (const TLinkTarget* target = nullptr;
+ (target = links.FindPtr(module + "::" + function)) ||
+ (target = links.FindPtr(module + "::" + "*"))) {
+ return *target;
}
- TMaybe<TLinkTarget> LookupBasic(const TLinks& links, TStringBuf name) {
- TMaybe<TLinkKey> key = NormalizedName(TString(name));
- if (!key) {
- return Nothing();
- }
-
- if (const TLinkTarget* target = links.FindPtr(*key)) {
- return *target;
- }
+ return Nothing();
+}
+TMaybe<TLinkTarget> LookupBasic(const TLinks& links, TStringBuf name) {
+ TMaybe<TLinkKey> key = NormalizedName(TString(name));
+ if (!key) {
return Nothing();
}
- TMaybe<TLinkTarget> Lookup(const TLinks& links, TStringBuf name) {
- if (IsUDF(name)) {
- return LookupUDF(links, name);
- }
+ if (const TLinkTarget* target = links.FindPtr(*key)) {
+ return *target;
+ }
+
+ return Nothing();
+}
- return LookupBasic(links, name);
+TMaybe<TLinkTarget> Lookup(const TLinks& links, TStringBuf name) {
+ if (IsUDF(name)) {
+ return LookupUDF(links, name);
}
- TLinkKey ParseLinkKey(TStringBuf string) {
- static RE2 UDFRegex(TStringBuilder()
- << "(" << NormalizedNameRegex.pattern() << ")\\:\\:("
- << "\\*|" << NormalizedNameRegex.pattern() << ")");
+ return LookupBasic(links, name);
+}
- if (IsNormalizedName(string)) {
- return TString(string);
- }
+TLinkKey ParseLinkKey(TStringBuf string) {
+ static RE2 UDFRegex(TStringBuilder()
+ << "(" << NormalizedNameRegex.pattern() << ")\\:\\:("
+ << "\\*|" << NormalizedNameRegex.pattern() << ")");
- if (RE2::FullMatch(string, UDFRegex)) {
- return TString(string);
- }
+ if (IsNormalizedName(string)) {
+ return TString(string);
+ }
- ythrow yexception()
- << "invalid link key '" << string << "': "
- << "does not match any regex";
+ if (RE2::FullMatch(string, UDFRegex)) {
+ return TString(string);
}
- TLinks ParseLinks(const NJson::TJsonValue& json) {
- TLinks links;
- for (const auto& [keyString, value] : json.GetMapSafe()) {
- TLinkKey key = ParseLinkKey(keyString);
- TLinkTarget target = TLinkTarget::Parse(value.GetStringSafe());
- links[std::move(key)] = std::move(target);
- }
- return links;
+ ythrow yexception()
+ << "invalid link key '" << string << "': "
+ << "does not match any regex";
+}
+
+TLinks ParseLinks(const NJson::TJsonValue& json) {
+ TLinks links;
+ for (const auto& [keyString, value] : json.GetMapSafe()) {
+ TLinkKey key = ParseLinkKey(keyString);
+ TLinkTarget target = TLinkTarget::Parse(value.GetStringSafe());
+ links[std::move(key)] = std::move(target);
}
+ return links;
+}
- TLinks Merge(TLinks&& lhs, TLinks&& rhs) {
- for (auto& [k, v] : rhs) {
- YQL_ENSURE(
- !lhs.contains(k),
- "Duplicate '" << k << "', old '" << lhs[k] << "', new '" << v << "'");
+TLinks Merge(TLinks&& lhs, TLinks&& rhs) {
+ for (auto& [k, v] : rhs) {
+ YQL_ENSURE(
+ !lhs.contains(k),
+ "Duplicate '" << k << "', old '" << lhs[k] << "', new '" << v << "'");
- lhs[k] = std::move(v);
- }
- return lhs;
+ lhs[k] = std::move(v);
}
+ return lhs;
+}
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/link.h b/yql/essentials/utils/docs/link.h
index 961f460b99a..70e91d99a27 100644
--- a/yql/essentials/utils/docs/link.h
+++ b/yql/essentials/utils/docs/link.h
@@ -7,23 +7,23 @@
namespace NYql::NDocs {
- struct TLinkTarget {
- TString RelativePath;
- TMaybe<TString> Anchor;
+struct TLinkTarget {
+ TString RelativePath;
+ TMaybe<TString> Anchor;
- static TLinkTarget Parse(TStringBuf string);
- };
+ static TLinkTarget Parse(TStringBuf string);
+};
- using TLinkKey = TString;
+using TLinkKey = TString;
- using TLinks = THashMap<TLinkKey, TLinkTarget>;
+using TLinks = THashMap<TLinkKey, TLinkTarget>;
- TMaybe<TLinkTarget> Lookup(const TLinks& links, TStringBuf name);
+TMaybe<TLinkTarget> Lookup(const TLinks& links, TStringBuf name);
- TLinkKey ParseLinkKey(TStringBuf string);
+TLinkKey ParseLinkKey(TStringBuf string);
- TLinks ParseLinks(const NJson::TJsonValue& json);
+TLinks ParseLinks(const NJson::TJsonValue& json);
- TLinks Merge(TLinks&& lhs, TLinks&& rhs);
+TLinks Merge(TLinks&& lhs, TLinks&& rhs);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/link_page.cpp b/yql/essentials/utils/docs/link_page.cpp
index eb71979462d..985410fafd5 100644
--- a/yql/essentials/utils/docs/link_page.cpp
+++ b/yql/essentials/utils/docs/link_page.cpp
@@ -7,110 +7,110 @@
namespace NYql::NDocs {
- TMaybe<TString> MatchSingleFunctionHeader(TStringBuf header) {
- return NormalizedName(TString(header));
+TMaybe<TString> MatchSingleFunctionHeader(TStringBuf header) {
+ return NormalizedName(TString(header));
+}
+
+TVector<TString> SplitBy(TStringBuf delim, const TVector<TString>& strings) {
+ TVector<TString> parts;
+ for (const TString& s : strings) {
+ StringSplitter(s).SplitByString(delim).AddTo(&parts);
}
-
- TVector<TString> SplitBy(TStringBuf delim, const TVector<TString>& strings) {
- TVector<TString> parts;
- for (const TString& s : strings) {
- StringSplitter(s).SplitByString(delim).AddTo(&parts);
+ return parts;
+}
+
+TVector<TString> SplitByPunctuation(TStringBuf header) {
+ TVector<TString> parts = {TString(header)};
+ parts = SplitBy(" и ", parts);
+ parts = SplitBy(" / ", parts);
+ parts = SplitBy(", ", parts);
+ return parts;
+}
+
+TVector<TString> MatchMultiFunctionHeader(TStringBuf header) {
+ TVector<TString> names = SplitByPunctuation(header);
+
+ for (TString& name : names) {
+ TMaybe<TString> normalized = NormalizedName(std::move(name));
+ if (!normalized) {
+ return {};
}
- return parts;
- }
- TVector<TString> SplitByPunctuation(TStringBuf header) {
- TVector<TString> parts = {TString(header)};
- parts = SplitBy(" и ", parts);
- parts = SplitBy(" / ", parts);
- parts = SplitBy(", ", parts);
- return parts;
+ name = std::move(*normalized);
}
- TVector<TString> MatchMultiFunctionHeader(TStringBuf header) {
- TVector<TString> names = SplitByPunctuation(header);
-
- for (TString& name : names) {
- TMaybe<TString> normalized = NormalizedName(std::move(name));
- if (!normalized) {
- return {};
- }
-
- name = std::move(*normalized);
- }
+ return names;
+}
- return names;
+TVector<TString> ExtractNormalized(TStringBuf header) {
+ if (auto single = MatchSingleFunctionHeader(header)) {
+ return {*single};
}
-
- TVector<TString> ExtractNormalized(TStringBuf header) {
- if (auto single = MatchSingleFunctionHeader(header)) {
- return {*single};
- }
- if (auto multi = MatchMultiFunctionHeader(header)) {
- return multi;
- }
- return {};
+ if (auto multi = MatchMultiFunctionHeader(header)) {
+ return multi;
}
-
- void EnrichFromMarkdown(TLinks& links, const TString& path, const TMarkdownHeader& header) {
- for (const TString& name : ExtractNormalized(header.Content)) {
- links[name] = {
- .RelativePath = path,
- .Anchor = header.Anchor,
- };
- }
+ return {};
+}
+
+void EnrichFromMarkdown(TLinks& links, const TString& path, const TMarkdownHeader& header) {
+ for (const TString& name : ExtractNormalized(header.Content)) {
+ links[name] = {
+ .RelativePath = path,
+ .Anchor = header.Anchor,
+ };
}
+}
- void EnrichFromMarkdown(TLinks& links, const TString& path, const TMarkdownPage& page) {
- for (const auto& [anchor, section] : page.SectionsByAnchor) {
- const TMarkdownHeader& header = section.Header;
- EnrichFromMarkdown(links, path, header);
- }
+void EnrichFromMarkdown(TLinks& links, const TString& path, const TMarkdownPage& page) {
+ for (const auto& [anchor, section] : page.SectionsByAnchor) {
+ const TMarkdownHeader& header = section.Header;
+ EnrichFromMarkdown(links, path, header);
}
+}
- void EnrichFromMarkdown(TLinks& links, const TPages& pages) {
- for (const auto& [path, page] : pages) {
- EnrichFromMarkdown(links, path, page);
- }
+void EnrichFromMarkdown(TLinks& links, const TPages& pages) {
+ for (const auto& [path, page] : pages) {
+ EnrichFromMarkdown(links, path, page);
}
-
- TLinks GetLinksFromPages(const TPages& pages) {
- TLinks links;
- EnrichFromMarkdown(links, pages);
- return links;
+}
+
+TLinks GetLinksFromPages(const TPages& pages) {
+ TLinks links;
+ EnrichFromMarkdown(links, pages);
+ return links;
+}
+
+TPages Stripped(TPages&& pages, const TLinks& links) {
+ THashSet<TString> usedPaths;
+ THashMap<TString, THashSet<TString>> usedAnchors;
+ for (const auto& [_, link] : links) {
+ TString anchor = link.Anchor.GetOrElse("");
+ usedAnchors[link.RelativePath].emplace(std::move(anchor));
}
- TPages Stripped(TPages&& pages, const TLinks& links) {
- THashSet<TString> usedPaths;
- THashMap<TString, THashSet<TString>> usedAnchors;
- for (const auto& [_, link] : links) {
- TString anchor = link.Anchor.GetOrElse("");
- usedAnchors[link.RelativePath].emplace(std::move(anchor));
- }
-
- THashSet<TString> unusedPaths;
- THashMap<TString, THashSet<TString>> unusedAnchors;
- for (const auto& [path, page] : pages) {
- for (const auto& [anchor, _] : page.SectionsByAnchor) {
- if (!usedAnchors.contains(path)) {
- unusedPaths.emplace(path);
- } else if (!usedAnchors[path].contains(anchor)) {
- unusedAnchors[path].emplace(anchor);
- }
- }
- }
-
- for (const auto& [path, anchors] : unusedAnchors) {
- for (const auto& anchor : anchors) {
- pages[path].SectionsByAnchor.erase(anchor);
+ THashSet<TString> unusedPaths;
+ THashMap<TString, THashSet<TString>> unusedAnchors;
+ for (const auto& [path, page] : pages) {
+ for (const auto& [anchor, _] : page.SectionsByAnchor) {
+ if (!usedAnchors.contains(path)) {
+ unusedPaths.emplace(path);
+ } else if (!usedAnchors[path].contains(anchor)) {
+ unusedAnchors[path].emplace(anchor);
}
}
+ }
- for (const auto& path : unusedPaths) {
- pages.erase(path);
+ for (const auto& [path, anchors] : unusedAnchors) {
+ for (const auto& anchor : anchors) {
+ pages[path].SectionsByAnchor.erase(anchor);
}
+ }
- return pages;
+ for (const auto& path : unusedPaths) {
+ pages.erase(path);
}
+ return pages;
+}
+
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/link_page.h b/yql/essentials/utils/docs/link_page.h
index beeb1252ef2..532da3fc539 100644
--- a/yql/essentials/utils/docs/link_page.h
+++ b/yql/essentials/utils/docs/link_page.h
@@ -5,8 +5,8 @@
namespace NYql::NDocs {
- TLinks GetLinksFromPages(const TPages& pages);
+TLinks GetLinksFromPages(const TPages& pages);
- TPages Stripped(TPages&& pages, const TLinks& links);
+TPages Stripped(TPages&& pages, const TLinks& links);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/markdown.cpp b/yql/essentials/utils/docs/markdown.cpp
index fd13820b8c4..fb4209717e4 100644
--- a/yql/essentials/utils/docs/markdown.cpp
+++ b/yql/essentials/utils/docs/markdown.cpp
@@ -9,127 +9,127 @@
namespace NYql::NDocs {
- class TMarkdownParser {
- private:
- static constexpr TStringBuf HeaderRegex = R"re(([^#]+)(\s+{#([a-z0-9\-_]+)})?)re";
-
- public:
- explicit TMarkdownParser(size_t headerDepth)
- : HeaderDepth_(headerDepth)
- , SectionHeaderRegex_(" *" + TString(HeaderDepth_, '#') + " " + HeaderRegex)
- , IsSkipping_(true)
- {
- }
+class TMarkdownParser {
+private:
+ static constexpr TStringBuf HeaderRegex = R"re(([^#]+)(\s+{#([a-z0-9\-_]+)})?)re";
+
+public:
+ explicit TMarkdownParser(size_t headerDepth)
+ : HeaderDepth_(headerDepth)
+ , SectionHeaderRegex_(" *" + TString(HeaderDepth_, '#') + " " + HeaderRegex)
+ , IsSkipping_(true)
+ {
+ }
- void Parse(IInputStream& markdown, TMarkdownCallback&& onSection) {
- for (TString line; markdown.ReadLine(line) != 0;) {
- size_t depth = HeaderDepth(line);
- if (IsSkipping_) {
- if (HeaderDepth_ == depth) {
- ResetSection(std::move(line));
- IsSkipping_ = false;
- } else {
- // Skip
- }
+ void Parse(IInputStream& markdown, TMarkdownCallback&& onSection) {
+ for (TString line; markdown.ReadLine(line) != 0;) {
+ size_t depth = HeaderDepth(line);
+ if (IsSkipping_) {
+ if (HeaderDepth_ == depth) {
+ ResetSection(std::move(line));
+ IsSkipping_ = false;
} else {
- if (HeaderDepth_ == depth) {
- onSection(std::move(Section_));
- ResetSection(std::move(line));
- } else if (depth == 0 || HeaderDepth_ < depth) {
- line.append('\n');
- Section_.Body.append(std::move(line));
- } else {
- onSection(std::move(Section_));
- IsSkipping_ = true;
- }
+ // Skip
+ }
+ } else {
+ if (HeaderDepth_ == depth) {
+ onSection(std::move(Section_));
+ ResetSection(std::move(line));
+ } else if (depth == 0 || HeaderDepth_ < depth) {
+ line.append('\n');
+ Section_.Body.append(std::move(line));
+ } else {
+ onSection(std::move(Section_));
+ IsSkipping_ = true;
}
- }
-
- if (!IsSkipping_) {
- onSection(std::move(Section_));
}
}
- private:
- void ResetSection(TString&& line) {
- Section_ = TMarkdownSection();
+ if (!IsSkipping_) {
+ onSection(std::move(Section_));
+ }
+ }
- TString content;
- std::optional<TString> dummy;
- std::optional<TString> anchor;
- if (!RE2::FullMatch(line, SectionHeaderRegex_, &content, &dummy, &anchor)) {
- Section_.Header.Content = std::move(line);
- return;
- }
+private:
+ void ResetSection(TString&& line) {
+ Section_ = TMarkdownSection();
- Section_.Header.Content = std::move(content);
- if (anchor) {
- Section_.Header.Anchor = std::move(*anchor);
- }
+ TString content;
+ std::optional<TString> dummy;
+ std::optional<TString> anchor;
+ if (!RE2::FullMatch(line, SectionHeaderRegex_, &content, &dummy, &anchor)) {
+ Section_.Header.Content = std::move(line);
+ return;
}
- size_t HeaderDepth(TStringBuf line) const {
- while (line.StartsWith(' ') || line.StartsWith('\t')) {
- line.Skip(1);
- }
+ Section_.Header.Content = std::move(content);
+ if (anchor) {
+ Section_.Header.Anchor = std::move(*anchor);
+ }
+ }
- if (!line.StartsWith('#')) {
- return 0;
- }
+ size_t HeaderDepth(TStringBuf line) const {
+ while (line.StartsWith(' ') || line.StartsWith('\t')) {
+ line.Skip(1);
+ }
- size_t begin = line.find('#');
- size_t end = line.find_first_not_of('#', begin);
- return end != TStringBuf::npos ? (end - begin) : 0;
+ if (!line.StartsWith('#')) {
+ return 0;
}
- size_t HeaderDepth_;
- RE2 SectionHeaderRegex_;
- bool IsSkipping_;
- TMarkdownSection Section_;
- };
+ size_t begin = line.find('#');
+ size_t end = line.find_first_not_of('#', begin);
+ return end != TStringBuf::npos ? (end - begin) : 0;
+ }
- TMaybe<TString> Anchor(const TMarkdownHeader& header) {
- static RE2 Regex(R"re([0-9a-z\-_]+)re");
+ size_t HeaderDepth_;
+ RE2 SectionHeaderRegex_;
+ bool IsSkipping_;
+ TMarkdownSection Section_;
+};
- if (header.Anchor) {
- return header.Anchor;
- }
+TMaybe<TString> Anchor(const TMarkdownHeader& header) {
+ static RE2 Regex(R"re([0-9a-z\-_]+)re");
- TString content = ToLowerUTF8(header.Content);
- SubstGlobal(content, ' ', '-');
+ if (header.Anchor) {
+ return header.Anchor;
+ }
- if (RE2::FullMatch(content, Regex)) {
- return content;
- }
+ TString content = ToLowerUTF8(header.Content);
+ SubstGlobal(content, ' ', '-');
- return Nothing();
+ if (RE2::FullMatch(content, Regex)) {
+ return content;
}
- TMarkdownPage ParseMarkdownPage(TString markdown) {
- TMarkdownPage page;
+ return Nothing();
+}
- const auto onSection = [&](TMarkdownSection&& section) {
- if (TMaybe<TString> anchor = Anchor(section.Header)) {
- section.Header.Anchor = anchor;
- page.SectionsByAnchor[*anchor] = std::move(section);
- }
- };
+TMarkdownPage ParseMarkdownPage(TString markdown) {
+ TMarkdownPage page;
- {
- TMarkdownParser parser(/*headerDepth=*/2);
- TStringStream stream(markdown);
- parser.Parse(stream, onSection);
- }
-
- {
- TMarkdownParser parser(/*headerDepth=*/3);
- TStringStream stream(markdown);
- parser.Parse(stream, onSection);
+ const auto onSection = [&](TMarkdownSection&& section) {
+ if (TMaybe<TString> anchor = Anchor(section.Header)) {
+ section.Header.Anchor = anchor;
+ page.SectionsByAnchor[*anchor] = std::move(section);
}
+ };
- page.Text = std::move(markdown);
+ {
+ TMarkdownParser parser(/*headerDepth=*/2);
+ TStringStream stream(markdown);
+ parser.Parse(stream, onSection);
+ }
- return page;
+ {
+ TMarkdownParser parser(/*headerDepth=*/3);
+ TStringStream stream(markdown);
+ parser.Parse(stream, onSection);
}
+ page.Text = std::move(markdown);
+
+ return page;
+}
+
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/markdown.h b/yql/essentials/utils/docs/markdown.h
index 6b5477ac253..ebc9707f52a 100644
--- a/yql/essentials/utils/docs/markdown.h
+++ b/yql/essentials/utils/docs/markdown.h
@@ -7,23 +7,23 @@
namespace NYql::NDocs {
- struct TMarkdownHeader {
- TString Content;
- TMaybe<TString> Anchor;
- };
+struct TMarkdownHeader {
+ TString Content;
+ TMaybe<TString> Anchor;
+};
- struct TMarkdownSection {
- TMarkdownHeader Header;
- TString Body;
- };
+struct TMarkdownSection {
+ TMarkdownHeader Header;
+ TString Body;
+};
- struct TMarkdownPage {
- TString Text;
- THashMap<TString, TMarkdownSection> SectionsByAnchor;
- };
+struct TMarkdownPage {
+ TString Text;
+ THashMap<TString, TMarkdownSection> SectionsByAnchor;
+};
- using TMarkdownCallback = std::function<void(TMarkdownSection&&)>;
+using TMarkdownCallback = std::function<void(TMarkdownSection&&)>;
- TMarkdownPage ParseMarkdownPage(TString markdown);
+TMarkdownPage ParseMarkdownPage(TString markdown);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/markdown_ut.cpp b/yql/essentials/utils/docs/markdown_ut.cpp
index 45e45e645a5..7aee0e3deac 100644
--- a/yql/essentials/utils/docs/markdown_ut.cpp
+++ b/yql/essentials/utils/docs/markdown_ut.cpp
@@ -6,8 +6,8 @@ using namespace NYql::NDocs;
Y_UNIT_TEST_SUITE(MarkdownParserTests) {
- Y_UNIT_TEST(ParseMarkdown) {
- TString markdown = R"(
+Y_UNIT_TEST(ParseMarkdown) {
+ TString markdown = R"(
# Basic built-in functions
Below are the general-purpose functions.
@@ -51,27 +51,27 @@ SELECT
FROM my_table;
```
)";
- TMarkdownPage page = ParseMarkdownPage(markdown);
-
- UNIT_ASSERT_VALUES_EQUAL(page.SectionsByAnchor.size(), 2);
-
- const auto& coelcese = page.SectionsByAnchor["coalesce"];
- UNIT_ASSERT_STRING_CONTAINS(coelcese.Header.Content, "COALESCE");
- UNIT_ASSERT_VALUES_EQUAL(coelcese.Header.Anchor, "coalesce");
- UNIT_ASSERT_STRING_CONTAINS(coelcese.Body, "Iterates");
- UNIT_ASSERT_STRING_CONTAINS(coelcese.Body, "COALESCE");
- UNIT_ASSERT_GE(Count(coelcese.Body, '\n'), 5);
-
- const auto& random = page.SectionsByAnchor["random"];
- UNIT_ASSERT_STRING_CONTAINS(random.Header.Content, "Random");
- UNIT_ASSERT_VALUES_EQUAL(random.Header.Anchor, "random");
- UNIT_ASSERT_STRING_CONTAINS(random.Body, "Generates");
- UNIT_ASSERT_STRING_CONTAINS(random.Body, "Random");
- UNIT_ASSERT_GE(Count(random.Body, '\n'), 5);
- }
-
- Y_UNIT_TEST(NestedSections) {
- TString markdown = R"(
+ TMarkdownPage page = ParseMarkdownPage(markdown);
+
+ UNIT_ASSERT_VALUES_EQUAL(page.SectionsByAnchor.size(), 2);
+
+ const auto& coelcese = page.SectionsByAnchor["coalesce"];
+ UNIT_ASSERT_STRING_CONTAINS(coelcese.Header.Content, "COALESCE");
+ UNIT_ASSERT_VALUES_EQUAL(coelcese.Header.Anchor, "coalesce");
+ UNIT_ASSERT_STRING_CONTAINS(coelcese.Body, "Iterates");
+ UNIT_ASSERT_STRING_CONTAINS(coelcese.Body, "COALESCE");
+ UNIT_ASSERT_GE(Count(coelcese.Body, '\n'), 5);
+
+ const auto& random = page.SectionsByAnchor["random"];
+ UNIT_ASSERT_STRING_CONTAINS(random.Header.Content, "Random");
+ UNIT_ASSERT_VALUES_EQUAL(random.Header.Anchor, "random");
+ UNIT_ASSERT_STRING_CONTAINS(random.Body, "Generates");
+ UNIT_ASSERT_STRING_CONTAINS(random.Body, "Random");
+ UNIT_ASSERT_GE(Count(random.Body, '\n'), 5);
+}
+
+Y_UNIT_TEST(NestedSections) {
+ TString markdown = R"(
# Section 1 {#s1}
Section 1 Text.
## Subsection 1 {#s1s1}
@@ -89,19 +89,19 @@ Subsection 2.2.1 Text.
# Section 3 {#s3}
Section 3 Text.
)";
- TMarkdownPage page = ParseMarkdownPage(markdown);
- {
- const TMarkdownSection& section = page.SectionsByAnchor["s1s2"];
- UNIT_ASSERT_STRING_CONTAINS(section.Body, "Subsection 1.2 Text.");
- UNIT_ASSERT_C(!section.Body.Contains("Section 1 Text."), section.Body);
- UNIT_ASSERT_C(!section.Body.Contains("Section 2 Text."), section.Body);
- UNIT_ASSERT_C(!section.Body.Contains("Section 3 Text."), section.Body);
- }
- {
- const TMarkdownSection& section = page.SectionsByAnchor["s2s2s1"];
- UNIT_ASSERT_STRING_CONTAINS(section.Body, "Subsection 2.2.1 Text.");
- UNIT_ASSERT_C(!section.Body.Contains("Section 3 Text."), section.Body);
- }
+ TMarkdownPage page = ParseMarkdownPage(markdown);
+ {
+ const TMarkdownSection& section = page.SectionsByAnchor["s1s2"];
+ UNIT_ASSERT_STRING_CONTAINS(section.Body, "Subsection 1.2 Text.");
+ UNIT_ASSERT_C(!section.Body.Contains("Section 1 Text."), section.Body);
+ UNIT_ASSERT_C(!section.Body.Contains("Section 2 Text."), section.Body);
+ UNIT_ASSERT_C(!section.Body.Contains("Section 3 Text."), section.Body);
+ }
+ {
+ const TMarkdownSection& section = page.SectionsByAnchor["s2s2s1"];
+ UNIT_ASSERT_STRING_CONTAINS(section.Body, "Subsection 2.2.1 Text.");
+ UNIT_ASSERT_C(!section.Body.Contains("Section 3 Text."), section.Body);
}
+}
} // Y_UNIT_TEST_SUITE(MarkdownParserTests)
diff --git a/yql/essentials/utils/docs/name.cpp b/yql/essentials/utils/docs/name.cpp
index 570bf23f313..9ebf04d06bd 100644
--- a/yql/essentials/utils/docs/name.cpp
+++ b/yql/essentials/utils/docs/name.cpp
@@ -7,43 +7,43 @@
namespace NYql::NDocs {
- const RE2 NormalizedNameRegex(R"re([a-z_]{1,2}[a-z0-9]*)re");
+const RE2 NormalizedNameRegex(R"re([a-z_]{1,2}[a-z0-9]*)re");
- bool IsNormalizedName(TStringBuf name) {
- return RE2::FullMatch(name, NormalizedNameRegex);
+bool IsNormalizedName(TStringBuf name) {
+ return RE2::FullMatch(name, NormalizedNameRegex);
+}
+
+TMaybe<TString> NormalizedName(TString name) {
+ if (TMaybe<TIssue> issue = NormalizeName(TPosition(), name)) {
+ return Nothing();
}
- TMaybe<TString> NormalizedName(TString name) {
- if (TMaybe<TIssue> issue = NormalizeName(TPosition(), name)) {
- return Nothing();
- }
+ if (!IsNormalizedName(name)) {
+ return Nothing();
+ }
- if (!IsNormalizedName(name)) {
- return Nothing();
- }
+ return name;
+}
- return name;
- }
+bool IsUDF(TStringBuf name) {
+ return name.Contains("::");
+}
- bool IsUDF(TStringBuf name) {
- return name.Contains("::");
+TMaybe<std::pair<TString, TString>> SplitUDF(TString name) {
+ if (!IsUDF(name)) {
+ return Nothing();
}
- TMaybe<std::pair<TString, TString>> SplitUDF(TString name) {
- if (!IsUDF(name)) {
- return Nothing();
- }
+ TVector<TString> words;
+ words.reserve(2);
+ StringSplitter(name).SplitByString("::").Collect(&words);
+ YQL_ENSURE(words.size() == 2, "Invalid UDF pattern: " << name);
- TVector<TString> words;
- words.reserve(2);
- StringSplitter(name).SplitByString("::").Collect(&words);
- YQL_ENSURE(words.size() == 2, "Invalid UDF pattern: " << name);
+ TMaybe<TString> module = NormalizedName(std::move(words[0]));
+ TMaybe<TString> function = NormalizedName(std::move(words[1]));
+ YQL_ENSURE(module && function, "Unable to normalize " << name);
- TMaybe<TString> module = NormalizedName(std::move(words[0]));
- TMaybe<TString> function = NormalizedName(std::move(words[1]));
- YQL_ENSURE(module && function, "Unable to normalize " << name);
-
- return std::make_pair(*module, *function);
- }
+ return std::make_pair(*module, *function);
+}
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/name.h b/yql/essentials/utils/docs/name.h
index 3ab303ca23f..0328801b76b 100644
--- a/yql/essentials/utils/docs/name.h
+++ b/yql/essentials/utils/docs/name.h
@@ -6,14 +6,14 @@
namespace NYql::NDocs {
- extern const RE2 NormalizedNameRegex;
+extern const RE2 NormalizedNameRegex;
- bool IsNormalizedName(TStringBuf name);
+bool IsNormalizedName(TStringBuf name);
- TMaybe<TString> NormalizedName(TString name);
+TMaybe<TString> NormalizedName(TString name);
- bool IsUDF(TStringBuf name);
+bool IsUDF(TStringBuf name);
- TMaybe<std::pair<TString, TString>> SplitUDF(TString name);
+TMaybe<std::pair<TString, TString>> SplitUDF(TString name);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/page.cpp b/yql/essentials/utils/docs/page.cpp
index 516b8b2886e..f0b1671a9dd 100644
--- a/yql/essentials/utils/docs/page.cpp
+++ b/yql/essentials/utils/docs/page.cpp
@@ -6,71 +6,71 @@
namespace NYql::NDocs {
- TString ResolvedMarkdownText(TStringBuf relativePath, TString text, TStringBuf baseURL) {
- static const RE2 anchorRegex(R"re(\[([^\\\]]+)\]\((#[^\\)]+)\))re");
- static const RE2 linkRegex(R"re(\[([^\\\]]+)\]\(([A-Za-z0-9/_\-\.]+).md(#[^\\)]+)?\))re");
+TString ResolvedMarkdownText(TStringBuf relativePath, TString text, TStringBuf baseURL) {
+ static const RE2 anchorRegex(R"re(\[([^\\\]]+)\]\((#[^\\)]+)\))re");
+ static const RE2 linkRegex(R"re(\[([^\\\]]+)\]\(([A-Za-z0-9/_\-\.]+).md(#[^\\)]+)?\))re");
- TString base = TString(baseURL) + "/" + TString(relativePath);
- TString anchorRewrite = "[\\1](" + base + "\\2)";
- TString linkRewrite = "[\\1](" + base + "/../" + "\\2\\3)";
+ TString base = TString(baseURL) + "/" + TString(relativePath);
+ TString anchorRewrite = "[\\1](" + base + "\\2)";
+ TString linkRewrite = "[\\1](" + base + "/../" + "\\2\\3)";
- TString error;
- YQL_ENSURE(
- anchorRegex.CheckRewriteString(anchorRewrite, &error),
- "Bad rewrite '" << anchorRewrite << "': " << error);
- YQL_ENSURE(
- linkRegex.CheckRewriteString(linkRewrite, &error),
- "Bad rewrite '" << linkRewrite << "': " << error);
+ TString error;
+ YQL_ENSURE(
+ anchorRegex.CheckRewriteString(anchorRewrite, &error),
+ "Bad rewrite '" << anchorRewrite << "': " << error);
+ YQL_ENSURE(
+ linkRegex.CheckRewriteString(linkRewrite, &error),
+ "Bad rewrite '" << linkRewrite << "': " << error);
- RE2::GlobalReplace(&text, anchorRegex, anchorRewrite);
- RE2::GlobalReplace(&text, linkRegex, linkRewrite);
+ RE2::GlobalReplace(&text, anchorRegex, anchorRewrite);
+ RE2::GlobalReplace(&text, linkRegex, linkRewrite);
- return text;
- }
+ return text;
+}
- TMarkdownPage Resolved(TStringBuf relativePath, TMarkdownPage page, TStringBuf baseURL) {
- page.Text = ResolvedMarkdownText(relativePath, page.Text, baseURL);
- for (auto& [_, section] : page.SectionsByAnchor) {
- section.Body = ResolvedMarkdownText(relativePath, std::move(section.Body), baseURL);
- }
- return page;
+TMarkdownPage Resolved(TStringBuf relativePath, TMarkdownPage page, TStringBuf baseURL) {
+ page.Text = ResolvedMarkdownText(relativePath, page.Text, baseURL);
+ for (auto& [_, section] : page.SectionsByAnchor) {
+ section.Body = ResolvedMarkdownText(relativePath, std::move(section.Body), baseURL);
}
+ return page;
+}
- TString ExtendedSyntaxRemoved(TString text) {
- static const RE2 regex(R"re( *{%[^\\]*?%} *\n?)re");
- RE2::GlobalReplace(&text, regex, "");
- return text;
- }
+TString ExtendedSyntaxRemoved(TString text) {
+ static const RE2 regex(R"re( *{%[^\\]*?%} *\n?)re");
+ RE2::GlobalReplace(&text, regex, "");
+ return text;
+}
- TMarkdownPage ExtendedSyntaxRemoved(TMarkdownPage page) {
- page.Text = ExtendedSyntaxRemoved(page.Text);
- for (auto& [_, section] : page.SectionsByAnchor) {
- section.Body = ExtendedSyntaxRemoved(std::move(section.Body));
- }
- return page;
+TMarkdownPage ExtendedSyntaxRemoved(TMarkdownPage page) {
+ page.Text = ExtendedSyntaxRemoved(page.Text);
+ for (auto& [_, section] : page.SectionsByAnchor) {
+ section.Body = ExtendedSyntaxRemoved(std::move(section.Body));
}
+ return page;
+}
- TPages ParsePages(TResourcesByRelativePath resources) {
- TPages pages;
- for (auto& [path, resource] : resources) {
- TMarkdownPage page = ParseMarkdownPage(std::move(resource));
- pages.emplace(std::move(path), std::move(page));
- }
- return pages;
+TPages ParsePages(TResourcesByRelativePath resources) {
+ TPages pages;
+ for (auto& [path, resource] : resources) {
+ TMarkdownPage page = ParseMarkdownPage(std::move(resource));
+ pages.emplace(std::move(path), std::move(page));
}
+ return pages;
+}
- TPages Resolved(TPages pages, TStringBuf baseURL) {
- for (auto& [relativeURL, page] : pages) {
- page = Resolved(relativeURL, std::move(page), baseURL);
- }
- return pages;
+TPages Resolved(TPages pages, TStringBuf baseURL) {
+ for (auto& [relativeURL, page] : pages) {
+ page = Resolved(relativeURL, std::move(page), baseURL);
}
+ return pages;
+}
- TPages ExtendedSyntaxRemoved(TPages pages) {
- for (auto& [_, page] : pages) {
- page = ExtendedSyntaxRemoved(std::move(page));
- }
- return pages;
+TPages ExtendedSyntaxRemoved(TPages pages) {
+ for (auto& [_, page] : pages) {
+ page = ExtendedSyntaxRemoved(std::move(page));
}
+ return pages;
+}
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/page.h b/yql/essentials/utils/docs/page.h
index 39d569f72c8..e01939a9292 100644
--- a/yql/essentials/utils/docs/page.h
+++ b/yql/essentials/utils/docs/page.h
@@ -5,12 +5,12 @@
namespace NYql::NDocs {
- using TPages = THashMap<TString, TMarkdownPage>;
+using TPages = THashMap<TString, TMarkdownPage>;
- TPages ParsePages(TResourcesByRelativePath resources);
+TPages ParsePages(TResourcesByRelativePath resources);
- TPages Resolved(TPages pages, TStringBuf baseURL);
+TPages Resolved(TPages pages, TStringBuf baseURL);
- TPages ExtendedSyntaxRemoved(TPages pages);
+TPages ExtendedSyntaxRemoved(TPages pages);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/page_ut.cpp b/yql/essentials/utils/docs/page_ut.cpp
index ede92785140..a11d7784a5b 100644
--- a/yql/essentials/utils/docs/page_ut.cpp
+++ b/yql/essentials/utils/docs/page_ut.cpp
@@ -6,8 +6,8 @@ using namespace NYql::NDocs;
Y_UNIT_TEST_SUITE(PageTests) {
- Y_UNIT_TEST(ResolveURL) {
- TString markdown = R"(
+Y_UNIT_TEST(ResolveURL) {
+ TString markdown = R"(
# List of window functions in YQL
The syntax for calling window functions is detailed in a
@@ -35,26 +35,26 @@ If one of the compared arguments is 0.0, the function always returns false.
End.
)";
- TPages pages = {{"builtins/window", ParseMarkdownPage(markdown)}};
- pages = Resolved(std::move(pages), "https://ytsaurus.tech/docs/en/yql");
- pages = ExtendedSyntaxRemoved(std::move(pages));
-
- TVector<TString> changes = {
- "[separate article](https://ytsaurus.tech/docs/en/yql/builtins/window/../../syntax/window)",
- "[aggregate functions](https://ytsaurus.tech/docs/en/yql/builtins/window/../aggregation)",
- "[window frame](https://ytsaurus.tech/docs/en/yql/builtins/window/../../syntax/window#frame)",
- "[any()](https://clickhouse.tech/docs/en/sql-reference/aggregate-functions/reference/any/)",
- };
-
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(0));
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(1));
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(2));
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(3));
-
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, "the function always returns false");
- UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, "End.");
- UNIT_ASSERT(!pages["builtins/window"].Text.Contains("{% note alert %}"));
- UNIT_ASSERT(!pages["builtins/window"].Text.Contains("{% endnote %}"));
- }
+ TPages pages = {{"builtins/window", ParseMarkdownPage(markdown)}};
+ pages = Resolved(std::move(pages), "https://ytsaurus.tech/docs/en/yql");
+ pages = ExtendedSyntaxRemoved(std::move(pages));
+
+ TVector<TString> changes = {
+ "[separate article](https://ytsaurus.tech/docs/en/yql/builtins/window/../../syntax/window)",
+ "[aggregate functions](https://ytsaurus.tech/docs/en/yql/builtins/window/../aggregation)",
+ "[window frame](https://ytsaurus.tech/docs/en/yql/builtins/window/../../syntax/window#frame)",
+ "[any()](https://clickhouse.tech/docs/en/sql-reference/aggregate-functions/reference/any/)",
+ };
+
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(0));
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(1));
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(2));
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, changes.at(3));
+
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, "the function always returns false");
+ UNIT_ASSERT_STRING_CONTAINS(pages["builtins/window"].Text, "End.");
+ UNIT_ASSERT(!pages["builtins/window"].Text.Contains("{% note alert %}"));
+ UNIT_ASSERT(!pages["builtins/window"].Text.Contains("{% endnote %}"));
+}
} // Y_UNIT_TEST_SUITE(PageTests)
diff --git a/yql/essentials/utils/docs/resource.cpp b/yql/essentials/utils/docs/resource.cpp
index 8ca724c432e..f453fe8975c 100644
--- a/yql/essentials/utils/docs/resource.cpp
+++ b/yql/essentials/utils/docs/resource.cpp
@@ -6,38 +6,38 @@
namespace NYql::NDocs {
- bool IsMatching(const TResourceFilter& filter, TStringBuf key) {
- return key.Contains(filter.BaseDirectorySuffix) &&
- key.EndsWith(filter.CutSuffix);
- }
-
- TStringBuf RelativePath(const TResourceFilter& filter, TStringBuf key Y_LIFETIME_BOUND) {
- size_t pos = key.find(filter.BaseDirectorySuffix);
- YQL_ENSURE(pos != TString::npos);
- pos += filter.BaseDirectorySuffix.size();
-
- TStringBuf tail = TStringBuf(key).SubStr(pos);
- tail.remove_suffix(filter.CutSuffix.size());
- return tail;
- }
-
- TResourcesByRelativePath FindResources(const TResourceFilter& filter) {
- YQL_ENSURE(
- filter.BaseDirectorySuffix.EndsWith('/'),
- "BaseDirectory should end with '/', but got '" << filter.BaseDirectorySuffix << "'");
-
- TResourcesByRelativePath resources;
- for (TStringBuf key : NResource::ListAllKeys()) {
- if (!key.StartsWith("resfs/file/") || !IsMatching(filter, key)) {
- continue;
- }
+bool IsMatching(const TResourceFilter& filter, TStringBuf key) {
+ return key.Contains(filter.BaseDirectorySuffix) &&
+ key.EndsWith(filter.CutSuffix);
+}
+
+TStringBuf RelativePath(const TResourceFilter& filter, TStringBuf key Y_LIFETIME_BOUND) {
+ size_t pos = key.find(filter.BaseDirectorySuffix);
+ YQL_ENSURE(pos != TString::npos);
+ pos += filter.BaseDirectorySuffix.size();
+
+ TStringBuf tail = TStringBuf(key).SubStr(pos);
+ tail.remove_suffix(filter.CutSuffix.size());
+ return tail;
+}
+
+TResourcesByRelativePath FindResources(const TResourceFilter& filter) {
+ YQL_ENSURE(
+ filter.BaseDirectorySuffix.EndsWith('/'),
+ "BaseDirectory should end with '/', but got '" << filter.BaseDirectorySuffix << "'");
+
+ TResourcesByRelativePath resources;
+ for (TStringBuf key : NResource::ListAllKeys()) {
+ if (!key.StartsWith("resfs/file/") || !IsMatching(filter, key)) {
+ continue;
+ }
- TStringBuf path = RelativePath(filter, key);
- YQL_ENSURE(!resources.contains(path));
+ TStringBuf path = RelativePath(filter, key);
+ YQL_ENSURE(!resources.contains(path));
- resources[path] = NResource::Find(key);
- }
- return resources;
+ resources[path] = NResource::Find(key);
}
+ return resources;
+}
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/resource.h b/yql/essentials/utils/docs/resource.h
index 0221b5ed9fc..3a39fbc2d71 100644
--- a/yql/essentials/utils/docs/resource.h
+++ b/yql/essentials/utils/docs/resource.h
@@ -6,14 +6,14 @@
namespace NYql::NDocs {
- struct TResourceFilter {
- TString BaseDirectorySuffix;
- TString CutSuffix;
- };
+struct TResourceFilter {
+ TString BaseDirectorySuffix;
+ TString CutSuffix;
+};
- using TResourcesByRelativePath = THashMap<TString, TString>;
+using TResourcesByRelativePath = THashMap<TString, TString>;
- // Useful when YaTool ALL_RESOURCE_FILES macro is used.
- TResourcesByRelativePath FindResources(const TResourceFilter& filter);
+// Useful when YaTool ALL_RESOURCE_FILES macro is used.
+TResourcesByRelativePath FindResources(const TResourceFilter& filter);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/ut/ya.make b/yql/essentials/utils/docs/ut/ya.make
index 3afe8f60aa8..72c013d9e29 100644
--- a/yql/essentials/utils/docs/ut/ya.make
+++ b/yql/essentials/utils/docs/ut/ya.make
@@ -1,5 +1,7 @@
UNITTEST_FOR(yql/essentials/utils/docs)
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
markdown_ut.cpp
page_ut.cpp
diff --git a/yql/essentials/utils/docs/verification.cpp b/yql/essentials/utils/docs/verification.cpp
index 0eaedc2a3b4..13f84a16330 100644
--- a/yql/essentials/utils/docs/verification.cpp
+++ b/yql/essentials/utils/docs/verification.cpp
@@ -10,121 +10,121 @@
namespace NYql::NDocs {
- auto Fames = {
- EFame::BadLinked,
- EFame::Unknown,
- EFame::Mentioned,
- EFame::Documented,
- };
+auto Fames = {
+ EFame::BadLinked,
+ EFame::Unknown,
+ EFame::Mentioned,
+ EFame::Documented,
+};
- bool IsLikelyDocumentedAt(TString text, TString name) {
- SubstGlobal(text, "_", "");
+bool IsLikelyDocumentedAt(TString text, TString name) {
+ SubstGlobal(text, "_", "");
- TVector<TStringBuf> tokens;
- Split(name, ":.", tokens);
+ TVector<TStringBuf> tokens;
+ Split(name, ":.", tokens);
- for (TStringBuf token : tokens) {
- YQL_ENSURE(!token.Empty());
+ for (TStringBuf token : tokens) {
+ YQL_ENSURE(!token.Empty());
- TMaybe<TString> normalized = NormalizedName(TString(token));
- YQL_ENSURE(normalized, "Unable to normalize " << token);
+ TMaybe<TString> normalized = NormalizedName(TString(token));
+ YQL_ENSURE(normalized, "Unable to normalize " << token);
- if (TCaseInsensitiveAsciiString(text).Contains(*normalized)) {
- return true;
- }
+ if (TCaseInsensitiveAsciiString(text).Contains(*normalized)) {
+ return true;
}
- return false;
}
+ return false;
+}
- void Verify(const TLinks& links, const TPages& pages, TString name, TFameReport& report) {
- TMaybe<TLinkTarget> target = Lookup(links, name);
- if (!target) {
- report[EFame::Unknown][std::move(name)] = "Unknown";
- return;
- }
-
- const TMarkdownPage* page = pages.FindPtr(target->RelativePath);
- if (!page) {
- report[EFame::BadLinked][std::move(name)] =
- TStringBuilder()
- << "Page '" << target->RelativePath << "' not found";
- return;
- }
+void Verify(const TLinks& links, const TPages& pages, TString name, TFameReport& report) {
+ TMaybe<TLinkTarget> target = Lookup(links, name);
+ if (!target) {
+ report[EFame::Unknown][std::move(name)] = "Unknown";
+ return;
+ }
- if (!target->Anchor && !IsLikelyDocumentedAt(page->Text, name)) {
- report[EFame::BadLinked][std::move(name)] =
- TStringBuilder()
- << "Absent at '" << target->RelativePath << "'";
- return;
- }
+ const TMarkdownPage* page = pages.FindPtr(target->RelativePath);
+ if (!page) {
+ report[EFame::BadLinked][std::move(name)] =
+ TStringBuilder()
+ << "Page '" << target->RelativePath << "' not found";
+ return;
+ }
- if (!target->Anchor) {
- report[EFame::Mentioned][std::move(name)] =
- TStringBuilder()
- << "Mentioned at '" << target->RelativePath << "'";
- return;
- }
+ if (!target->Anchor && !IsLikelyDocumentedAt(page->Text, name)) {
+ report[EFame::BadLinked][std::move(name)] =
+ TStringBuilder()
+ << "Absent at '" << target->RelativePath << "'";
+ return;
+ }
- const TMarkdownSection* section = page->SectionsByAnchor.FindPtr(*target->Anchor);
- if (!section) {
- report[EFame::BadLinked][std::move(name)] =
- TStringBuilder()
- << "Section '" << *target->Anchor << "' not found "
- << "at '" << target->RelativePath << "'";
- return;
- }
+ if (!target->Anchor) {
+ report[EFame::Mentioned][std::move(name)] =
+ TStringBuilder()
+ << "Mentioned at '" << target->RelativePath << "'";
+ return;
+ }
- if (!IsLikelyDocumentedAt(section->Header.Content, name) &&
- !IsLikelyDocumentedAt(section->Body, name)) {
- report[EFame::BadLinked][std::move(name)] =
- TStringBuilder()
- << "Absent at section '" << target << "', "
- << "section header is '" << section->Header.Content << "', "
- << "section prefix is '" << TStringBuf(section->Body).SubString(0, 32) << "'";
- return;
- }
+ const TMarkdownSection* section = page->SectionsByAnchor.FindPtr(*target->Anchor);
+ if (!section) {
+ report[EFame::BadLinked][std::move(name)] =
+ TStringBuilder()
+ << "Section '" << *target->Anchor << "' not found "
+ << "at '" << target->RelativePath << "'";
+ return;
+ }
- report[EFame::Documented][std::move(name)] =
+ if (!IsLikelyDocumentedAt(section->Header.Content, name) &&
+ !IsLikelyDocumentedAt(section->Body, name)) {
+ report[EFame::BadLinked][std::move(name)] =
TStringBuilder()
- << "Documented at '" << target << "'";
+ << "Absent at section '" << target << "', "
+ << "section header is '" << section->Header.Content << "', "
+ << "section prefix is '" << TStringBuf(section->Body).SubString(0, 32) << "'";
+ return;
}
- void ExamineShortHands(TFameReport& report, const TMap<TString, TString>& shortHands) {
- for (const auto& [shorten, qualified] : shortHands) {
- report[EFame::BadLinked].erase(shorten);
- for (EFame fame : Fames) {
- auto it = report[fame].find(qualified);
- if (it != report[fame].end()) {
- report[fame][shorten] = it->second;
- }
+ report[EFame::Documented][std::move(name)] =
+ TStringBuilder()
+ << "Documented at '" << target << "'";
+}
+
+void ExamineShortHands(TFameReport& report, const TMap<TString, TString>& shortHands) {
+ for (const auto& [shorten, qualified] : shortHands) {
+ report[EFame::BadLinked].erase(shorten);
+ for (EFame fame : Fames) {
+ auto it = report[fame].find(qualified);
+ if (it != report[fame].end()) {
+ report[fame][shorten] = it->second;
}
}
}
+}
- TFameReport Verify(TVerificationInput input) {
- TFameReport report;
- for (TString name : input.Names) {
- Verify(input.Links, input.Pages, std::move(name), report);
- }
- ExamineShortHands(report, input.ShortHands);
- return report;
+TFameReport Verify(TVerificationInput input) {
+ TFameReport report;
+ for (TString name : input.Names) {
+ Verify(input.Links, input.Pages, std::move(name), report);
}
+ ExamineShortHands(report, input.ShortHands);
+ return report;
+}
- double Coverage(const TFameReport& report, const TVector<TString>& names) {
- if (!report.contains(EFame::Documented)) {
- return 0;
- }
+double Coverage(const TFameReport& report, const TVector<TString>& names) {
+ if (!report.contains(EFame::Documented)) {
+ return 0;
+ }
- const TStatusesByName& documented = report.at(EFame::Documented);
+ const TStatusesByName& documented = report.at(EFame::Documented);
- size_t covered = 0;
- for (const TString& name : names) {
- covered += documented.contains(name) ? 1 : 0;
- }
-
- return static_cast<double>(covered) / names.size();
+ size_t covered = 0;
+ for (const TString& name : names) {
+ covered += documented.contains(name) ? 1 : 0;
}
+ return static_cast<double>(covered) / names.size();
+}
+
} // namespace NYql::NDocs
template <>
diff --git a/yql/essentials/utils/docs/verification.h b/yql/essentials/utils/docs/verification.h
index 4eac54017f8..0f9a2aa8214 100644
--- a/yql/essentials/utils/docs/verification.h
+++ b/yql/essentials/utils/docs/verification.h
@@ -8,26 +8,26 @@
namespace NYql::NDocs {
- enum class EFame {
- BadLinked,
- Unknown,
- Mentioned,
- Documented,
- };
+enum class EFame {
+ BadLinked,
+ Unknown,
+ Mentioned,
+ Documented,
+};
- using TStatusesByName = TMap<TString, TString>;
+using TStatusesByName = TMap<TString, TString>;
- using TFameReport = THashMap<EFame, TStatusesByName>;
+using TFameReport = THashMap<EFame, TStatusesByName>;
- struct TVerificationInput {
- TLinks Links;
- TPages Pages;
- TSet<TString> Names;
- TMap<TString, TString> ShortHands;
- };
+struct TVerificationInput {
+ TLinks Links;
+ TPages Pages;
+ TSet<TString> Names;
+ TMap<TString, TString> ShortHands;
+};
- TFameReport Verify(TVerificationInput input);
+TFameReport Verify(TVerificationInput input);
- double Coverage(const TFameReport& report, const TVector<TString>& names);
+double Coverage(const TFameReport& report, const TVector<TString>& names);
} // namespace NYql::NDocs
diff --git a/yql/essentials/utils/docs/ya.make b/yql/essentials/utils/docs/ya.make
index 6f828c1434b..40cc3862c93 100644
--- a/yql/essentials/utils/docs/ya.make
+++ b/yql/essentials/utils/docs/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
link_page.cpp
link.cpp
diff --git a/yql/essentials/utils/exceptions.cpp b/yql/essentials/utils/exceptions.cpp
index 8a6d09fc9d1..0a813bf8c36 100644
--- a/yql/essentials/utils/exceptions.cpp
+++ b/yql/essentials/utils/exceptions.cpp
@@ -7,13 +7,15 @@ namespace NYql {
TCodeLineException::TCodeLineException(ui32 code)
: SourceLocation("", 0)
, Code(code)
-{}
+{
+}
TCodeLineException::TCodeLineException(const TSourceLocation& sl, const TCodeLineException& t)
: yexception(t)
, SourceLocation(sl)
, Code(t.Code)
-{}
+{
+}
const char* TCodeLineException::GetRawMessage() const {
return yexception::what();
@@ -25,7 +27,7 @@ const char* TCodeLineException::what() const noexcept {
Message = TStringBuilder{} << SourceLocation << TStringBuf(": ") << yexception::what();
}
return Message.c_str();
- } catch(...) {
+ } catch (...) {
return "Unexpected exception in TCodeLineException::what()";
}
}
@@ -34,4 +36,4 @@ TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t)
return TCodeLineException(sl, t);
}
-} // namespace NFq \ No newline at end of file
+} // namespace NYql
diff --git a/yql/essentials/utils/exceptions.h b/yql/essentials/utils/exceptions.h
index 8df5307da2d..1fd13e39f61 100644
--- a/yql/essentials/utils/exceptions.h
+++ b/yql/essentials/utils/exceptions.h
@@ -4,9 +4,8 @@
namespace NYql {
-// This exception can separate code line and file name from the error message
+// This exception can separate code line and file name from the error message
struct TCodeLineException: public yexception {
-
TSourceLocation SourceLocation;
mutable TString Message;
ui32 Code;
@@ -18,16 +17,15 @@ struct TCodeLineException: public yexception {
virtual const char* what() const noexcept override;
const char* GetRawMessage() const;
-
};
TCodeLineException operator+(const TSourceLocation& sl, TCodeLineException&& t);
-#define YQL_ENSURE_CODELINE(CONDITION, CODE, ...) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
+#define YQL_ENSURE_CODELINE(CONDITION, CODE, ...) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
ythrow TCodeLineException(CODE) << __VA_ARGS__; \
- } \
+ } \
} while (0)
-} // namespace NYql \ No newline at end of file
+} // namespace NYql
diff --git a/yql/essentials/utils/failure_injector/failure_injector.cpp b/yql/essentials/utils/failure_injector/failure_injector.cpp
index dfaff74503a..f875362d4af 100644
--- a/yql/essentials/utils/failure_injector/failure_injector.cpp
+++ b/yql/essentials/utils/failure_injector/failure_injector.cpp
@@ -30,7 +30,7 @@ THashMap<TString, TFailureInjector::TFailureSpec> TFailureInjector::GetCurrentSt
THashMap<TString, TFailureInjector::TFailureSpec> TFailureInjector::GetCurrentStateImpl() {
THashMap<TString, TFailureInjector::TFailureSpec> copy;
- with_lock(Lock_) {
+ with_lock (Lock_) {
copy = FailureSpecs_;
}
return copy;
@@ -40,7 +40,7 @@ void TFailureInjector::ReachImpl(std::string_view name, std::function<void()> ac
if (!Enabled_.load()) {
return;
}
- with_lock(Lock_) {
+ with_lock (Lock_) {
if (auto failureSpec = FailureSpecs_.FindPtr(name)) {
YQL_LOG(DEBUG) << "TFailureInjector::Reach: " << name << ", Skip=" << failureSpec->Skip << ", Fails=" << failureSpec->CountOfFails;
if (failureSpec->Skip > 0) {
@@ -55,10 +55,10 @@ void TFailureInjector::ReachImpl(std::string_view name, std::function<void()> ac
}
void TFailureInjector::SetImpl(std::string_view name, ui64 skip, ui64 countOfFails) {
- with_lock(Lock_) {
+ with_lock (Lock_) {
YQL_ENSURE(countOfFails > 0, "failure " << name << ", 'countOfFails' must be positive");
FailureSpecs_[TString{name}] = TFailureSpec{skip, countOfFails};
}
}
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/failure_injector/failure_injector.h b/yql/essentials/utils/failure_injector/failure_injector.h
index 227eb1518f1..a791d4f1e52 100644
--- a/yql/essentials/utils/failure_injector/failure_injector.h
+++ b/yql/essentials/utils/failure_injector/failure_injector.h
@@ -33,4 +33,4 @@ private:
TMutex Lock_;
};
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/failure_injector/failure_injector_ut.cpp b/yql/essentials/utils/failure_injector/failure_injector_ut.cpp
index 4d94b5cce7d..75c67e30048 100644
--- a/yql/essentials/utils/failure_injector/failure_injector_ut.cpp
+++ b/yql/essentials/utils/failure_injector/failure_injector_ut.cpp
@@ -26,62 +26,62 @@ void SetUpLogger() {
}
Y_UNIT_TEST_SUITE(TFailureInjectorTests) {
- Y_UNIT_TEST(BasicFailureTest) {
- SetUpLogger();
- std::atomic<bool> called;
- called.store(false);
- auto behavior = [&called] { OnReach(called); };
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(false, called.load());
- TFailureInjector::Activate();
- TFailureInjector::Set("misc_failure", 0, 1);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(true, called.load());
- }
+Y_UNIT_TEST(BasicFailureTest) {
+ SetUpLogger();
+ std::atomic<bool> called;
+ called.store(false);
+ auto behavior = [&called] { OnReach(called); };
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(false, called.load());
+ TFailureInjector::Activate();
+ TFailureInjector::Set("misc_failure", 0, 1);
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(true, called.load());
+}
- Y_UNIT_TEST(CheckSkipTest) {
- SetUpLogger();
- std::atomic<bool> called;
- called.store(false);
- auto behavior = [&called] { OnReach(called); };
- TFailureInjector::Activate();
- TFailureInjector::Set("misc_failure", 1, 1);
+Y_UNIT_TEST(CheckSkipTest) {
+ SetUpLogger();
+ std::atomic<bool> called;
+ called.store(false);
+ auto behavior = [&called] { OnReach(called); };
+ TFailureInjector::Activate();
+ TFailureInjector::Set("misc_failure", 1, 1);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(false, called.load());
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(true, called.load());
- }
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(false, called.load());
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(true, called.load());
+}
- Y_UNIT_TEST(CheckFailCountTest) {
- SetUpLogger();
- int called = 0;
- auto behavior = [&called] { ++called; };
- TFailureInjector::Activate();
- TFailureInjector::Set("misc_failure", 1, 2);
+Y_UNIT_TEST(CheckFailCountTest) {
+ SetUpLogger();
+ int called = 0;
+ auto behavior = [&called] { ++called; };
+ TFailureInjector::Activate();
+ TFailureInjector::Set("misc_failure", 1, 2);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(0, called);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(1, called);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(2, called);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(2, called);
- TFailureInjector::Reach("misc_failure", behavior);
- UNIT_ASSERT_EQUAL(2, called);
- }
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(0, called);
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(1, called);
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(2, called);
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(2, called);
+ TFailureInjector::Reach("misc_failure", behavior);
+ UNIT_ASSERT_EQUAL(2, called);
+}
- Y_UNIT_TEST(SlowDownTest) {
- SetUpLogger();
- TFailureInjector::Activate();
- TFailureInjector::Set("misc_failure", 0, 1);
+Y_UNIT_TEST(SlowDownTest) {
+ SetUpLogger();
+ TFailureInjector::Activate();
+ TFailureInjector::Set("misc_failure", 0, 1);
- auto start = system_clock::now();
- TFailureInjector::Reach("misc_failure", [] { ::Sleep(TDuration::Seconds(5)); });
- auto finish = system_clock::now();
- auto duration = duration_cast<std::chrono::seconds>(finish - start);
- YQL_LOG(DEBUG) << "Duration :" << duration.count();
- UNIT_ASSERT_GE(duration.count(), 5);
- }
+ auto start = system_clock::now();
+ TFailureInjector::Reach("misc_failure", [] { ::Sleep(TDuration::Seconds(5)); });
+ auto finish = system_clock::now();
+ auto duration = duration_cast<std::chrono::seconds>(finish - start);
+ YQL_LOG(DEBUG) << "Duration :" << duration.count();
+ UNIT_ASSERT_GE(duration.count(), 5);
}
+} // Y_UNIT_TEST_SUITE(TFailureInjectorTests)
diff --git a/yql/essentials/utils/failure_injector/ut/ya.make b/yql/essentials/utils/failure_injector/ut/ya.make
index 579a4662872..2b9138f378c 100644
--- a/yql/essentials/utils/failure_injector/ut/ya.make
+++ b/yql/essentials/utils/failure_injector/ut/ya.make
@@ -1,6 +1,8 @@
IF (OS_LINUX OR OS_DARWIN)
UNITTEST_FOR(yql/essentials/utils/failure_injector)
+ ENABLE(YQL_STYLE_CPP)
+
SIZE(SMALL)
SRCS(
diff --git a/yql/essentials/utils/failure_injector/ya.make b/yql/essentials/utils/failure_injector/ya.make
index e10dfdaecba..a7f969d4b67 100644
--- a/yql/essentials/utils/failure_injector/ya.make
+++ b/yql/essentials/utils/failure_injector/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
failure_injector.cpp
)
diff --git a/yql/essentials/utils/fetch/fetch.cpp b/yql/essentials/utils/fetch/fetch.cpp
index 4b0777e9feb..d7a76e3e6ed 100644
--- a/yql/essentials/utils/fetch/fetch.cpp
+++ b/yql/essentials/utils/fetch/fetch.cpp
@@ -125,33 +125,32 @@ inline bool IsRedirectCode(unsigned code) {
return false;
}
-} // unnamed
+} // namespace
ERetryErrorClass DefaultClassifyHttpCode(unsigned code) {
switch (code) {
- case HTTP_REQUEST_TIME_OUT: //408
- case HTTP_AUTHENTICATION_TIMEOUT: //419
+ case HTTP_REQUEST_TIME_OUT: // 408
+ case HTTP_AUTHENTICATION_TIMEOUT: // 419
return ERetryErrorClass::ShortRetry;
- case HTTP_TOO_MANY_REQUESTS: //429
- case HTTP_SERVICE_UNAVAILABLE: //503
+ case HTTP_TOO_MANY_REQUESTS: // 429
+ case HTTP_SERVICE_UNAVAILABLE: // 503
return ERetryErrorClass::LongRetry;
default:
return IsServerError(code)
- ? ERetryErrorClass::ShortRetry //5xx
- : ERetryErrorClass::NoRetry;
+ ? ERetryErrorClass::ShortRetry // 5xx
+ : ERetryErrorClass::NoRetry;
}
}
IRetryPolicy<unsigned>::TPtr GetDefaultPolicy() {
static const auto policy = IRetryPolicy<unsigned>::GetExponentialBackoffPolicy(
- /*retryClassFunction=*/DefaultClassifyHttpCode,
- /*minDelay=*/TDuration::Seconds(1),
- /*minLongRetryDelay:*/TDuration::Seconds(5),
- /*maxDelay=*/TDuration::Minutes(1),
- /*maxRetries=*/3,
- /*maxTime=*/TDuration::Minutes(3),
- /*scaleFactor=*/2
- );
+ /*retryClassFunction=*/DefaultClassifyHttpCode,
+ /*minDelay=*/TDuration::Seconds(1),
+ /*minLongRetryDelay:*/ TDuration::Seconds(5),
+ /*maxDelay=*/TDuration::Minutes(1),
+ /*maxRetries=*/3,
+ /*maxTime=*/TDuration::Minutes(3),
+ /*scaleFactor=*/2);
return policy;
}
@@ -215,4 +214,4 @@ TFetchResultPtr Fetch(const THttpURL& url, const THttpHeaders& additionalHeaders
ythrow yexception() << "Failed to fetch url '" << currentUrl.PrintS() << "': too many redirects";
}
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/fetch/fetch.h b/yql/essentials/utils/fetch/fetch.h
index 3909de07215..c644a05a9f3 100644
--- a/yql/essentials/utils/fetch/fetch.h
+++ b/yql/essentials/utils/fetch/fetch.h
@@ -24,4 +24,4 @@ IRetryPolicy<unsigned>::TPtr GetDefaultPolicy();
ERetryErrorClass DefaultClassifyHttpCode(unsigned code);
TFetchResultPtr Fetch(const THttpURL& url, const THttpHeaders& additionalHeaders = {}, const TDuration& timeout = TDuration::Max(), size_t redirects = 10, const IRetryPolicy<unsigned>::TPtr& policy = nullptr);
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/fetch/ya.make b/yql/essentials/utils/fetch/ya.make
index 71b7d54d501..337496a541d 100644
--- a/yql/essentials/utils/fetch/ya.make
+++ b/yql/essentials/utils/fetch/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
fetch.cpp
)
diff --git a/yql/essentials/utils/fp_bits.h b/yql/essentials/utils/fp_bits.h
index ffce6e161b4..9d2a812544d 100644
--- a/yql/essentials/utils/fp_bits.h
+++ b/yql/essentials/utils/fp_bits.h
@@ -98,13 +98,13 @@ struct TCanonizeFpBitsImpl<T, false> {
using TNumTraits = std::numeric_limits<T>;
const T value = *(T*)buffer;
switch (std::fpclassify(value)) {
- case FP_NAN:
- static_assert(TNumTraits::has_quiet_NaN, "no QNAN");
- *(T*)buffer = TNumTraits::quiet_NaN();
- break;
- case FP_ZERO:
- *(T*)buffer = T(0);
- break;
+ case FP_NAN:
+ static_assert(TNumTraits::has_quiet_NaN, "no QNAN");
+ *(T*)buffer = TNumTraits::quiet_NaN();
+ break;
+ case FP_ZERO:
+ *(T*)buffer = T(0);
+ break;
}
}
};
@@ -119,4 +119,4 @@ void CanonizeFpBits(void* buffer) {
return TCanonizeFpBitsImpl<T, TFpTraits<T>::Supported>::Do(buffer);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/fp_bits_ut.cpp b/yql/essentials/utils/fp_bits_ut.cpp
index d6d94b56f46..b8572a265ec 100644
--- a/yql/essentials/utils/fp_bits_ut.cpp
+++ b/yql/essentials/utils/fp_bits_ut.cpp
@@ -83,23 +83,23 @@ void CanonizeFpBitsTest() {
UNIT_ASSERT(std::memcmp((const void*)&newValues[v], (const void*)&values[originalV], std::min(size_t(10), sizeof(T))) == 0);
}
}
-}
+} // namespace
Y_UNIT_TEST_SUITE(TFpBits) {
- Y_UNIT_TEST(CanonizeFloat) {
- CanonizeFpBitsTest<float>();
- }
+Y_UNIT_TEST(CanonizeFloat) {
+ CanonizeFpBitsTest<float>();
+}
- Y_UNIT_TEST(CanonizeDouble) {
- CanonizeFpBitsTest<double>();
- }
+Y_UNIT_TEST(CanonizeDouble) {
+ CanonizeFpBitsTest<double>();
+}
- Y_UNIT_TEST(CanonizeLongDouble) {
- if (NValgrind::ValgrindIsOn()) {
- return; // TODO KIKIMR-3431
- }
- CanonizeFpBitsTest<long double>();
+Y_UNIT_TEST(CanonizeLongDouble) {
+ if (NValgrind::ValgrindIsOn()) {
+ return; // TODO KIKIMR-3431
}
+ CanonizeFpBitsTest<long double>();
}
+} // Y_UNIT_TEST_SUITE(TFpBits)
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/future_action.h b/yql/essentials/utils/future_action.h
index d4a8dd69aad..0da98307a38 100644
--- a/yql/essentials/utils/future_action.h
+++ b/yql/essentials/utils/future_action.h
@@ -43,12 +43,12 @@ NThreading::TFuture<std::function<V()>> AddConstantActionToFuture(NThreading::TF
/*
Transform action result by applying mapper
*/
-template <typename R, typename TMapper, typename ...Args>
+template <typename R, typename TMapper, typename... Args>
auto MapFutureAction(NThreading::TFuture<std::function<R(Args&&...)>> f, const TMapper& mapper) {
using V = decltype(mapper(std::declval<R>()));
return f.Apply([mapper](NThreading::TFuture<std::function<R(Args&&...)>> f) {
- std::function<V(Args&&...)> r = [f, mapper](Args&& ...args) {
+ std::function<V(Args && ...)> r = [f, mapper](Args&&... args) {
return mapper(f.GetValue()(std::forward<Args>(args)...));
};
@@ -56,4 +56,4 @@ auto MapFutureAction(NThreading::TFuture<std::function<R(Args&&...)>> f, const T
});
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/hash.cpp b/yql/essentials/utils/hash.cpp
index b0bc284d4f8..803dcb3b4b8 100644
--- a/yql/essentials/utils/hash.cpp
+++ b/yql/essentials/utils/hash.cpp
@@ -11,11 +11,12 @@ size_t VaryingHash(size_t src) {
TPid()
: Value(GetEnv("YQL_MUTATE_HASHCODE") ? IntHash(GetPID()) : 0)
- {}
+ {
+ }
};
return Singleton<TPid>()->Value ^ src;
}
#endif
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/hash.h b/yql/essentials/utils/hash.h
index 45cd95b777a..ac6f1324a11 100644
--- a/yql/essentials/utils/hash.h
+++ b/yql/essentials/utils/hash.h
@@ -23,7 +23,8 @@ struct TVaryingHash {
TVaryingHash(const TVaryingHash&) = default;
TVaryingHash(const THasher& underlying)
: Underlying(underlying)
- {}
+ {
+ }
TVaryingHash& operator=(const TVaryingHash& other) = default;
@@ -33,55 +34,55 @@ struct TVaryingHash {
};
template <class TKey,
- class TValue,
- class THasher = std::hash<TKey>,
- class TEqual = std::equal_to<TKey>,
- class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
+ class TValue,
+ class THasher = std::hash<TKey>,
+ class TEqual = std::equal_to<TKey>,
+ class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
using TVaryingUnorderedMap = std::unordered_map<TKey, TValue, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class TValue,
- class THasher = std::hash<TKey>,
- class TEqual = std::equal_to<TKey>,
- class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
+ class TValue,
+ class THasher = std::hash<TKey>,
+ class TEqual = std::equal_to<TKey>,
+ class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
using TVaryingUnorderedMultiMap = std::unordered_multimap<TKey, TValue, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class THasher = std::hash<TKey>,
- class TEqual = std::equal_to<TKey>,
- class TAlloc = std::allocator<TKey>>
+ class THasher = std::hash<TKey>,
+ class TEqual = std::equal_to<TKey>,
+ class TAlloc = std::allocator<TKey>>
using TVaryingUnorderedSet = std::unordered_set<TKey, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class THasher = std::hash<TKey>,
- class TEqual = std::equal_to<TKey>,
- class TAlloc = std::allocator<TKey>>
+ class THasher = std::hash<TKey>,
+ class TEqual = std::equal_to<TKey>,
+ class TAlloc = std::allocator<TKey>>
using TVaryingUnorderedMultiSet = std::unordered_multiset<TKey, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class TValue,
- class THasher = THash<TKey>,
- class TEqual = TEqualTo<TKey>,
- class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
+ class TValue,
+ class THasher = THash<TKey>,
+ class TEqual = TEqualTo<TKey>,
+ class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
using TVaryingHashMap = THashMap<TKey, TValue, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class TValue,
- class THasher = THash<TKey>,
- class TEqual = TEqualTo<TKey>,
- class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
+ class TValue,
+ class THasher = THash<TKey>,
+ class TEqual = TEqualTo<TKey>,
+ class TAlloc = std::allocator<std::pair<const TKey, TValue>>>
using TVaryingHashMultiMap = THashMultiMap<TKey, TValue, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class THasher = THash<TKey>,
- class TEqual = TEqualTo<TKey>,
- class TAlloc = std::allocator<TKey>>
+ class THasher = THash<TKey>,
+ class TEqual = TEqualTo<TKey>,
+ class TAlloc = std::allocator<TKey>>
using TVaryingHashSet = THashSet<TKey, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
template <class TKey,
- class THasher = THash<TKey>,
- class TEqual = TEqualTo<TKey>,
- class TAlloc = std::allocator<TKey>>
+ class THasher = THash<TKey>,
+ class TEqual = TEqualTo<TKey>,
+ class TAlloc = std::allocator<TKey>>
using TVaryingHashMultiSet = THashMultiSet<TKey, TVaryingHash<TKey, THasher>, TEqual, TAlloc>;
} // namespace NYql
diff --git a/yql/essentials/utils/limiting_allocator.cpp b/yql/essentials/utils/limiting_allocator.cpp
index 0ff84f90378..e25ec99a427 100644
--- a/yql/essentials/utils/limiting_allocator.cpp
+++ b/yql/essentials/utils/limiting_allocator.cpp
@@ -4,9 +4,12 @@
#include <util/generic/yexception.h>
namespace {
-class TLimitingAllocator : public IAllocator {
+class TLimitingAllocator: public IAllocator {
public:
- TLimitingAllocator(size_t limit, IAllocator* allocator) : Alloc_(allocator), Limit_(limit) {};
+ TLimitingAllocator(size_t limit, IAllocator* allocator)
+ : Alloc_(allocator)
+ , Limit_(limit)
+ {};
TBlock Allocate(size_t len) override final {
if (Allocated_ + len > Limit_) {
throw std::runtime_error("Out of memory");
@@ -26,10 +29,10 @@ private:
size_t Allocated_ = 0;
const size_t Limit_;
};
-}
+} // namespace
namespace NYql {
std::unique_ptr<IAllocator> MakeLimitingAllocator(size_t limit, IAllocator* underlying) {
return std::make_unique<TLimitingAllocator>(limit, underlying);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/limiting_allocator.h b/yql/essentials/utils/limiting_allocator.h
index 7d94aa7f2ad..f90a09e7b7b 100644
--- a/yql/essentials/utils/limiting_allocator.h
+++ b/yql/essentials/utils/limiting_allocator.h
@@ -5,4 +5,4 @@
namespace NYql {
std::unique_ptr<IAllocator> MakeLimitingAllocator(size_t limit, IAllocator* underlying);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/log/context.cpp b/yql/essentials/utils/log/context.cpp
index 6f4cb0c580e..fb7db9a5548 100644
--- a/yql/essentials/utils/log/context.cpp
+++ b/yql/essentials/utils/log/context.cpp
@@ -3,7 +3,6 @@
#include <util/thread/singleton.h>
-
namespace NYql {
namespace NLog {
namespace {
@@ -12,28 +11,28 @@ struct TThrowedLogContext {
TString LocationWithLogContext; // separated with ': '
};
-} // namspace
+} // namespace
TStringBuf ToStringBuf(EContextKey key) {
switch (key) {
- case EContextKey::DateTime:
- return "datetime";
- case EContextKey::Level:
- return "level";
- case EContextKey::ProcessName:
- return "procname";
- case EContextKey::ProcessID:
- return "pid";
- case EContextKey::ThreadID:
- return "tid";
- case EContextKey::Component:
- return "component";
- case EContextKey::FileName:
- return "filename";
- case EContextKey::Line:
- return "line";
- case EContextKey::Path:
- return "path";
+ case EContextKey::DateTime:
+ return "datetime";
+ case EContextKey::Level:
+ return "level";
+ case EContextKey::ProcessName:
+ return "procname";
+ case EContextKey::ProcessID:
+ return "pid";
+ case EContextKey::ThreadID:
+ return "tid";
+ case EContextKey::Component:
+ return "component";
+ case EContextKey::FileName:
+ return "filename";
+ case EContextKey::Line:
+ return "line";
+ case EContextKey::Path:
+ return "path";
}
}
@@ -50,7 +49,7 @@ void OutputLogCtx(IOutputStream* out, bool withBraces, bool skipSessionId) {
bool isFirst = true;
while (ctxItem != ctxList) {
- for (const TString& name: *ctxItem) {
+ for (const TString& name : *ctxItem) {
if (!skipSessionId && !name.empty()) {
if (!isFirst) {
(*out) << '/';
@@ -92,7 +91,6 @@ TString ThrowedLogContextPath() {
return std::move(tlc->LocationWithLogContext);
}
-
TAutoPtr<TLogElement> TContextPreprocessor::Preprocess(TAutoPtr<TLogElement> element)
{
TStringStream out;
diff --git a/yql/essentials/utils/log/context.h b/yql/essentials/utils/log/context.h
index f2b423cf494..b8bbb63e9e1 100644
--- a/yql/essentials/utils/log/context.h
+++ b/yql/essentials/utils/log/context.h
@@ -9,32 +9,34 @@
// continues existing contexts chain
-#define YQL_LOG_CTX_SCOPE(...) \
+#define YQL_LOG_CTX_SCOPE(...) \
auto Y_CAT(c, __LINE__) = ::NYql::NLog::MakeCtx(__VA_ARGS__); \
Y_UNUSED(Y_CAT(c, __LINE__))
-#define YQL_LOG_CTX_BLOCK(...) \
+#define YQL_LOG_CTX_BLOCK(...) \
if (auto Y_GENERATE_UNIQUE_ID(c) = ::NYql::NLog::MakeCtx(__VA_ARGS__)) { \
- goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
- } else Y_CAT(YQL_LOG_CTX_LABEL, __LINE__):
-
+ goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
+ } else \
+ Y_CAT(YQL_LOG_CTX_LABEL, __LINE__) \
+ :
// starts new contexts chain, after leaving current scope restores
// previous contexts chain
-#define YQL_LOG_CTX_ROOT_SESSION_SCOPE(sessionId, ...) \
+#define YQL_LOG_CTX_ROOT_SESSION_SCOPE(sessionId, ...) \
auto Y_CAT(c, __LINE__) = ::NYql::NLog::MakeRootCtx(sessionId, ##__VA_ARGS__); \
Y_UNUSED(Y_CAT(c, __LINE__))
-#define YQL_LOG_CTX_ROOT_SCOPE(...) \
+#define YQL_LOG_CTX_ROOT_SCOPE(...) \
auto Y_CAT(c, __LINE__) = ::NYql::NLog::MakeRootCtx("", __VA_ARGS__); \
Y_UNUSED(Y_CAT(c, __LINE__))
-#define YQL_LOG_CTX_ROOT_BLOCK(...) \
+#define YQL_LOG_CTX_ROOT_BLOCK(...) \
if (auto Y_GENERATE_UNIQUE_ID(c) = ::NYql::NLog::MakeRootCtx(__VA_ARGS__)) { \
- goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
- } else Y_CAT(YQL_LOG_CTX_LABEL, __LINE__):
-
+ goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
+ } else \
+ Y_CAT(YQL_LOG_CTX_LABEL, __LINE__) \
+ :
// adds current contexts path to exception message before throwing it
@@ -93,7 +95,9 @@ public:
}
void Unlink() {
- if (!HasNext()) return;
+ if (!HasNext()) {
+ return;
+ }
Prev->Next = Next;
Next->Prev = Prev;
@@ -112,11 +116,12 @@ TLogContextListItem* GetLogContextList();
/**
* @brief Context element with stored SessionId.
-*/
-class TLogContextSessionItem : public TLogContextListItem {
+ */
+class TLogContextSessionItem: public TLogContextListItem {
public:
TLogContextSessionItem(size_t size, bool hasSessionId_)
- : TLogContextListItem(size, sizeof(*this)) {
+ : TLogContextListItem(size, sizeof(*this))
+ {
HasSessionId_ = hasSessionId_;
}
@@ -128,7 +133,7 @@ private:
bool HasSessionId_;
};
-} // namspace NImpl
+} // namespace NImpl
enum class EContextKey {
DateTime = 0,
@@ -153,7 +158,7 @@ public:
template <typename... TArgs>
TLogContext(TArgs... args)
: TLogContextListItem(Size)
- , Names_{{ TString{std::forward<TArgs>(args)}... }}
+ , Names_{{TString{std::forward<TArgs>(args)}...}}
{
LinkBefore(NImpl::GetLogContextList());
}
@@ -180,7 +185,7 @@ public:
template <typename... TArgs>
TRootLogContext(const TString& sessionId, TArgs... args)
: TLogContextSessionItem(Size, !sessionId.empty())
- , Names_{{ sessionId, TString{std::forward<TArgs>(args)}... }}
+ , Names_{{sessionId, TString{std::forward<TArgs>(args)}...}}
{
NImpl::TLogContextListItem* ctxList = NImpl::GetLogContextList();
PrevLogContextHead_.Prev = ctxList->Prev;
diff --git a/yql/essentials/utils/log/format.cpp b/yql/essentials/utils/log/format.cpp
index 6292235d52d..6cd57fe3fda 100644
--- a/yql/essentials/utils/log/format.cpp
+++ b/yql/essentials/utils/log/format.cpp
@@ -15,160 +15,160 @@
namespace NYql::NLog {
- namespace {
+namespace {
- constexpr size_t MaxRequiredContextKey = static_cast<size_t>(EContextKey::Line);
+constexpr size_t MaxRequiredContextKey = static_cast<size_t>(EContextKey::Line);
- auto RequiredContextAccessor(const TLogRecord& rec) {
- return [&](EContextKey key) -> TStringBuf {
- return rec.MetaFlags.at(static_cast<size_t>(key)).second;
- };
- }
-
- auto OptionalContextAccessor(const TLogRecord& rec) {
- return [&](TStringBuf key) -> TMaybe<TStringBuf> {
- const auto isContextKeyPath = [&](const auto& pair) {
- return pair.first == key;
- };
+auto RequiredContextAccessor(const TLogRecord& rec) {
+ return [&](EContextKey key) -> TStringBuf {
+ return rec.MetaFlags.at(static_cast<size_t>(key)).second;
+ };
+}
- const auto* path = FindIfPtr(
- rec.MetaFlags.begin() + MaxRequiredContextKey + 1,
- rec.MetaFlags.end(),
- isContextKeyPath);
+auto OptionalContextAccessor(const TLogRecord& rec) {
+ return [&](TStringBuf key) -> TMaybe<TStringBuf> {
+ const auto isContextKeyPath = [&](const auto& pair) {
+ return pair.first == key;
+ };
- if (!path) {
- return Nothing();
- }
+ const auto* path = FindIfPtr(
+ rec.MetaFlags.begin() + MaxRequiredContextKey + 1,
+ rec.MetaFlags.end(),
+ isContextKeyPath);
- return path->second;
- };
+ if (!path) {
+ return Nothing();
}
- void PrintBody(TStringBuilder& out, const TLogRecord& rec, size_t flagBegin) {
- out << TStringBuf(rec.Data, rec.Len);
+ return path->second;
+ };
+}
- if (flagBegin < rec.MetaFlags.size()) {
- out << ". Extra context: ";
- }
+void PrintBody(TStringBuilder& out, const TLogRecord& rec, size_t flagBegin) {
+ out << TStringBuf(rec.Data, rec.Len);
- for (size_t i = flagBegin; i < rec.MetaFlags.size(); ++i) {
- const auto& [key, value] = rec.MetaFlags[i];
- out << key << " = " << value;
- if (i + 1 != rec.MetaFlags.size()) {
- out << ", ";
- }
- }
- }
+ if (flagBegin < rec.MetaFlags.size()) {
+ out << ". Extra context: ";
+ }
- TString FallbackFormat(const TLogRecord& rec) {
- TStringBuilder out;
- PrintBody(out, rec, /*flagBegin=*/0);
- return out;
+ for (size_t i = flagBegin; i < rec.MetaFlags.size(); ++i) {
+ const auto& [key, value] = rec.MetaFlags[i];
+ out << key << " = " << value;
+ if (i + 1 != rec.MetaFlags.size()) {
+ out << ", ";
}
+ }
+}
+
+TString FallbackFormat(const TLogRecord& rec) {
+ TStringBuilder out;
+ PrintBody(out, rec, /*flagBegin=*/0);
+ return out;
+}
+
+class TFormattingLogBackend final: public TForwardingLogBackend {
+public:
+ explicit TFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child)
+ : TForwardingLogBackend(std::move(child))
+ , Formatter_(std::move(formatter))
+ , IsStrict_(isStrict)
+ {
+ }
- class TFormattingLogBackend final: public TForwardingLogBackend {
- public:
- explicit TFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child)
- : TForwardingLogBackend(std::move(child))
- , Formatter_(std::move(formatter))
- , IsStrict_(isStrict)
- {
- }
-
- void WriteData(const TLogRecord& rec) final {
- if (rec.MetaFlags.empty()) {
- // NB. For signal handler.
- return TForwardingLogBackend::WriteData(rec);
- }
-
- TString message;
- if (IsSupported(rec.MetaFlags)) {
- message = Formatter_(rec);
- } else if (IsStrict_) {
- TStringBuilder message;
- message << "LogRecord is not supported: ";
- PrintBody(message, rec, /* flagBegin = */ 0);
- ythrow yexception() << std::move(message);
- } else {
- message = FallbackFormat(rec);
- }
- message.append('\n');
-
- const TLogRecord formatted(rec.Priority, message.data(), message.size());
- return TForwardingLogBackend::WriteData(formatted);
- }
+ void WriteData(const TLogRecord& rec) final {
+ if (rec.MetaFlags.empty()) {
+ // NB. For signal handler.
+ return TForwardingLogBackend::WriteData(rec);
+ }
- protected:
- static bool IsSupported(const TLogRecord::TMetaFlags& flags) {
- const auto isSupported = [&](size_t i) -> bool {
- const EContextKey key = static_cast<EContextKey>(i);
+ TString message;
+ if (IsSupported(rec.MetaFlags)) {
+ message = Formatter_(rec);
+ } else if (IsStrict_) {
+ TStringBuilder message;
+ message << "LogRecord is not supported: ";
+ PrintBody(message, rec, /* flagBegin = */ 0);
+ ythrow yexception() << std::move(message);
+ } else {
+ message = FallbackFormat(rec);
+ }
+ message.append('\n');
- const TStringBuf expected = ToStringBuf(key);
- if (flags.size() <= i) {
- return false;
- }
+ const TLogRecord formatted(rec.Priority, message.data(), message.size());
+ return TForwardingLogBackend::WriteData(formatted);
+ }
- const TStringBuf actual = flags[i].first;
- if (actual != expected) {
- return false;
- }
+protected:
+ static bool IsSupported(const TLogRecord::TMetaFlags& flags) {
+ const auto isSupported = [&](size_t i) -> bool {
+ const EContextKey key = static_cast<EContextKey>(i);
- return true;
- };
+ const TStringBuf expected = ToStringBuf(key);
+ if (flags.size() <= i) {
+ return false;
+ }
- return AllOf(std::views::iota(Min<size_t>(), MaxRequiredContextKey), isSupported);
+ const TStringBuf actual = flags[i].first;
+ if (actual != expected) {
+ return false;
}
- private:
- TFormatter Formatter_;
- bool IsStrict_;
+ return true;
};
- } // namespace
-
- TString LegacyFormat(const TLogRecord& rec) {
- const auto get = RequiredContextAccessor(rec);
- const auto opt = OptionalContextAccessor(rec);
-
- TStringBuilder out;
- out << get(EContextKey::DateTime) << ' '
- << get(EContextKey::Level) << ' '
- << get(EContextKey::ProcessName)
- << "(pid=" << get(EContextKey::ProcessID)
- << ", tid=" << get(EContextKey::ThreadID)
- << ") [" << get(EContextKey::Component) << "] "
- << get(EContextKey::FileName)
- << ':' << get(EContextKey::Line) << ": ";
-
- size_t unknownContextBegin = MaxRequiredContextKey + 1;
- if (auto path = opt(ToStringBuf(EContextKey::Path))) {
- out << "{" << *path << "} ";
- unknownContextBegin += 1;
- }
-
- PrintBody(out, rec, unknownContextBegin);
- return out;
+ return AllOf(std::views::iota(Min<size_t>(), MaxRequiredContextKey), isSupported);
}
- TString JsonFormat(const TLogRecord& rec) {
- TStringStream out;
- NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML, &out);
- buf.BeginObject();
- buf.WriteKey("message");
- buf.WriteString(TStringBuf(rec.Data, rec.Len));
- buf.WriteKey("@fields");
- buf.BeginObject();
- for (const auto& [key, value] : rec.MetaFlags) {
- buf.WriteKey(key);
- buf.WriteString(value);
- }
- buf.EndObject();
- buf.EndObject();
- return std::move(out.Str());
+private:
+ TFormatter Formatter_;
+ bool IsStrict_;
+};
+
+} // namespace
+
+TString LegacyFormat(const TLogRecord& rec) {
+ const auto get = RequiredContextAccessor(rec);
+ const auto opt = OptionalContextAccessor(rec);
+
+ TStringBuilder out;
+ out << get(EContextKey::DateTime) << ' '
+ << get(EContextKey::Level) << ' '
+ << get(EContextKey::ProcessName)
+ << "(pid=" << get(EContextKey::ProcessID)
+ << ", tid=" << get(EContextKey::ThreadID)
+ << ") [" << get(EContextKey::Component) << "] "
+ << get(EContextKey::FileName)
+ << ':' << get(EContextKey::Line) << ": ";
+
+ size_t unknownContextBegin = MaxRequiredContextKey + 1;
+ if (auto path = opt(ToStringBuf(EContextKey::Path))) {
+ out << "{" << *path << "} ";
+ unknownContextBegin += 1;
}
- TAutoPtr<TLogBackend> MakeFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child) {
- return new TFormattingLogBackend(std::move(formatter), isStrict, std::move(child));
+ PrintBody(out, rec, unknownContextBegin);
+ return out;
+}
+
+TString JsonFormat(const TLogRecord& rec) {
+ TStringStream out;
+ NJsonWriter::TBuf buf(NJsonWriter::HEM_DONT_ESCAPE_HTML, &out);
+ buf.BeginObject();
+ buf.WriteKey("message");
+ buf.WriteString(TStringBuf(rec.Data, rec.Len));
+ buf.WriteKey("@fields");
+ buf.BeginObject();
+ for (const auto& [key, value] : rec.MetaFlags) {
+ buf.WriteKey(key);
+ buf.WriteString(value);
}
+ buf.EndObject();
+ buf.EndObject();
+ return std::move(out.Str());
+}
+
+TAutoPtr<TLogBackend> MakeFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child) {
+ return new TFormattingLogBackend(std::move(formatter), isStrict, std::move(child));
+}
} // namespace NYql::NLog
diff --git a/yql/essentials/utils/log/format.h b/yql/essentials/utils/log/format.h
index c0ece9412ba..3f4b9b01c0e 100644
--- a/yql/essentials/utils/log/format.h
+++ b/yql/essentials/utils/log/format.h
@@ -6,12 +6,12 @@
namespace NYql::NLog {
- using TFormatter = std::function<TString(const TLogRecord&)>;
+using TFormatter = std::function<TString(const TLogRecord&)>;
- TString LegacyFormat(const TLogRecord& rec);
+TString LegacyFormat(const TLogRecord& rec);
- TString JsonFormat(const TLogRecord& rec);
+TString JsonFormat(const TLogRecord& rec);
- TAutoPtr<TLogBackend> MakeFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child);
+TAutoPtr<TLogBackend> MakeFormattingLogBackend(TFormatter formatter, bool isStrict, TAutoPtr<TLogBackend> child);
} // namespace NYql::NLog
diff --git a/yql/essentials/utils/log/fwd_backend.cpp b/yql/essentials/utils/log/fwd_backend.cpp
index 091b07c78f1..be4ce454e54 100644
--- a/yql/essentials/utils/log/fwd_backend.cpp
+++ b/yql/essentials/utils/log/fwd_backend.cpp
@@ -2,37 +2,37 @@
namespace NYql::NLog {
- TForwardingLogBackend::TForwardingLogBackend(TAutoPtr<TLogBackend> child)
- : Child_(std::move(child))
- {
- }
-
- void TForwardingLogBackend::WriteData(const TLogRecord& rec) {
- return Child_->WriteData(rec);
- }
-
- void TForwardingLogBackend::ReopenLog() {
- return Child_->ReopenLog();
- }
-
- void TForwardingLogBackend::ReopenLogNoFlush() {
- return Child_->ReopenLogNoFlush();
- }
-
- ELogPriority TForwardingLogBackend::FiltrationLevel() const {
- return Child_->FiltrationLevel();
- }
-
- size_t TForwardingLogBackend::QueueSize() const {
- return Child_->QueueSize();
- }
-
- void TForwardingLogBackend::SetChild(TAutoPtr<TLogBackend> child) {
- Child_ = std::move(child);
- }
-
- TAutoPtr<TLogBackend> TForwardingLogBackend::GetChild() const {
- return Child_;
- }
+TForwardingLogBackend::TForwardingLogBackend(TAutoPtr<TLogBackend> child)
+ : Child_(std::move(child))
+{
+}
+
+void TForwardingLogBackend::WriteData(const TLogRecord& rec) {
+ return Child_->WriteData(rec);
+}
+
+void TForwardingLogBackend::ReopenLog() {
+ return Child_->ReopenLog();
+}
+
+void TForwardingLogBackend::ReopenLogNoFlush() {
+ return Child_->ReopenLogNoFlush();
+}
+
+ELogPriority TForwardingLogBackend::FiltrationLevel() const {
+ return Child_->FiltrationLevel();
+}
+
+size_t TForwardingLogBackend::QueueSize() const {
+ return Child_->QueueSize();
+}
+
+void TForwardingLogBackend::SetChild(TAutoPtr<TLogBackend> child) {
+ Child_ = std::move(child);
+}
+
+TAutoPtr<TLogBackend> TForwardingLogBackend::GetChild() const {
+ return Child_;
+}
} // namespace NYql::NLog
diff --git a/yql/essentials/utils/log/fwd_backend.h b/yql/essentials/utils/log/fwd_backend.h
index 144d2eccee2..21fcd3dc32f 100644
--- a/yql/essentials/utils/log/fwd_backend.h
+++ b/yql/essentials/utils/log/fwd_backend.h
@@ -6,21 +6,21 @@
namespace NYql::NLog {
- class TForwardingLogBackend: public TLogBackend {
- public:
- explicit TForwardingLogBackend(TAutoPtr<TLogBackend> child);
-
- void WriteData(const TLogRecord& rec) override;
- void ReopenLog() override;
- void ReopenLogNoFlush() override;
- ELogPriority FiltrationLevel() const override;
- size_t QueueSize() const override;
-
- void SetChild(TAutoPtr<TLogBackend> child);
- TAutoPtr<TLogBackend> GetChild() const;
-
- private:
- TAutoPtr<TLogBackend> Child_;
- };
+class TForwardingLogBackend: public TLogBackend {
+public:
+ explicit TForwardingLogBackend(TAutoPtr<TLogBackend> child);
+
+ void WriteData(const TLogRecord& rec) override;
+ void ReopenLog() override;
+ void ReopenLogNoFlush() override;
+ ELogPriority FiltrationLevel() const override;
+ size_t QueueSize() const override;
+
+ void SetChild(TAutoPtr<TLogBackend> child);
+ TAutoPtr<TLogBackend> GetChild() const;
+
+private:
+ TAutoPtr<TLogBackend> Child_;
+};
} // namespace NYql::NLog
diff --git a/yql/essentials/utils/log/log.cpp b/yql/essentials/utils/log/log.cpp
index 1b03c194b6a..73394c4f2de 100644
--- a/yql/essentials/utils/log/log.cpp
+++ b/yql/essentials/utils/log/log.cpp
@@ -25,10 +25,9 @@
static TMutex g_InitLoggerMutex;
static int g_LoggerInitialized = 0;
-
namespace {
-class TLimitedLogBackend final : public TLogBackend {
+class TLimitedLogBackend final: public TLogBackend {
public:
TLimitedLogBackend(TAutoPtr<TLogBackend> b, TAtomic& flag, ui64 limit) noexcept
: Backend_(b)
@@ -97,7 +96,6 @@ private:
char Buf_[1 << 20];
char* Current_;
char* const End_;
-
};
TEmergencyLogOutput EMERGENCY_LOG_OUT;
@@ -106,82 +104,119 @@ void LogBacktraceOnSignal(int signum) {
if (NYql::NLog::IsYqlLoggerInitialized()) {
EMERGENCY_LOG_OUT <<
#ifdef _win_
- signum
+ signum
#else
- strsignal(signum)
+ strsignal(signum)
#endif
- << TStringBuf(" (pid=") << GetPID() << TStringBuf("): ");
+ << TStringBuf(" (pid=") << GetPID() << TStringBuf("): ");
NYql::NBacktrace::KikimrBackTraceFormatImpl(&EMERGENCY_LOG_OUT);
EMERGENCY_LOG_OUT.Flush();
}
}
-
// Conversions between NYql::NProto::TLoggingConfig enums and NYql::NLog enums
NYql::NLog::ELevel ConvertLevel(NYql::NProto::TLoggingConfig::ELevel level) {
using namespace NYql::NProto;
using namespace NYql::NLog;
switch (level) {
- case TLoggingConfig::FATAL: return ELevel::FATAL;
- case TLoggingConfig::ERROR: return ELevel::ERROR;
- case TLoggingConfig::WARN: return ELevel::WARN;
- case TLoggingConfig::INFO: return ELevel::INFO;
- case TLoggingConfig::DEBUG: return ELevel::DEBUG;
- case TLoggingConfig::TRACE: return ELevel::TRACE;
+ case TLoggingConfig::FATAL:
+ return ELevel::FATAL;
+ case TLoggingConfig::ERROR:
+ return ELevel::ERROR;
+ case TLoggingConfig::WARN:
+ return ELevel::WARN;
+ case TLoggingConfig::INFO:
+ return ELevel::INFO;
+ case TLoggingConfig::DEBUG:
+ return ELevel::DEBUG;
+ case TLoggingConfig::TRACE:
+ return ELevel::TRACE;
}
ythrow yexception() << "unknown log level: "
- << TLoggingConfig::ELevel_Name(level);
+ << TLoggingConfig::ELevel_Name(level);
}
NYql::NLog::EComponent ConvertComponent(NYql::NProto::TLoggingConfig::EComponent c) {
using namespace NYql::NProto;
using namespace NYql::NLog;
switch (c) {
- case TLoggingConfig::DEFAULT: return EComponent::Default;
- case TLoggingConfig::CORE: return EComponent::Core;
- case TLoggingConfig::CORE_EVAL: return EComponent::CoreEval;
- case TLoggingConfig::CORE_PEEPHOLE: return EComponent::CorePeepHole;
- case TLoggingConfig::CORE_EXECUTION: return EComponent::CoreExecution;
- case TLoggingConfig::SQL: return EComponent::Sql;
- case TLoggingConfig::PROVIDER_COMMON: return EComponent::ProviderCommon;
- case TLoggingConfig::PROVIDER_CONFIG: return EComponent::ProviderConfig;
- case TLoggingConfig::PROVIDER_RESULT: return EComponent::ProviderResult;
- case TLoggingConfig::PROVIDER_YT: return EComponent::ProviderYt;
- case TLoggingConfig::PROVIDER_KIKIMR: return EComponent::ProviderKikimr;
- case TLoggingConfig::PROVIDER_KQP: return EComponent::ProviderKqp;
- case TLoggingConfig::PROVIDER_RTMR: return EComponent::ProviderRtmr;
- case TLoggingConfig::PERFORMANCE: return EComponent::Perf;
- case TLoggingConfig::NET: return EComponent::Net;
- case TLoggingConfig::PROVIDER_STAT: return EComponent::ProviderStat;
- case TLoggingConfig::PROVIDER_SOLOMON: return EComponent::ProviderSolomon;
- case TLoggingConfig::PROVIDER_DQ: return EComponent::ProviderDq;
- case TLoggingConfig::PROVIDER_CLICKHOUSE: return EComponent::ProviderClickHouse;
- case TLoggingConfig::PROVIDER_YDB: return EComponent::ProviderYdb;
- case TLoggingConfig::PROVIDER_PQ: return EComponent::ProviderPq;
- case TLoggingConfig::PROVIDER_S3: return EComponent::ProviderS3;
- case TLoggingConfig::CORE_DQ: return EComponent::CoreDq;
- case TLoggingConfig::HTTP_GATEWAY: return EComponent::HttpGateway;
- case TLoggingConfig::PROVIDER_GENERIC: return EComponent::ProviderGeneric;
- case TLoggingConfig::PROVIDER_PG: return EComponent::ProviderPg;
- case TLoggingConfig::PROVIDER_PURE: return EComponent::ProviderPure;
- case TLoggingConfig::FAST_MAP_REDUCE: return EComponent::FastMapReduce;
- case TLoggingConfig::PROVIDER_YTFLOW: return EComponent::ProviderYtflow;
+ case TLoggingConfig::DEFAULT:
+ return EComponent::Default;
+ case TLoggingConfig::CORE:
+ return EComponent::Core;
+ case TLoggingConfig::CORE_EVAL:
+ return EComponent::CoreEval;
+ case TLoggingConfig::CORE_PEEPHOLE:
+ return EComponent::CorePeepHole;
+ case TLoggingConfig::CORE_EXECUTION:
+ return EComponent::CoreExecution;
+ case TLoggingConfig::SQL:
+ return EComponent::Sql;
+ case TLoggingConfig::PROVIDER_COMMON:
+ return EComponent::ProviderCommon;
+ case TLoggingConfig::PROVIDER_CONFIG:
+ return EComponent::ProviderConfig;
+ case TLoggingConfig::PROVIDER_RESULT:
+ return EComponent::ProviderResult;
+ case TLoggingConfig::PROVIDER_YT:
+ return EComponent::ProviderYt;
+ case TLoggingConfig::PROVIDER_KIKIMR:
+ return EComponent::ProviderKikimr;
+ case TLoggingConfig::PROVIDER_KQP:
+ return EComponent::ProviderKqp;
+ case TLoggingConfig::PROVIDER_RTMR:
+ return EComponent::ProviderRtmr;
+ case TLoggingConfig::PERFORMANCE:
+ return EComponent::Perf;
+ case TLoggingConfig::NET:
+ return EComponent::Net;
+ case TLoggingConfig::PROVIDER_STAT:
+ return EComponent::ProviderStat;
+ case TLoggingConfig::PROVIDER_SOLOMON:
+ return EComponent::ProviderSolomon;
+ case TLoggingConfig::PROVIDER_DQ:
+ return EComponent::ProviderDq;
+ case TLoggingConfig::PROVIDER_CLICKHOUSE:
+ return EComponent::ProviderClickHouse;
+ case TLoggingConfig::PROVIDER_YDB:
+ return EComponent::ProviderYdb;
+ case TLoggingConfig::PROVIDER_PQ:
+ return EComponent::ProviderPq;
+ case TLoggingConfig::PROVIDER_S3:
+ return EComponent::ProviderS3;
+ case TLoggingConfig::CORE_DQ:
+ return EComponent::CoreDq;
+ case TLoggingConfig::HTTP_GATEWAY:
+ return EComponent::HttpGateway;
+ case TLoggingConfig::PROVIDER_GENERIC:
+ return EComponent::ProviderGeneric;
+ case TLoggingConfig::PROVIDER_PG:
+ return EComponent::ProviderPg;
+ case TLoggingConfig::PROVIDER_PURE:
+ return EComponent::ProviderPure;
+ case TLoggingConfig::FAST_MAP_REDUCE:
+ return EComponent::FastMapReduce;
+ case TLoggingConfig::PROVIDER_YTFLOW:
+ return EComponent::ProviderYtflow;
}
ythrow yexception() << "unknown log component: "
- << TLoggingConfig::EComponent_Name(c);
+ << TLoggingConfig::EComponent_Name(c);
}
TString ConvertDestinationType(NYql::NProto::TLoggingConfig::ELogTo c) {
switch (c) {
- case NYql::NProto::TLoggingConfig::STDOUT: return "cout";
- case NYql::NProto::TLoggingConfig::STDERR: return "cerr";
- case NYql::NProto::TLoggingConfig::CONSOLE: return "console";
- default : {
- ythrow yexception() << "unsupported ELogTo destination in Convert";
- }
+ case NYql::NProto::TLoggingConfig::STDOUT:
+ return "cout";
+ case NYql::NProto::TLoggingConfig::STDERR:
+ return "cerr";
+ case NYql::NProto::TLoggingConfig::CONSOLE:
+ return "console";
+ default: {
+ ythrow yexception() << "unsupported ELogTo destination in Convert";
+ }
}
ythrow yexception() << "unknown ELogTo destination";
@@ -204,16 +239,16 @@ NYql::NProto::TLoggingConfig::TLogDestination CreateLogDestination(const TString
NYql::NLog::TFormatter Formatter(const NYql::NProto::TLoggingConfig& config) {
switch (config.GetFormat().Format_case()) {
- case NYql::NProto::TLoggingConfig_TFormat::kLegacyFormat:
- return NYql::NLog::LegacyFormat;
- case NYql::NProto::TLoggingConfig_TFormat::kJsonFormat:
- return NYql::NLog::JsonFormat;
- case NYql::NProto::TLoggingConfig_TFormat::FORMAT_NOT_SET:
- return NYql::NLog::LegacyFormat;
+ case NYql::NProto::TLoggingConfig_TFormat::kLegacyFormat:
+ return NYql::NLog::LegacyFormat;
+ case NYql::NProto::TLoggingConfig_TFormat::kJsonFormat:
+ return NYql::NLog::JsonFormat;
+ case NYql::NProto::TLoggingConfig_TFormat::FORMAT_NOT_SET:
+ return NYql::NLog::LegacyFormat;
}
}
-} // namspace
+} // namespace
namespace NYql {
namespace NLog {
@@ -234,7 +269,7 @@ TString GetLocalTime() {
return std::move(time.Str());
}
-}
+} // namespace NImpl
void WriteLocalTime(IOutputStream* out) {
struct timeval now;
@@ -255,7 +290,9 @@ TYqlLog::TYqlLog()
: TLog()
, ProcName_()
, ProcId_()
- , WriteTruncMsg_(0) {}
+ , WriteTruncMsg_(0)
+{
+}
TYqlLog::TYqlLog(const TString& logType, const TComponentLevels& levels)
: TLog(logType)
@@ -285,9 +322,8 @@ void TYqlLog::UpdateProcInfo(const TString& procName) {
}
TAutoPtr<TLogElement> TYqlLog::CreateLogElement(
- EComponent component, ELevel level,
- TStringBuf file, int line) const
-{
+ EComponent component, ELevel level,
+ TStringBuf file, int line) const {
if (/* const bool writeMsg = */ AtomicCas(&WriteTruncMsg_, 0, 1)) {
TLogElement fatal(this, ELevelHelpers::ToLogPriority(ELevel::FATAL));
Contextify(fatal, EComponent::Default, ELevel::FATAL, __FILE__, __LINE__);
@@ -336,7 +372,7 @@ void InitLogger(const TString& logType, bool startAsDaemon) {
}
void InitLogger(const NProto::TLoggingConfig& config, bool startAsDaemon) {
- with_lock(g_InitLoggerMutex) {
+ with_lock (g_InitLoggerMutex) {
++g_LoggerInitialized;
if (g_LoggerInitialized > 1) {
return;
@@ -349,7 +385,7 @@ void InitLogger(const NProto::TLoggingConfig& config, bool startAsDaemon) {
levels.fill(ELevel::INFO);
}
- for (const auto& cmpLevel: config.GetLevels()) {
+ for (const auto& cmpLevel : config.GetLevels()) {
auto component = ConvertComponent(cmpLevel.GetC());
auto level = ConvertLevel(cmpLevel.GetL());
levels[EComponentHelpers::ToInt(component)] = level;
@@ -410,11 +446,11 @@ void InitLogger(const NProto::TLoggingConfig& config, bool startAsDaemon) {
config.GetFormat().GetIsStrict(),
std::move(backend)));
}
- NYql::NBacktrace::AddAfterFatalCallback([](int signo){ LogBacktraceOnSignal(signo); });
+ NYql::NBacktrace::AddAfterFatalCallback([](int signo) { LogBacktraceOnSignal(signo); });
}
void InitLogger(TAutoPtr<TLogBackend> backend, TFormatter formatter, bool isStrictFormatting) {
- with_lock(g_InitLoggerMutex) {
+ with_lock (g_InitLoggerMutex) {
++g_LoggerInitialized;
if (g_LoggerInitialized > 1) {
return;
@@ -426,7 +462,7 @@ void InitLogger(TAutoPtr<TLogBackend> backend, TFormatter formatter, bool isStri
levels.fill(ELevel::INFO);
TLoggerOperator<TYqlLog>::Set(new TYqlLog(backend, levels));
}
- NYql::NBacktrace::AddAfterFatalCallback([](int signo){ LogBacktraceOnSignal(signo); });
+ NYql::NBacktrace::AddAfterFatalCallback([](int signo) { LogBacktraceOnSignal(signo); });
}
void InitLogger(IOutputStream* out, TFormatter formatter, bool isStrictFormatting) {
@@ -434,7 +470,7 @@ void InitLogger(IOutputStream* out, TFormatter formatter, bool isStrictFormattin
}
void CleanupLogger() {
- with_lock(g_InitLoggerMutex) {
+ with_lock (g_InitLoggerMutex) {
--g_LoggerInitialized;
if (g_LoggerInitialized > 0) {
return;
@@ -445,7 +481,7 @@ void CleanupLogger() {
}
void ReopenLog() {
- with_lock(g_InitLoggerMutex) {
+ with_lock (g_InitLoggerMutex) {
TLoggerOperator<TYqlLog>::Log().ReopenLog();
}
}
diff --git a/yql/essentials/utils/log/log.h b/yql/essentials/utils/log/log.h
index 68aa8b09b0e..e531c183104 100644
--- a/yql/essentials/utils/log/log.h
+++ b/yql/essentials/utils/log/log.h
@@ -14,45 +14,43 @@
#include <array>
-
-#define YQL_LOG_IMPL(logger, component, level, preprocessor, file, line) \
+#define YQL_LOG_IMPL(logger, component, level, preprocessor, file, line) \
logger.NeedToLog(component, level) && NPrivateGlobalLogger::TEatStream() | \
- (*preprocessor::Preprocess(logger.CreateLogElement(component, level, file, line)))
+ (*preprocessor::Preprocess(logger.CreateLogElement(component, level, file, line)))
#define YQL_LOG_IF_IMPL(logger, component, level, preprocessor, condition, file, line) \
- logger.NeedToLog(component, level) && (condition) && NPrivateGlobalLogger::TEatStream() | \
- (*preprocessor::Preprocess(logger.CreateLogElement(component, level, file, line)))
+ logger.NeedToLog(component, level) && (condition) && NPrivateGlobalLogger::TEatStream() | (*preprocessor::Preprocess(logger.CreateLogElement(component, level, file, line)))
// with component logger
-#define YQL_CLOG_PREP(level, component, preprocessor) YQL_LOG_IMPL(\
- ::NYql::NLog::YqlLogger(), \
- ::NYql::NLog::EComponent::component, \
- ::NYql::NLog::ELevel::level, \
- preprocessor, \
+#define YQL_CLOG_PREP(level, component, preprocessor) YQL_LOG_IMPL( \
+ ::NYql::NLog::YqlLogger(), \
+ ::NYql::NLog::EComponent::component, \
+ ::NYql::NLog::ELevel::level, \
+ preprocessor, \
__FILE__, __LINE__)
#define YQL_CLOG(level, component) \
YQL_CLOG_PREP(level, component, ::NYql::NLog::TContextPreprocessor)
#define YQL_CLOG_ACTIVE(level, component) ::NYql::NLog::YqlLogger().NeedToLog( \
- ::NYql::NLog::EComponent::component, \
+ ::NYql::NLog::EComponent::component, \
::NYql::NLog::ELevel::level)
// with component/level values logger
-#define YQL_CVLOG_PREP(level, component, preprocessor) YQL_LOG_IMPL(\
- ::NYql::NLog::YqlLogger(), \
- component, \
- level, \
- preprocessor, \
+#define YQL_CVLOG_PREP(level, component, preprocessor) YQL_LOG_IMPL( \
+ ::NYql::NLog::YqlLogger(), \
+ component, \
+ level, \
+ preprocessor, \
__FILE__, __LINE__)
#define YQL_CVLOG(level, component) \
YQL_CVLOG_PREP(level, component, ::NYql::NLog::TContextPreprocessor)
#define YQL_CVLOG_ACTIVE(level, component) ::NYql::NLog::YqlLogger().NeedToLog( \
- component, \
+ component, \
level)
// default logger
@@ -67,12 +65,12 @@
// conditional logger
-#define YQL_CLOG_PREP_IF(level, component, preprocessor, condition) YQL_LOG_IF_IMPL(\
- ::NYql::NLog::YqlLogger(), \
- ::NYql::NLog::EComponent::component, \
- ::NYql::NLog::ELevel::level, \
- preprocessor, \
- condition, \
+#define YQL_CLOG_PREP_IF(level, component, preprocessor, condition) YQL_LOG_IF_IMPL( \
+ ::NYql::NLog::YqlLogger(), \
+ ::NYql::NLog::EComponent::component, \
+ ::NYql::NLog::ELevel::level, \
+ preprocessor, \
+ condition, \
__FILE__, __LINE__)
#define YQL_CLOG_IF(level, component, condition) \
@@ -84,12 +82,11 @@
#define YQL_LOG_IF(level, condition) \
YQL_LOG_PREP_IF(level, ::NYql::NLog::TContextPreprocessor, condition)
-
namespace NYql {
namespace NProto {
- class TLoggingConfig;
-} // NProto
+class TLoggingConfig;
+} // namespace NProto
namespace NLog {
@@ -99,10 +96,10 @@ TString GetThreadId();
TString GetLocalTime();
-}
+} // namespace NImpl
using TComponentLevels =
- std::array<ELevel, EComponentHelpers::ToInt(EComponent::MaxValue)>;
+ std::array<ELevel, EComponentHelpers::ToInt(EComponent::MaxValue)>;
void WriteLocalTime(IOutputStream* out);
@@ -181,7 +178,7 @@ void InitLogger(const TString& log, bool startAsDaemon = false);
/**
* @brief Initialize logger with backends described in config.
-*/
+ */
void InitLogger(const NProto::TLoggingConfig& loggingConfig, bool startAsDaemon = false);
/**
@@ -204,7 +201,9 @@ void ReopenLog();
class YqlLoggerScope {
public:
- YqlLoggerScope(const TString& log, bool startAsDaemon = false) { InitLogger(log, startAsDaemon); }
+ YqlLoggerScope(const TString& log, bool startAsDaemon = false) {
+ InitLogger(log, startAsDaemon);
+ }
YqlLoggerScope(TAutoPtr<TLogBackend> backend, TFormatter formatter = LegacyFormat, bool isStrictFormatting = true) {
InitLogger(backend, std::move(formatter), isStrictFormatting);
@@ -214,7 +213,9 @@ public:
InitLogger(out, std::move(formatter), isStrictFormatting);
}
- ~YqlLoggerScope() { CleanupLogger(); }
+ ~YqlLoggerScope() {
+ CleanupLogger();
+ }
};
} // namespace NLog
diff --git a/yql/essentials/utils/log/log_component.h b/yql/essentials/utils/log/log_component.h
index be1df138635..bd284cb9d81 100644
--- a/yql/essentials/utils/log/log_component.h
+++ b/yql/essentials/utils/log/log_component.h
@@ -3,7 +3,6 @@
#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>
-
namespace NYql {
namespace NLog {
@@ -20,7 +19,8 @@ enum class EComponent {
ProviderKikimr,
ProviderKqp,
ProviderRtmr,
- Performance, Perf = Performance,
+ Performance,
+ Perf = Performance,
Net,
ProviderStat,
ProviderSolomon,
@@ -50,77 +50,164 @@ struct EComponentHelpers {
static constexpr EComponent FromInt(int component) {
return (component >= ToInt(EComponent::Default) &&
component < ToInt(EComponent::MaxValue))
- ? static_cast<EComponent>(component)
- : EComponent::Default;
+ ? static_cast<EComponent>(component)
+ : EComponent::Default;
}
static TStringBuf ToString(EComponent component) {
switch (component) {
- case EComponent::Default: return TStringBuf("default");
- case EComponent::Core: return TStringBuf("core");
- case EComponent::CoreEval: return TStringBuf("core eval");
- case EComponent::CorePeepHole: return TStringBuf("core peephole");
- case EComponent::CoreExecution: return TStringBuf("core exec");
- case EComponent::Sql: return TStringBuf("sql");
- case EComponent::ProviderCommon: return TStringBuf("common provider");
- case EComponent::ProviderConfig: return TStringBuf("CONFIG");
- case EComponent::ProviderResult: return TStringBuf("RESULT");
- case EComponent::ProviderYt: return TStringBuf("YT");
- case EComponent::ProviderKikimr: return TStringBuf("KIKIMR");
- case EComponent::ProviderKqp: return TStringBuf("KQP");
- case EComponent::ProviderRtmr: return TStringBuf("RTMR");
- case EComponent::Performance: return TStringBuf("perf");
- case EComponent::Net: return TStringBuf("net");
- case EComponent::ProviderStat: return TStringBuf("STATFACE");
- case EComponent::ProviderSolomon: return TStringBuf("SOLOMON");
- case EComponent::ProviderDq: return TStringBuf("DQ");
- case EComponent::ProviderClickHouse: return TStringBuf("CLICKHOUSE");
- case EComponent::ProviderYdb: return TStringBuf("YDB");
- case EComponent::ProviderPq: return TStringBuf("PQ");
- case EComponent::ProviderS3: return TStringBuf("S3");
- case EComponent::CoreDq: return TStringBuf("core dq");
- case EComponent::HttpGateway: return TStringBuf("http gw");
- case EComponent::ProviderGeneric: return TStringBuf("generic");
- case EComponent::ProviderPg: return TStringBuf("PG");
- case EComponent::ProviderPure: return TStringBuf("pure");
- case EComponent::FastMapReduce: return TStringBuf("FMR");
- case EComponent::ProviderYtflow: return TStringBuf("YTFLOW");
- default:
- ythrow yexception() << "invalid log component value: "
- << ToInt(component);
+ case EComponent::Default:
+ return TStringBuf("default");
+ case EComponent::Core:
+ return TStringBuf("core");
+ case EComponent::CoreEval:
+ return TStringBuf("core eval");
+ case EComponent::CorePeepHole:
+ return TStringBuf("core peephole");
+ case EComponent::CoreExecution:
+ return TStringBuf("core exec");
+ case EComponent::Sql:
+ return TStringBuf("sql");
+ case EComponent::ProviderCommon:
+ return TStringBuf("common provider");
+ case EComponent::ProviderConfig:
+ return TStringBuf("CONFIG");
+ case EComponent::ProviderResult:
+ return TStringBuf("RESULT");
+ case EComponent::ProviderYt:
+ return TStringBuf("YT");
+ case EComponent::ProviderKikimr:
+ return TStringBuf("KIKIMR");
+ case EComponent::ProviderKqp:
+ return TStringBuf("KQP");
+ case EComponent::ProviderRtmr:
+ return TStringBuf("RTMR");
+ case EComponent::Performance:
+ return TStringBuf("perf");
+ case EComponent::Net:
+ return TStringBuf("net");
+ case EComponent::ProviderStat:
+ return TStringBuf("STATFACE");
+ case EComponent::ProviderSolomon:
+ return TStringBuf("SOLOMON");
+ case EComponent::ProviderDq:
+ return TStringBuf("DQ");
+ case EComponent::ProviderClickHouse:
+ return TStringBuf("CLICKHOUSE");
+ case EComponent::ProviderYdb:
+ return TStringBuf("YDB");
+ case EComponent::ProviderPq:
+ return TStringBuf("PQ");
+ case EComponent::ProviderS3:
+ return TStringBuf("S3");
+ case EComponent::CoreDq:
+ return TStringBuf("core dq");
+ case EComponent::HttpGateway:
+ return TStringBuf("http gw");
+ case EComponent::ProviderGeneric:
+ return TStringBuf("generic");
+ case EComponent::ProviderPg:
+ return TStringBuf("PG");
+ case EComponent::ProviderPure:
+ return TStringBuf("pure");
+ case EComponent::FastMapReduce:
+ return TStringBuf("FMR");
+ case EComponent::ProviderYtflow:
+ return TStringBuf("YTFLOW");
+ default:
+ ythrow yexception() << "invalid log component value: "
+ << ToInt(component);
}
}
static EComponent FromString(TStringBuf str) {
- if (str == TStringBuf("default")) return EComponent::Default;
- if (str == TStringBuf("core")) return EComponent::Core;
- if (str == TStringBuf("core eval")) return EComponent::CoreEval;
- if (str == TStringBuf("core peephole")) return EComponent::CorePeepHole;
- if (str == TStringBuf("core exec")) return EComponent::CoreExecution;
- if (str == TStringBuf("sql")) return EComponent::Sql;
- if (str == TStringBuf("common provider")) return EComponent::ProviderCommon;
- if (str == TStringBuf("CONFIG")) return EComponent::ProviderConfig;
- if (str == TStringBuf("RESULT")) return EComponent::ProviderResult;
- if (str == TStringBuf("YT")) return EComponent::ProviderYt;
- if (str == TStringBuf("KIKIMR")) return EComponent::ProviderKikimr;
- if (str == TStringBuf("KQP")) return EComponent::ProviderKqp;
- if (str == TStringBuf("RTMR")) return EComponent::ProviderRtmr;
- if (str == TStringBuf("perf")) return EComponent::Performance;
- if (str == TStringBuf("net")) return EComponent::Net;
- if (str == TStringBuf("STATFACE")) return EComponent::ProviderStat;
- if (str == TStringBuf("SOLOMON")) return EComponent::ProviderSolomon;
- if (str == TStringBuf("DQ")) return EComponent::ProviderDq;
- if (str == TStringBuf("CLICKHOUSE")) return EComponent::ProviderClickHouse;
- if (str == TStringBuf("YDB")) return EComponent::ProviderYdb;
- if (str == TStringBuf("PQ")) return EComponent::ProviderPq;
- if (str == TStringBuf("S3")) return EComponent::ProviderS3;
- if (str == TStringBuf("core dq")) return EComponent::CoreDq;
- if (str == TStringBuf("http gw")) return EComponent::HttpGateway;
- if (str == TStringBuf("generic")) return EComponent::ProviderGeneric;
- if (str == TStringBuf("PG")) return EComponent::ProviderPg;
- if (str == TStringBuf("pure")) return EComponent::ProviderPure;
- if (str == TStringBuf("FMR")) return EComponent::FastMapReduce;
- if (str == TStringBuf("YTFLOW")) return EComponent::ProviderYtflow;
+ if (str == TStringBuf("default")) {
+ return EComponent::Default;
+ }
+ if (str == TStringBuf("core")) {
+ return EComponent::Core;
+ }
+ if (str == TStringBuf("core eval")) {
+ return EComponent::CoreEval;
+ }
+ if (str == TStringBuf("core peephole")) {
+ return EComponent::CorePeepHole;
+ }
+ if (str == TStringBuf("core exec")) {
+ return EComponent::CoreExecution;
+ }
+ if (str == TStringBuf("sql")) {
+ return EComponent::Sql;
+ }
+ if (str == TStringBuf("common provider")) {
+ return EComponent::ProviderCommon;
+ }
+ if (str == TStringBuf("CONFIG")) {
+ return EComponent::ProviderConfig;
+ }
+ if (str == TStringBuf("RESULT")) {
+ return EComponent::ProviderResult;
+ }
+ if (str == TStringBuf("YT")) {
+ return EComponent::ProviderYt;
+ }
+ if (str == TStringBuf("KIKIMR")) {
+ return EComponent::ProviderKikimr;
+ }
+ if (str == TStringBuf("KQP")) {
+ return EComponent::ProviderKqp;
+ }
+ if (str == TStringBuf("RTMR")) {
+ return EComponent::ProviderRtmr;
+ }
+ if (str == TStringBuf("perf")) {
+ return EComponent::Performance;
+ }
+ if (str == TStringBuf("net")) {
+ return EComponent::Net;
+ }
+ if (str == TStringBuf("STATFACE")) {
+ return EComponent::ProviderStat;
+ }
+ if (str == TStringBuf("SOLOMON")) {
+ return EComponent::ProviderSolomon;
+ }
+ if (str == TStringBuf("DQ")) {
+ return EComponent::ProviderDq;
+ }
+ if (str == TStringBuf("CLICKHOUSE")) {
+ return EComponent::ProviderClickHouse;
+ }
+ if (str == TStringBuf("YDB")) {
+ return EComponent::ProviderYdb;
+ }
+ if (str == TStringBuf("PQ")) {
+ return EComponent::ProviderPq;
+ }
+ if (str == TStringBuf("S3")) {
+ return EComponent::ProviderS3;
+ }
+ if (str == TStringBuf("core dq")) {
+ return EComponent::CoreDq;
+ }
+ if (str == TStringBuf("http gw")) {
+ return EComponent::HttpGateway;
+ }
+ if (str == TStringBuf("generic")) {
+ return EComponent::ProviderGeneric;
+ }
+ if (str == TStringBuf("PG")) {
+ return EComponent::ProviderPg;
+ }
+ if (str == TStringBuf("pure")) {
+ return EComponent::ProviderPure;
+ }
+ if (str == TStringBuf("FMR")) {
+ return EComponent::FastMapReduce;
+ }
+ if (str == TStringBuf("YTFLOW")) {
+ return EComponent::ProviderYtflow;
+ }
ythrow yexception() << "unknown log component: '" << str << '\'';
}
diff --git a/yql/essentials/utils/log/log_level.h b/yql/essentials/utils/log/log_level.h
index ccb12e4690b..5471e411d52 100644
--- a/yql/essentials/utils/log/log_level.h
+++ b/yql/essentials/utils/log/log_level.h
@@ -5,7 +5,6 @@
#include <util/generic/strbuf.h>
#include <util/generic/yexception.h>
-
namespace NYql {
namespace NLog {
@@ -38,47 +37,74 @@ struct ELevelHelpers {
static ELevel FromInt(int level) {
switch (level) {
- case TLOG_EMERG:
- case TLOG_ALERT:
- case TLOG_CRIT: return ELevel::FATAL;
-
- case TLOG_ERR: return ELevel::ERROR;
- case TLOG_WARNING: return ELevel::WARN;
-
- case TLOG_NOTICE:
- case TLOG_INFO: return ELevel::INFO;
-
- case TLOG_DEBUG: return ELevel::DEBUG;
- case TLOG_RESOURCES: return ELevel::TRACE;
-
- default:
- return ELevel::INFO;
+ case TLOG_EMERG:
+ case TLOG_ALERT:
+ case TLOG_CRIT:
+ return ELevel::FATAL;
+
+ case TLOG_ERR:
+ return ELevel::ERROR;
+ case TLOG_WARNING:
+ return ELevel::WARN;
+
+ case TLOG_NOTICE:
+ case TLOG_INFO:
+ return ELevel::INFO;
+
+ case TLOG_DEBUG:
+ return ELevel::DEBUG;
+ case TLOG_RESOURCES:
+ return ELevel::TRACE;
+
+ default:
+ return ELevel::INFO;
}
}
static TStringBuf ToString(ELevel level) {
// aligned 5-letters string
switch (level) {
- case ELevel::FATAL: return TStringBuf("FATAL");
- case ELevel::ERROR: return TStringBuf("ERROR");
- case ELevel::WARN: return TStringBuf("WARN ");
- case ELevel::NOTICE:return TStringBuf("NOTE ");
- case ELevel::INFO: return TStringBuf("INFO ");
- case ELevel::DEBUG: return TStringBuf("DEBUG");
- case ELevel::TRACE: return TStringBuf("TRACE");
+ case ELevel::FATAL:
+ return TStringBuf("FATAL");
+ case ELevel::ERROR:
+ return TStringBuf("ERROR");
+ case ELevel::WARN:
+ return TStringBuf("WARN ");
+ case ELevel::NOTICE:
+ return TStringBuf("NOTE ");
+ case ELevel::INFO:
+ return TStringBuf("INFO ");
+ case ELevel::DEBUG:
+ return TStringBuf("DEBUG");
+ case ELevel::TRACE:
+ return TStringBuf("TRACE");
}
ythrow yexception() << "unknown log level: " << ToInt(level);
}
static ELevel FromString(TStringBuf str) {
// aligned 5-letters string
- if (str == TStringBuf("FATAL")) return ELevel::FATAL;
- if (str == TStringBuf("ERROR")) return ELevel::ERROR;
- if (str == TStringBuf("WARN ")) return ELevel::WARN;
- if (str == TStringBuf("NOTE ")) return ELevel::NOTICE;
- if (str == TStringBuf("INFO ")) return ELevel::INFO;
- if (str == TStringBuf("DEBUG")) return ELevel::DEBUG;
- if (str == TStringBuf("TRACE")) return ELevel::TRACE;
+ if (str == TStringBuf("FATAL")) {
+ return ELevel::FATAL;
+ }
+ if (str == TStringBuf("ERROR")) {
+ return ELevel::ERROR;
+ }
+ if (str == TStringBuf("WARN ")) {
+ return ELevel::WARN;
+ }
+ if (str == TStringBuf("NOTE ")) {
+ return ELevel::NOTICE;
+ }
+ if (str == TStringBuf("INFO ")) {
+ return ELevel::INFO;
+ }
+ if (str == TStringBuf("DEBUG")) {
+ return ELevel::DEBUG;
+ }
+ if (str == TStringBuf("TRACE")) {
+ return ELevel::TRACE;
+ }
ythrow yexception() << "unknown log level: " << str;
}
@@ -93,6 +119,5 @@ struct ELevelHelpers {
}
};
-
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/log_ut.cpp b/yql/essentials/utils/log/log_ut.cpp
index e2ad8b24824..32cb5c9c02e 100644
--- a/yql/essentials/utils/log/log_ut.cpp
+++ b/yql/essentials/utils/log/log_ut.cpp
@@ -18,710 +18,708 @@
#include <regex>
-
using namespace NYql;
using namespace NLog;
Y_UNIT_TEST_SUITE(TLogTest)
{
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(WrittingWithoutMacro) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format, /* isStrict */ false);
-
- TString message = "some performance info";
- YqlLogger().Write(ELogPriority::TLOG_INFO, message);
-
- TString logRow = out.Str();
- UNIT_ASSERT_STRING_CONTAINS(logRow, message);
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(WrittingWithoutMacro) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format, /* isStrict */ false);
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(WrittingUnknownMetaFlag) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format, /* isStrict */ false);
+ TString message = "some performance info";
+ YqlLogger().Write(ELogPriority::TLOG_INFO, message);
- TString message = "some performance info";
- YqlLogger().Write(ELogPriority::TLOG_INFO, message, {{"unknown", "value"}});
+ TString logRow = out.Str();
+ UNIT_ASSERT_STRING_CONTAINS(logRow, message);
+}
- TString logRow = out.Str();
- UNIT_ASSERT_STRING_CONTAINS(logRow, message);
- UNIT_ASSERT_STRING_CONTAINS(logRow, "unknown = value");
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(WrittingUnknownMetaFlag) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format, /* isStrict */ false);
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Formatting) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
- YqlLogger().UpdateProcInfo("my_proc");
+ TString message = "some performance info";
+ YqlLogger().Write(ELogPriority::TLOG_INFO, message, {{"unknown", "value"}});
- TString message = "some performance info";
- YQL_LOG(INFO) << message;
+ TString logRow = out.Str();
+ UNIT_ASSERT_STRING_CONTAINS(logRow, message);
+ UNIT_ASSERT_STRING_CONTAINS(logRow, "unknown = value");
+}
- TLogRow logRow = ParseLogRow(out.Str());
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Formatting) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+ YqlLogger().UpdateProcInfo("my_proc");
+
+ TString message = "some performance info";
+ YQL_LOG(INFO) << message;
+
+ TLogRow logRow = ParseLogRow(out.Str());
+
+ TDuration elapsed(logRow.Time - TInstant::Now());
+ UNIT_ASSERT(elapsed < TDuration::MilliSeconds(5));
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.ProcName, "my_proc");
+ UNIT_ASSERT_EQUAL(logRow.ProcId, GetPID());
+ UNIT_ASSERT(logRow.ThreadId > 0);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(
+ logRow.FileName,
+ TStringBuf(__FILE__).RNextTok(LOCSLASH_C));
+ UNIT_ASSERT(logRow.LineNumber != 0);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, message);
+}
- TDuration elapsed(logRow.Time - TInstant::Now());
- UNIT_ASSERT(elapsed < TDuration::MilliSeconds(5));
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.ProcName, "my_proc");
- UNIT_ASSERT_EQUAL(logRow.ProcId, GetPID());
- UNIT_ASSERT(logRow.ThreadId > 0);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(
- logRow.FileName,
- TStringBuf(__FILE__).RNextTok(LOCSLASH_C));
- UNIT_ASSERT(logRow.LineNumber != 0);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, message);
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(SpecialCharacters) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+ YqlLogger().UpdateProcInfo("\\evil\\");
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(SpecialCharacters) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
- YqlLogger().UpdateProcInfo("\\evil\\");
+ YQL_LOG(INFO) << "My name is \"YQL\"!";
- YQL_LOG(INFO) << "My name is \"YQL\"!";
+ TLogRow logRow = ParseLogRow(out.Str());
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.ProcName, "\\evil\\");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "My name is \"YQL\"!");
+}
- TLogRow logRow = ParseLogRow(out.Str());
- UNIT_ASSERT_STRINGS_EQUAL(logRow.ProcName, "\\evil\\");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "My name is \"YQL\"!");
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Levels) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format); // default log level INFO
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Levels) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format); // default log level INFO
+ YQL_LOG(FATAL) << "fatal message";
+ YQL_LOG(ERROR) << "error message";
+ YQL_LOG(WARN) << "warning message";
+ YQL_LOG(INFO) << "info message";
+ YQL_LOG(DEBUG) << "debug message";
+ YQL_LOG(TRACE) << "trace message";
- YQL_LOG(FATAL) << "fatal message";
- YQL_LOG(ERROR) << "error message";
- YQL_LOG(WARN) << "warning message";
- YQL_LOG(INFO) << "info message";
- YQL_LOG(DEBUG) << "debug message";
- YQL_LOG(TRACE) << "trace message";
+ TString fatalStr, errorStr, warnStr, infoStr, _;
+ Split(out.Str(), '\n', fatalStr, errorStr, warnStr, infoStr, _);
- TString fatalStr, errorStr, warnStr, infoStr, _;
- Split(out.Str(), '\n', fatalStr, errorStr, warnStr, infoStr, _);
-
- {
- TLogRow logRow = ParseLogRow(fatalStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "fatal message");
- }
- {
- TLogRow logRow = ParseLogRow(errorStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "error message");
- }
- {
- TLogRow logRow = ParseLogRow(warnStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "warning message");
- }
- {
- TLogRow logRow = ParseLogRow(infoStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "info message");
- }
+ {
+ TLogRow logRow = ParseLogRow(fatalStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "fatal message");
}
+ {
+ TLogRow logRow = ParseLogRow(errorStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "error message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(warnStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "warning message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(infoStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "info message");
+ }
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Components) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
-
- YQL_CLOG(INFO, Default) << "default message";
- YQL_CLOG(INFO, Core) << "core message";
- YQL_CLOG(INFO, Sql) << "sql message";
- YQL_CLOG(INFO, ProviderCommon) << "common message";
- YQL_CLOG(INFO, ProviderYt) << "yt message";
- YQL_CLOG(INFO, ProviderKikimr) << "kikimr message";
- YQL_CLOG(INFO, ProviderRtmr) << "rtmr message";
- YQL_CLOG(INFO, Performance) << "performance message";
- YQL_CLOG(INFO, Perf) << "perf message";
-
- TString defaultStr, coreStr, sqlStr, commonStr, ytStr,
- kikimrStr, rtmrStr, performanceStr, perfStr, _;
- Split(out.Str(), '\n', defaultStr, coreStr, sqlStr,
- commonStr, ytStr,
- kikimrStr, rtmrStr,
- performanceStr, perfStr, _);
-
- {
- TLogRow logRow = ParseLogRow(defaultStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "default message");
- }
- {
- TLogRow logRow = ParseLogRow(coreStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "core message");
- }
- {
- TLogRow logRow = ParseLogRow(sqlStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Sql);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "sql message");
- }
- {
- TLogRow logRow = ParseLogRow(commonStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderCommon);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "common message");
- }
- {
- TLogRow logRow = ParseLogRow(ytStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderYt);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "yt message");
- }
- {
- TLogRow logRow = ParseLogRow(kikimrStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderKikimr);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "kikimr message");
- }
- {
- TLogRow logRow = ParseLogRow(rtmrStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderRtmr);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "rtmr message");
- }
- {
- TLogRow logRow = ParseLogRow(performanceStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "performance message");
- }
- {
- TLogRow logRow = ParseLogRow(perfStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "perf message");
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Components) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+
+ YQL_CLOG(INFO, Default) << "default message";
+ YQL_CLOG(INFO, Core) << "core message";
+ YQL_CLOG(INFO, Sql) << "sql message";
+ YQL_CLOG(INFO, ProviderCommon) << "common message";
+ YQL_CLOG(INFO, ProviderYt) << "yt message";
+ YQL_CLOG(INFO, ProviderKikimr) << "kikimr message";
+ YQL_CLOG(INFO, ProviderRtmr) << "rtmr message";
+ YQL_CLOG(INFO, Performance) << "performance message";
+ YQL_CLOG(INFO, Perf) << "perf message";
+
+ TString defaultStr, coreStr, sqlStr, commonStr, ytStr,
+ kikimrStr, rtmrStr, performanceStr, perfStr, _;
+ Split(out.Str(), '\n', defaultStr, coreStr, sqlStr,
+ commonStr, ytStr,
+ kikimrStr, rtmrStr,
+ performanceStr, perfStr, _);
+
+ {
+ TLogRow logRow = ParseLogRow(defaultStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "default message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(coreStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "core message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(sqlStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Sql);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "sql message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(commonStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderCommon);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "common message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(ytStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderYt);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "yt message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(kikimrStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderKikimr);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "kikimr message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(rtmrStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::ProviderRtmr);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "rtmr message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(performanceStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "performance message");
+ }
+ {
+ TLogRow logRow = ParseLogRow(perfStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "perf message");
}
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Conditional) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Conditional) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
- YQL_LOG_IF(INFO, true) << "default info message";
- YQL_LOG_IF(INFO, false) << "must not be logged";
+ YQL_LOG_IF(INFO, true) << "default info message";
+ YQL_LOG_IF(INFO, false) << "must not be logged";
- YQL_CLOG_IF(INFO, Perf, true) << "perf info message";
- YQL_CLOG_IF(INFO, Perf, false) << "perf info message";
+ YQL_CLOG_IF(INFO, Perf, true) << "perf info message";
+ YQL_CLOG_IF(INFO, Perf, false) << "perf info message";
- TString defaultStr, perfStr, _;
- Split(out.Str(), '\n', defaultStr, perfStr, _);
+ TString defaultStr, perfStr, _;
+ Split(out.Str(), '\n', defaultStr, perfStr, _);
- {
- TLogRow logRow = ParseLogRow(defaultStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "default info message");
- }
- {
- TLogRow logRow = ParseLogRow(perfStr);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "perf info message");
- }
+ {
+ TLogRow logRow = ParseLogRow(defaultStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "default info message");
}
+ {
+ TLogRow logRow = ParseLogRow(perfStr);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "perf info message");
+ }
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Contexts) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Contexts) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
- YQL_LOG(INFO) << "level0 - begin";
- {
- YQL_LOG_CTX_SCOPE("ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
- YQL_LOG(INFO) << "level1 - begin";
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
+ YQL_LOG(INFO) << "level0 - begin";
+ {
+ YQL_LOG_CTX_SCOPE("ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
+ YQL_LOG(INFO) << "level1 - begin";
- YQL_LOG_CTX_BLOCK(TStringBuf("ctx2")) {
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
- YQL_LOG(WARN) << "level2";
- }
-
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
- YQL_LOG(INFO) << "level1 - end";
+ YQL_LOG_CTX_BLOCK(TStringBuf("ctx2")) {
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
+ YQL_LOG(WARN) << "level2";
}
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
- YQL_LOG(INFO) << "level0 - end";
- TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
+ YQL_LOG(INFO) << "level1 - end";
+ }
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
+ YQL_LOG(INFO) << "level0 - end";
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
- }
- {
- TLogRow logRow = ParseLogRow(row4Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
- }
- {
- TLogRow logRow = ParseLogRow(row5Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
- }
+ TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
+
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
}
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row4Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row5Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
+ }
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(UnknownSessionContexts) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(UnknownSessionContexts) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+
+ {
+ YQL_LOG_CTX_ROOT_SCOPE("ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
+ YQL_LOG(INFO) << "level0 - begin";
{
- YQL_LOG_CTX_ROOT_SCOPE("ctx");
+ YQL_LOG_CTX_ROOT_SESSION_SCOPE(CurrentLogContextPath());
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level0 - begin";
- {
- YQL_LOG_CTX_ROOT_SESSION_SCOPE(CurrentLogContextPath());
+ YQL_LOG(INFO) << "level1 - begin";
+ YQL_LOG_CTX_BLOCK("ctx1") {
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
-
- YQL_LOG(INFO) << "level1 - begin";
- YQL_LOG_CTX_BLOCK("ctx1") {
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx/ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx/ctx1");
- YQL_LOG(WARN) << "level2";
- }
-
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level1 - end";
+ YQL_LOG(WARN) << "level2";
}
+
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level0 - end";
+ YQL_LOG(INFO) << "level1 - end";
}
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
+ YQL_LOG(INFO) << "level0 - end";
+ }
- TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx/ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
- }
- {
- TLogRow logRow = ParseLogRow(row4Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
- }
- {
- TLogRow logRow = ParseLogRow(row5Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
- }
+ TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx/ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row4Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
}
+ {
+ TLogRow logRow = ParseLogRow(row5Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
+ }
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(SessionContexts) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(SessionContexts) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+
+ {
+ YQL_LOG_CTX_ROOT_SESSION_SCOPE("sessionId", "ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
+ YQL_LOG(INFO) << "level0 - begin";
{
- YQL_LOG_CTX_ROOT_SESSION_SCOPE("sessionId", "ctx");
+ YQL_LOG_CTX_ROOT_SESSION_SCOPE(CurrentLogContextPath());
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level0 - begin";
- {
- YQL_LOG_CTX_ROOT_SESSION_SCOPE(CurrentLogContextPath());
+ YQL_LOG(INFO) << "level1 - begin";
+ YQL_LOG_CTX_BLOCK("ctx1") {
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
-
- YQL_LOG(INFO) << "level1 - begin";
- YQL_LOG_CTX_BLOCK("ctx1") {
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx/ctx1");
-
- YQL_LOG(WARN) << "level2";
- }
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx/ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level1 - end";
+ YQL_LOG(WARN) << "level2";
}
+
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
- YQL_LOG(INFO) << "level0 - end";
- }
-
- TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx/ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
- }
- {
- TLogRow logRow = ParseLogRow(row4Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
- }
- {
- TLogRow logRow = ParseLogRow(row5Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
+ YQL_LOG(INFO) << "level1 - end";
}
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().first, "sessionId");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx");
+ YQL_LOG(INFO) << "level0 - end";
}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ThrowWithContext) {
- bool isThrown = false;
- YQL_LOG_CTX_SCOPE("first");
- try {
- YQL_LOG_CTX_SCOPE("second");
- YQL_LOG_CTX_THROW yexception() << "some message";
- } catch (const yexception& e) {
- isThrown = true;
-
- UNIT_ASSERT_STRINGS_EQUAL(e.AsStrBuf(), "some message");
-
- TString throwedLogCtx = ThrowedLogContextPath();
- TStringBuf file, line, context;
- TStringBuf(throwedLogCtx).Split(".cpp:", file, line);
- line.Split(':', line, context);
-
- TString expectedFile(__LOCATION__.File);
- SubstGlobal(expectedFile, LOCSLASH_C, '/');
- UNIT_ASSERT_STRINGS_EQUAL(TString(file)+".cpp", expectedFile);
- int lineNumber;
- UNIT_ASSERT(TryFromString<int>(line, lineNumber));
- UNIT_ASSERT(lineNumber > 0);
- UNIT_ASSERT_STRINGS_EQUAL(context, " {first/second} ");
-
- // second call without throw returns empty string
- throwedLogCtx = ThrowedLogContextPath();
- UNIT_ASSERT(throwedLogCtx.empty());
- }
+ TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx/ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row4Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row5Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "sessionId/ctx");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level0 - end");
+ }
+}
- UNIT_ASSERT_C(isThrown, "exception was not thrown");
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ThrowWithContext) {
+ bool isThrown = false;
+ YQL_LOG_CTX_SCOPE("first");
+ try {
+ YQL_LOG_CTX_SCOPE("second");
+ YQL_LOG_CTX_THROW yexception() << "some message";
+ } catch (const yexception& e) {
+ isThrown = true;
+
+ UNIT_ASSERT_STRINGS_EQUAL(e.AsStrBuf(), "some message");
+
+ TString throwedLogCtx = ThrowedLogContextPath();
+ TStringBuf file, line, context;
+ TStringBuf(throwedLogCtx).Split(".cpp:", file, line);
+ line.Split(':', line, context);
+
+ TString expectedFile(__LOCATION__.File);
+ SubstGlobal(expectedFile, LOCSLASH_C, '/');
+ UNIT_ASSERT_STRINGS_EQUAL(TString(file) + ".cpp", expectedFile);
+ int lineNumber;
+ UNIT_ASSERT(TryFromString<int>(line, lineNumber));
+ UNIT_ASSERT(lineNumber > 0);
+ UNIT_ASSERT_STRINGS_EQUAL(context, " {first/second} ");
+
+ // second call without throw returns empty string
+ throwedLogCtx = ThrowedLogContextPath();
+ UNIT_ASSERT(throwedLogCtx.empty());
}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ContextOverride) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+ UNIT_ASSERT_C(isThrown, "exception was not thrown");
+}
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
- {
- YQL_LOG_CTX_SCOPE("ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
- YQL_LOG(INFO) << "level1 - begin";
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ContextOverride) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
- YQL_LOG_CTX_BLOCK(TStringBuf("ctx2")) {
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
- YQL_LOG(WARN) << "level2 - begin";
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
+ {
+ YQL_LOG_CTX_SCOPE("ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
+ YQL_LOG(INFO) << "level1 - begin";
- {
- YQL_LOG_CTX_ROOT_SCOPE("ctx3");
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx3");
- YQL_LOG(ERROR) << "level3";
- }
+ YQL_LOG_CTX_BLOCK(TStringBuf("ctx2")) {
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
+ YQL_LOG(WARN) << "level2 - begin";
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
- YQL_LOG(WARN) << "level2 - end";
+ {
+ YQL_LOG_CTX_ROOT_SCOPE("ctx3");
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx3");
+ YQL_LOG(ERROR) << "level3";
}
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
- YQL_LOG(INFO) << "level1 - end";
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1/ctx2");
+ YQL_LOG(WARN) << "level2 - end";
}
- UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
-
- TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2 - begin");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx3");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level3");
- }
- {
- TLogRow logRow = ParseLogRow(row4Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2 - end");
- }
- {
- TLogRow logRow = ParseLogRow(row5Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
- }
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "ctx1");
+ YQL_LOG(INFO) << "level1 - end";
}
+ UNIT_ASSERT_STRINGS_EQUAL(CurrentLogContextPath().second, "");
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Profiling) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+ TString row1Str, row2Str, row3Str, row4Str, row5Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, row5Str, _);
- {
- YQL_PROFILE_SCOPE(INFO, "scope1");
- }
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2 - begin");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx3");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level3");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row4Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1/ctx2");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level2 - end");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row5Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Path, "ctx1");
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "level1 - end");
+ }
+}
- YQL_PROFILE_BLOCK(WARN, "block1") {
- Sleep(TDuration::MilliSeconds(2));
- }
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Profiling) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
- YQL_PROFILE_BLOCK(ERROR, "block2") {
- Sleep(TDuration::MilliSeconds(1200));
- }
+ {
+ YQL_PROFILE_SCOPE(INFO, "scope1");
+ }
- bool isExecuted = false;
- YQL_PROFILE_BLOCK(TRACE, "block3") { // log will be filtered out
- isExecuted = true;
- }
- UNIT_ASSERT(isExecuted);
+ YQL_PROFILE_BLOCK(WARN, "block1") {
+ Sleep(TDuration::MilliSeconds(2));
+ }
- TString row1Str, row2Str, row3Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, _);
+ YQL_PROFILE_BLOCK(ERROR, "block2") {
+ Sleep(TDuration::MilliSeconds(1200));
+ }
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
- std::regex re("Execution of \\[scope1\\] took [0-9\\.]+us");
- bool isMatch = std::regex_match(logRow.Message.c_str(), re);
- UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
- std::regex re("Execution of \\[block1\\] took [0-9\\.]+ms");
- bool isMatch = std::regex_match(logRow.Message.c_str(), re);
- UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
- std::regex re("Execution of \\[block2\\] took [0-9\\.]+s");
- bool isMatch = std::regex_match(logRow.Message.c_str(), re);
- UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
- }
+ bool isExecuted = false;
+ YQL_PROFILE_BLOCK(TRACE, "block3") { // log will be filtered out
+ isExecuted = true;
}
+ UNIT_ASSERT(isExecuted);
+ TString row1Str, row2Str, row3Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, _);
- int Func1(int a, char b) {
- YQL_PROFILE_FUNC(INFO);
- return a + b;
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ std::regex re("Execution of \\[scope1\\] took [0-9\\.]+us");
+ bool isMatch = std::regex_match(logRow.Message.c_str(), re);
+ UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
}
-
- int Func2(int a, char b) {
- YQL_PROFILE_FUNCSIG(WARN);
- return a + b;
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ std::regex re("Execution of \\[block1\\] took [0-9\\.]+ms");
+ bool isMatch = std::regex_match(logRow.Message.c_str(), re);
+ UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::ERROR);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ std::regex re("Execution of \\[block2\\] took [0-9\\.]+s");
+ bool isMatch = std::regex_match(logRow.Message.c_str(), re);
+ UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
}
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ProfilingFuncs) {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
+int Func1(int a, char b) {
+ YQL_PROFILE_FUNC(INFO);
+ return a + b;
+}
- Func1(1, 2);
- Func2(1, 2);
+int Func2(int a, char b) {
+ YQL_PROFILE_FUNCSIG(WARN);
+ return a + b;
+}
- TString row1Str, row2Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, _);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(ProfilingFuncs) {
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ Func1(1, 2);
+ Func2(1, 2);
+
+ TString row1Str, row2Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, _);
+
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
#ifdef _win_
- std::regex re("Execution of \\[[NTestSuiteTLogTest::Func1\\] took [0-9\\.]+us");
+ std::regex re("Execution of \\[[NTestSuiteTLogTest::Func1\\] took [0-9\\.]+us");
#else
- std::regex re("Execution of \\[Func1\\] took [0-9\\.]+us");
+ std::regex re("Execution of \\[Func1\\] took [0-9\\.]+us");
#endif
- bool isMatch = std::regex_match(logRow.Message.c_str(), re);
- UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
+ bool isMatch = std::regex_match(logRow.Message.c_str(), re);
+ UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Perf);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Performance);
#ifdef _win_
- std::regex re("Execution of \\[int __cdecl NTestSuiteTLogTest::Func2\\(int, char\\)\\] took [0-9\\.]+us");
+ std::regex re("Execution of \\[int __cdecl NTestSuiteTLogTest::Func2\\(int, char\\)\\] took [0-9\\.]+us");
#else
- std::regex re("Execution of \\[int NTestSuiteTLogTest::Func2\\(int, char\\)\\] took [0-9\\.]+us");
+ std::regex re("Execution of \\[int NTestSuiteTLogTest::Func2\\(int, char\\)\\] took [0-9\\.]+us");
#endif
- bool isMatch = std::regex_match(logRow.Message.c_str(), re);
- UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
- }
+ bool isMatch = std::regex_match(logRow.Message.c_str(), re);
+ UNIT_ASSERT_C(isMatch, "Unexpected message: " << logRow.Message);
}
+}
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Limit1) {
- size_t limit = 0;
- {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
- YqlLogger().UpdateProcInfo("proc");
- YQL_CLOG(INFO, Core) << "message1";
- limit = out.Str().length() * 2 - 7; // Not more than 2 log lines
- }
-
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Limit1) {
+ size_t limit = 0;
+ {
TStringStream out;
YqlLoggerScope logger(&out, Format);
YqlLogger().UpdateProcInfo("proc");
- YqlLogger().SetMaxLogLimit(limit);
-
YQL_CLOG(INFO, Core) << "message1";
- YQL_CLOG(INFO, Core) << "message2";
- YQL_CLOG(INFO, Core) << "message3";
+ limit = out.Str().length() * 2 - 7; // Not more than 2 log lines
+ }
- TString row1Str, row2Str, row3Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, _);
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+ YqlLogger().UpdateProcInfo("proc");
+ YqlLogger().SetMaxLogLimit(limit);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message1");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message2");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "Log is truncated by limit");
- }
- }
+ YQL_CLOG(INFO, Core) << "message1";
+ YQL_CLOG(INFO, Core) << "message2";
+ YQL_CLOG(INFO, Core) << "message3";
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Limit2) {
- size_t limit = 0;
- {
- TStringStream out;
- YqlLoggerScope logger(&out, Format);
- YqlLogger().UpdateProcInfo("proc");
- YQL_CLOG(INFO, Core) << "message1";
- limit = out.Str().length() * 2 - 7; // Not more than 2 log lines
- }
+ TString row1Str, row2Str, row3Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, _);
+
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message1");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message2");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "Log is truncated by limit");
+ }
+}
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(Limit2) {
+ size_t limit = 0;
+ {
TStringStream out;
YqlLoggerScope logger(&out, Format);
YqlLogger().UpdateProcInfo("proc");
- YqlLogger().SetMaxLogLimit(limit);
-
YQL_CLOG(INFO, Core) << "message1";
- YQL_CLOG(INFO, Core) << "message2";
- YQL_CLOG(WARN, Core) << "message3";
+ limit = out.Str().length() * 2 - 7; // Not more than 2 log lines
+ }
- TString row1Str, row2Str, row3Str, row4Str, _;
- Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, _);
+ TStringStream out;
+ YqlLoggerScope logger(&out, Format);
+ YqlLogger().UpdateProcInfo("proc");
+ YqlLogger().SetMaxLogLimit(limit);
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message1");
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message2");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "Log is truncated by limit");
- }
- {
- TLogRow logRow = ParseLogRow(row4Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message3");
- }
+ YQL_CLOG(INFO, Core) << "message1";
+ YQL_CLOG(INFO, Core) << "message2";
+ YQL_CLOG(WARN, Core) << "message3";
+
+ TString row1Str, row2Str, row3Str, row4Str, _;
+ Split(out.Str(), '\n', row1Str, row2Str, row3Str, row4Str, _);
+
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message1");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message2");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::FATAL);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "Log is truncated by limit");
+ }
+ {
+ TLogRow logRow = ParseLogRow(row4Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::WARN);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Core);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "message3");
}
}
+} // Y_UNIT_TEST_SUITE(TLogTest)
diff --git a/yql/essentials/utils/log/profile.cpp b/yql/essentials/utils/log/profile.cpp
index 130bb05a4ab..66bf8de7171 100644
--- a/yql/essentials/utils/log/profile.cpp
+++ b/yql/essentials/utils/log/profile.cpp
@@ -3,12 +3,10 @@
#include <util/stream/format.h>
-
-#define YQL_PERF_LOG(level, file, line) YQL_LOG_IMPL( \
+#define YQL_PERF_LOG(level, file, line) YQL_LOG_IMPL( \
::NYql::NLog::YqlLogger(), ::NYql::NLog::EComponent::Perf, level, \
::NYql::NLog::TContextPreprocessor, file, line)
-
namespace NYql {
namespace NLog {
@@ -30,8 +28,8 @@ TProfilingScope::~TProfilingScope() {
auto doLog = [&]() {
YQL_PERF_LOG(Level_, File_, Line_)
- << TStringBuf("Execution of [") << Name_
- << TStringBuf("] took ") << Prec(elapsed, 3) << unit;
+ << TStringBuf("Execution of [") << Name_
+ << TStringBuf("] took ") << Prec(elapsed, 3) << unit;
};
if (!LogCtxPath_.first.empty() || !LogCtxPath_.second.empty()) {
@@ -46,5 +44,5 @@ TProfilingScope::~TProfilingScope() {
}
}
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/profile.h b/yql/essentials/utils/log/profile.h
index dda7e03f9d2..0c5fd4f74d9 100644
--- a/yql/essentials/utils/log/profile.h
+++ b/yql/essentials/utils/log/profile.h
@@ -5,29 +5,30 @@
#include <util/system/datetime.h>
-
-#define YQL_PROFILE_SCOPE(level, name) \
+#define YQL_PROFILE_SCOPE(level, name) \
::NYql::NLog::TProfilingScope Y_GENERATE_UNIQUE_ID(ps)( \
- name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__)
+ name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__)
#define YQL_PROFILE_BLOCK_IMPL(level, name) \
- ::NYql::NLog::TProfilingScope( \
- name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__)
+ ::NYql::NLog::TProfilingScope( \
+ name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__)
-#define YQL_PROFILE_SCOPE_VAL(level, name) \
- TAutoPtr<::NYql::NLog::TProfilingScope>(new ::NYql::NLog::TProfilingScope(\
- name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__, \
- ::NYql::NLog::CurrentLogContextPath()))
+#define YQL_PROFILE_SCOPE_VAL(level, name) \
+ TAutoPtr<::NYql::NLog::TProfilingScope>(new ::NYql::NLog::TProfilingScope( \
+ name, ::NYql::NLog::ELevel::level, __FILE__, __LINE__, \
+ ::NYql::NLog::CurrentLogContextPath()))
-#define YQL_PROFILE_BIND_VAL(future, scopeVal) \
+#define YQL_PROFILE_BIND_VAL(future, scopeVal) \
future.Apply([scopeVal](const decltype(future)& f) { \
- return f.GetValue(); \
+ return f.GetValue(); \
});
-#define YQL_PROFILE_BLOCK(level, name) \
+#define YQL_PROFILE_BLOCK(level, name) \
if (auto Y_GENERATE_UNIQUE_ID(t) = YQL_PROFILE_SCOPE_VAL(level, name)) { \
- goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
- } else Y_CAT(YQL_LOG_CTX_LABEL, __LINE__):
+ goto Y_CAT(YQL_LOG_CTX_LABEL, __LINE__); \
+ } else \
+ Y_CAT(YQL_LOG_CTX_LABEL, __LINE__) \
+ :
#define YQL_PROFILE_FUNC(level) YQL_PROFILE_SCOPE(level, __FUNCTION__)
#define YQL_PROFILE_FUNCSIG(level) YQL_PROFILE_SCOPE(level, Y_FUNC_SIGNATURE)
@@ -35,7 +36,6 @@
#define YQL_PROFILE_FUNC_VAL(level) YQL_PROFILE_SCOPE_VAL(level, __FUNCTION__)
#define YQL_PROFILE_FUNCSIG_VAL(level) YQL_PROFILE_SCOPE_VAL(level, Y_FUNC_SIGNATURE)
-
namespace NYql {
namespace NLog {
@@ -70,5 +70,5 @@ private:
std::pair<TString, TString> LogCtxPath_;
};
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/tls_backend.cpp b/yql/essentials/utils/log/tls_backend.cpp
index a92f123c9bf..ec677fe8e8a 100644
--- a/yql/essentials/utils/log/tls_backend.cpp
+++ b/yql/essentials/utils/log/tls_backend.cpp
@@ -2,19 +2,18 @@
#include <util/system/tls.h>
-
namespace NYql {
namespace NLog {
namespace {
Y_POD_STATIC_THREAD(TLogBackend*) CurrentBackend;
-} // namspace
+} // namespace
TLogBackend* SetLogBackendForCurrentThread(TLogBackend* backend) {
- TLogBackend* prev = *(&CurrentBackend);
- *(&CurrentBackend) = backend;
- return prev;
+ TLogBackend* prev = *(&CurrentBackend);
+ *(&CurrentBackend) = backend;
+ return prev;
}
void TTlsLogBackend::WriteData(const TLogRecord& rec) {
@@ -45,5 +44,5 @@ ELogPriority TTlsLogBackend::FiltrationLevel() const {
return LOG_MAX_PRIORITY;
}
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/tls_backend.h b/yql/essentials/utils/log/tls_backend.h
index 802a73aae90..f8bded8bae7 100644
--- a/yql/essentials/utils/log/tls_backend.h
+++ b/yql/essentials/utils/log/tls_backend.h
@@ -6,7 +6,6 @@
#include <utility>
-
namespace NYql {
namespace NLog {
@@ -63,5 +62,5 @@ private:
TLogBackend* PrevBacked_;
};
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/tls_backend_ut.cpp b/yql/essentials/utils/log/tls_backend_ut.cpp
index 96d77751316..e5496c746a3 100644
--- a/yql/essentials/utils/log/tls_backend_ut.cpp
+++ b/yql/essentials/utils/log/tls_backend_ut.cpp
@@ -15,7 +15,6 @@
#include <thread>
#include <chrono>
-
using namespace NYql;
using namespace NLog;
@@ -53,72 +52,72 @@ private:
Y_UNIT_TEST_SUITE(TTlsLogBackendTest)
{
- Y_UNIT_TEST_ON_EACH_LOG_FORMAT(CaptureOutputs) {
- YqlLoggerScope logger(new TTlsLogBackend(new TNullLogBackend), Format);
+Y_UNIT_TEST_ON_EACH_LOG_FORMAT(CaptureOutputs) {
+ YqlLoggerScope logger(new TTlsLogBackend(new TNullLogBackend), Format);
- YQL_LOG(INFO) << "this message will be missed";
+ YQL_LOG(INFO) << "this message will be missed";
- TRunnable r1("t1", 3);
- std::thread t1(std::ref(r1));
+ TRunnable r1("t1", 3);
+ std::thread t1(std::ref(r1));
- TRunnable r2("t2", 2);
- std::thread t2(std::ref(r2));
+ TRunnable r2("t2", 2);
+ std::thread t2(std::ref(r2));
- t1.join();
- t2.join();
+ t1.join();
+ t2.join();
-// Cout << "--[t1 logs]-----------------\n" << r1.GetLogs() << Endl;
-// Cout << "--[t2 logs]-----------------\n" << r2.GetLogs() << Endl;
+ // Cout << "--[t1 logs]-----------------\n" << r1.GetLogs() << Endl;
+ // Cout << "--[t2 logs]-----------------\n" << r2.GetLogs() << Endl;
- { // t1
- TString row1Str, row2Str, row3Str, _;
- Split(r1.GetLogs(), '\n', row1Str, row2Str, row3Str, _);
+ { // t1
+ TString row1Str, row2Str, row3Str, _;
+ Split(r1.GetLogs(), '\n', row1Str, row2Str, row3Str, _);
- ui64 threadId = 0;
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT(logRow.ThreadId > 0);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
- threadId = logRow.ThreadId;
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
- }
- {
- TLogRow logRow = ParseLogRow(row3Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
- }
+ ui64 threadId = 0;
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT(logRow.ThreadId > 0);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
+ threadId = logRow.ThreadId;
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
}
+ {
+ TLogRow logRow = ParseLogRow(row3Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t1");
+ }
+ }
- { // t2
- TString row1Str, row2Str, _;
- Split(r2.GetLogs(), '\n', row1Str, row2Str, _);
-
- ui64 threadId = 0;
- {
- TLogRow logRow = ParseLogRow(row1Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT(logRow.ThreadId > 0);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t2");
- threadId = logRow.ThreadId;
- }
- {
- TLogRow logRow = ParseLogRow(row2Str);
- UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
- UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
- UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
- UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t2");
- }
+ { // t2
+ TString row1Str, row2Str, _;
+ Split(r2.GetLogs(), '\n', row1Str, row2Str, _);
+
+ ui64 threadId = 0;
+ {
+ TLogRow logRow = ParseLogRow(row1Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT(logRow.ThreadId > 0);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t2");
+ threadId = logRow.ThreadId;
+ }
+ {
+ TLogRow logRow = ParseLogRow(row2Str);
+ UNIT_ASSERT_EQUAL(logRow.Level, ELevel::INFO);
+ UNIT_ASSERT_EQUAL(logRow.Component, EComponent::Default);
+ UNIT_ASSERT_EQUAL(logRow.ThreadId, threadId);
+ UNIT_ASSERT_STRINGS_EQUAL(logRow.Message, "t2");
}
}
}
+} // Y_UNIT_TEST_SUITE(TTlsLogBackendTest)
diff --git a/yql/essentials/utils/log/ut/log_parser.cpp b/yql/essentials/utils/log/ut/log_parser.cpp
index 461fd67cdbd..55f23ba0f57 100644
--- a/yql/essentials/utils/log/ut/log_parser.cpp
+++ b/yql/essentials/utils/log/ut/log_parser.cpp
@@ -4,67 +4,67 @@
namespace NYql::NLog {
- TLogRow ParseJsonLogRow(TStringBuf str) {
- NJson::TJsonMap json;
- UNIT_ASSERT_C(NJson::ReadJsonTree(str, &json), "invalid json '" << str << "'");
+TLogRow ParseJsonLogRow(TStringBuf str) {
+ NJson::TJsonMap json;
+ UNIT_ASSERT_C(NJson::ReadJsonTree(str, &json), "invalid json '" << str << "'");
- return {
- .Time = TInstant::ParseIso8601(json["@fields"]["datetime"].GetStringSafe()) - TDuration::Hours(4),
- .Level = ELevelHelpers::FromString(json["@fields"]["level"].GetStringSafe()),
- .ProcName = json["@fields"]["procname"].GetStringSafe(),
- .ProcId = FromString<pid_t>(json["@fields"]["pid"].GetStringSafe()),
- .ThreadId = [&] {
- TString string = json["@fields"]["tid"].GetStringSafe();
- if (string.substr(0, 2) == "0x") {
- return IntFromString<ui64, 16, TStringBuf>(string.substr(2));
- } else {
- return IntFromString<ui64, 10, TStringBuf>(string);
- }
- }(),
- .Component = EComponentHelpers::FromString(json["@fields"]["component"].GetStringSafe()),
- .FileName = json["@fields"]["filename"].GetStringSafe(),
- .LineNumber = FromString<ui32>(json["@fields"]["line"].GetStringSafe()),
- .Path = json["@fields"]["path"].GetStringRobust(),
- .Message = json["message"].GetStringSafe(),
- };
- }
+ return {
+ .Time = TInstant::ParseIso8601(json["@fields"]["datetime"].GetStringSafe()) - TDuration::Hours(4),
+ .Level = ELevelHelpers::FromString(json["@fields"]["level"].GetStringSafe()),
+ .ProcName = json["@fields"]["procname"].GetStringSafe(),
+ .ProcId = FromString<pid_t>(json["@fields"]["pid"].GetStringSafe()),
+ .ThreadId = [&] {
+ TString string = json["@fields"]["tid"].GetStringSafe();
+ if (string.substr(0, 2) == "0x") {
+ return IntFromString<ui64, 16, TStringBuf>(string.substr(2));
+ } else {
+ return IntFromString<ui64, 10, TStringBuf>(string);
+ }
+ }(),
+ .Component = EComponentHelpers::FromString(json["@fields"]["component"].GetStringSafe()),
+ .FileName = json["@fields"]["filename"].GetStringSafe(),
+ .LineNumber = FromString<ui32>(json["@fields"]["line"].GetStringSafe()),
+ .Path = json["@fields"]["path"].GetStringRobust(),
+ .Message = json["message"].GetStringSafe(),
+ };
+}
- TLogRow ParseLegacyLogRow(TStringBuf str) {
- static std::regex rowRe(
- "^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}) " // (1) time
- "([A-Z ]{5}) " // (2) level
- "([a-zA-Z0-9_\\.-]+)" // (3) process name
- ".pid=([0-9]+)," // (4) process id
- " tid=(0?x?[0-9a-fA-F]+). " // (5) thread id
- ".([a-zA-Z0-9_\\. ]+). " // (6) component name
- "([^:]+):" // (7) file name
- "([0-9]+): " // (8) line number
- "(\\{[^\n]*\\} )?" // (9) path
- "([^\n]*)\n?$" // (10) message
- , std::regex_constants::extended);
+TLogRow ParseLegacyLogRow(TStringBuf str) {
+ static std::regex rowRe(
+ "^([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}) " // (1) time
+ "([A-Z ]{5}) " // (2) level
+ "([a-zA-Z0-9_\\.-]+)" // (3) process name
+ ".pid=([0-9]+)," // (4) process id
+ " tid=(0?x?[0-9a-fA-F]+). " // (5) thread id
+ ".([a-zA-Z0-9_\\. ]+). " // (6) component name
+ "([^:]+):" // (7) file name
+ "([0-9]+): " // (8) line number
+ "(\\{[^\n]*\\} )?" // (9) path
+ "([^\n]*)\n?$" // (10) message
+ , std::regex_constants::extended);
- std::cmatch match;
- bool isMatch = std::regex_match(str.data(), match, rowRe);
+ std::cmatch match;
+ bool isMatch = std::regex_match(str.data(), match, rowRe);
- UNIT_ASSERT_C(isMatch, "log row does not match format: '" << str << '\'');
- UNIT_ASSERT_EQUAL_C(match.size(), 11, "expected 11 groups in log row: '" << str << '\'');
+ UNIT_ASSERT_C(isMatch, "log row does not match format: '" << str << '\'');
+ UNIT_ASSERT_EQUAL_C(match.size(), 11, "expected 11 groups in log row: '" << str << '\'');
- return {
- .Time = TInstant::ParseIso8601(match[1].str()) - TDuration::Hours(4),
- .Level = ELevelHelpers::FromString(match[2].str()),
- .ProcName = match[3].str(),
- .ProcId = FromString<pid_t>(match[4].str()),
- .ThreadId = match[5].str().substr(0, 2) == "0x"
- ? IntFromString<ui64, 16, TStringBuf>(match[5].str().substr(2))
- : IntFromString<ui64, 10, TStringBuf>(match[5].str()),
- .Component = EComponentHelpers::FromString(match[6].str()),
- .FileName = match[7].str(),
- .LineNumber = FromString<ui32>(match[8].str()),
- .Path = match[9].str() != ""
- ? match[9].str().substr(1, match[9].str().size() - 3)
- : "",
- .Message = match[10].str(),
- };
- }
+ return {
+ .Time = TInstant::ParseIso8601(match[1].str()) - TDuration::Hours(4),
+ .Level = ELevelHelpers::FromString(match[2].str()),
+ .ProcName = match[3].str(),
+ .ProcId = FromString<pid_t>(match[4].str()),
+ .ThreadId = match[5].str().substr(0, 2) == "0x"
+ ? IntFromString<ui64, 16, TStringBuf>(match[5].str().substr(2))
+ : IntFromString<ui64, 10, TStringBuf>(match[5].str()),
+ .Component = EComponentHelpers::FromString(match[6].str()),
+ .FileName = match[7].str(),
+ .LineNumber = FromString<ui32>(match[8].str()),
+ .Path = match[9].str() != ""
+ ? match[9].str().substr(1, match[9].str().size() - 3)
+ : "",
+ .Message = match[10].str(),
+ };
+}
} // namespace NYql::NLog
diff --git a/yql/essentials/utils/log/ut/log_parser.h b/yql/essentials/utils/log/ut/log_parser.h
index a1bea046821..922000924b9 100644
--- a/yql/essentials/utils/log/ut/log_parser.h
+++ b/yql/essentials/utils/log/ut/log_parser.h
@@ -27,5 +27,5 @@ struct TLogRow {
TLogRow ParseLegacyLogRow(TStringBuf str);
TLogRow ParseJsonLogRow(TStringBuf str);
-} // namspace NLog
-} // namspace NYql
+} // namespace NLog
+} // namespace NYql
diff --git a/yql/essentials/utils/log/ut/ya.make b/yql/essentials/utils/log/ut/ya.make
index a78d4e0601b..3732c3f1ebc 100644
--- a/yql/essentials/utils/log/ut/ya.make
+++ b/yql/essentials/utils/log/ut/ya.make
@@ -1,5 +1,7 @@
UNITTEST_FOR(yql/essentials/utils/log)
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
log_parser.cpp
log_ut.cpp
diff --git a/yql/essentials/utils/log/ya.make b/yql/essentials/utils/log/ya.make
index 540b524c5eb..2a0d3dc3a4a 100644
--- a/yql/essentials/utils/log/ya.make
+++ b/yql/essentials/utils/log/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
context.cpp
format.cpp
diff --git a/yql/essentials/utils/md5_stream.cpp b/yql/essentials/utils/md5_stream.cpp
index 8a1c2191645..10e7bd07c9c 100644
--- a/yql/essentials/utils/md5_stream.cpp
+++ b/yql/essentials/utils/md5_stream.cpp
@@ -8,7 +8,7 @@ TMd5OutputStream::TMd5OutputStream(IOutputStream& delegatee)
}
TString TMd5OutputStream::Finalize() {
- char buf[33] = { 0 };
+ char buf[33] = {0};
return TString(Accumulator_.End(buf));
}
@@ -17,4 +17,4 @@ void TMd5OutputStream::DoWrite(const void* buf, size_t len) {
Accumulator_.Update(buf, len);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/md5_stream.h b/yql/essentials/utils/md5_stream.h
index ca8b1c4bb94..3fd73e8e304 100644
--- a/yql/essentials/utils/md5_stream.h
+++ b/yql/essentials/utils/md5_stream.h
@@ -4,7 +4,7 @@
#include <library/cpp/digest/md5/md5.h>
namespace NYql {
-class TMd5OutputStream : public IOutputStream {
+class TMd5OutputStream: public IOutputStream {
public:
explicit TMd5OutputStream(IOutputStream& delegatee);
TString Finalize();
@@ -16,4 +16,4 @@ private:
IOutputStream& Delegatee_;
MD5 Accumulator_;
};
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/md5_stream_ut.cpp b/yql/essentials/utils/md5_stream_ut.cpp
index 1d04c632d49..a120e83eda0 100644
--- a/yql/essentials/utils/md5_stream_ut.cpp
+++ b/yql/essentials/utils/md5_stream_ut.cpp
@@ -17,31 +17,31 @@ TString Consume(const TString& input) {
UNIT_ASSERT_VALUES_EQUAL(input, output);
return md5Stream.Finalize();
}
-}
+} // namespace
Y_UNIT_TEST_SUITE(TStreamMd5Tests) {
- Y_UNIT_TEST(Empty) {
- const auto md5 = Consume("");
- const TString emptyStringMd5 = "d41d8cd98f00b204e9800998ecf8427e";
- UNIT_ASSERT_VALUES_EQUAL(md5, emptyStringMd5);
- }
+Y_UNIT_TEST(Empty) {
+ const auto md5 = Consume("");
+ const TString emptyStringMd5 = "d41d8cd98f00b204e9800998ecf8427e";
+ UNIT_ASSERT_VALUES_EQUAL(md5, emptyStringMd5);
+}
- Y_UNIT_TEST(ShortText) {
- const auto md5 = Consume("hello from Y!");
- const TString expectedMd5 = "abf59ed7b0daa71085e76e461a737cc2";
- UNIT_ASSERT_VALUES_EQUAL(md5, expectedMd5);
- }
+Y_UNIT_TEST(ShortText) {
+ const auto md5 = Consume("hello from Y!");
+ const TString expectedMd5 = "abf59ed7b0daa71085e76e461a737cc2";
+ UNIT_ASSERT_VALUES_EQUAL(md5, expectedMd5);
+}
- Y_UNIT_TEST(BigText) {
- // TransferData uses TempBuf of 64K
- const TString s(1000000, 'A');
- const auto md5 = Consume(s.c_str());
- /*
- $ for i in {1..1000000};do echo -n A >> 1M.txt;done
- $ md5sum 1M.txt
- 48fcdb8b87ce8ef779774199a856091d 1M.txt
- */
- const TString expectedMd5 = "48fcdb8b87ce8ef779774199a856091d";
- UNIT_ASSERT_VALUES_EQUAL(md5, expectedMd5);
- }
+Y_UNIT_TEST(BigText) {
+ // TransferData uses TempBuf of 64K
+ const TString s(1000000, 'A');
+ const auto md5 = Consume(s.c_str());
+ /*
+ $ for i in {1..1000000};do echo -n A >> 1M.txt;done
+ $ md5sum 1M.txt
+ 48fcdb8b87ce8ef779774199a856091d 1M.txt
+ */
+ const TString expectedMd5 = "48fcdb8b87ce8ef779774199a856091d";
+ UNIT_ASSERT_VALUES_EQUAL(md5, expectedMd5);
}
+} // Y_UNIT_TEST_SUITE(TStreamMd5Tests)
diff --git a/yql/essentials/utils/mem_limit.cpp b/yql/essentials/utils/mem_limit.cpp
index 87a0db833e3..6f03f796c82 100644
--- a/yql/essentials/utils/mem_limit.cpp
+++ b/yql/essentials/utils/mem_limit.cpp
@@ -1,5 +1,5 @@
#ifdef __unix__
-#include <sys/resource.h>
+ #include <sys/resource.h>
#endif
#include <util/generic/yexception.h>
@@ -9,21 +9,21 @@ namespace NYql {
void SetAddressSpaceLimit(ui64 memLimit) {
if (memLimit) {
- #ifdef __unix__
- auto memLimitBytes = memLimit * 1024 * 1024;
+#ifdef __unix__
+ auto memLimitBytes = memLimit * 1024 * 1024;
- struct rlimit rl;
- if (getrlimit(RLIMIT_AS, &rl)) {
- throw TSystemError() << "Cannot getrlimit(RLIMIT_AS)";
- }
+ struct rlimit rl;
+ if (getrlimit(RLIMIT_AS, &rl)) {
+ throw TSystemError() << "Cannot getrlimit(RLIMIT_AS)";
+ }
- rl.rlim_cur = memLimitBytes;
- if (setrlimit(RLIMIT_AS, &rl)) {
- throw TSystemError() << "Cannot setrlimit(RLIMIT_AS) to " << memLimitBytes << " bytes";
- }
- #else
- throw yexception() << "Memory limit can not be set on this platfrom";
- #endif
+ rl.rlim_cur = memLimitBytes;
+ if (setrlimit(RLIMIT_AS, &rl)) {
+ throw TSystemError() << "Cannot setrlimit(RLIMIT_AS) to " << memLimitBytes << " bytes";
+ }
+#else
+ throw yexception() << "Memory limit can not be set on this platfrom";
+#endif
}
}
diff --git a/yql/essentials/utils/memory_profiling/ya.make b/yql/essentials/utils/memory_profiling/ya.make
index 3e728ecbb83..2b74947d5b8 100644
--- a/yql/essentials/utils/memory_profiling/ya.make
+++ b/yql/essentials/utils/memory_profiling/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
IF (PROFILE_MEMORY_ALLOCATIONS)
CFLAGS(GLOBAL -DPROFILE_MEMORY_ALLOCATIONS)
CFLAGS(GLOBAL -DALLOW_DEFAULT_ALLOCATOR)
diff --git a/yql/essentials/utils/method_index.cpp b/yql/essentials/utils/method_index.cpp
index 16dd0e520be..704a17dc1e5 100644
--- a/yql/essentials/utils/method_index.cpp
+++ b/yql/essentials/utils/method_index.cpp
@@ -42,4 +42,4 @@ size_t GetMethodPtrIndex(uintptr_t ptr) {
#endif
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/method_index.h b/yql/essentials/utils/method_index.h
index 04944049c29..40be550b0ce 100644
--- a/yql/essentials/utils/method_index.h
+++ b/yql/essentials/utils/method_index.h
@@ -8,11 +8,11 @@ namespace NYql {
size_t GetMethodPtrIndex(uintptr_t ptr);
-template<typename Method>
+template <typename Method>
inline size_t GetMethodIndex(Method method) {
uintptr_t ptr;
std::memcpy(&ptr, &method, sizeof(uintptr_t));
return GetMethodPtrIndex(ptr);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/network/bind_in_range.cpp b/yql/essentials/utils/network/bind_in_range.cpp
index 88cf641ce39..3229ffad530 100644
--- a/yql/essentials/utils/network/bind_in_range.cpp
+++ b/yql/essentials/utils/network/bind_in_range.cpp
@@ -24,4 +24,4 @@ TVector<NBus::TBindResult> BindInRange(TRangeWalker<int>& portWalker) {
ythrow yexception() << "Unable to bind within port range [" << portWalker.GetStart() << ", " << portWalker.GetFinish() << "]";
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/network/bind_in_range.h b/yql/essentials/utils/network/bind_in_range.h
index 5621529dd52..83de399b1fa 100644
--- a/yql/essentials/utils/network/bind_in_range.h
+++ b/yql/essentials/utils/network/bind_in_range.h
@@ -5,4 +5,4 @@
namespace NYql {
TVector<NBus::TBindResult> BindInRange(TRangeWalker<int>& portWalker);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/network/ya.make b/yql/essentials/utils/network/ya.make
index 282e1502b3c..b123808aa48 100644
--- a/yql/essentials/utils/network/ya.make
+++ b/yql/essentials/utils/network/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
bind_in_range.cpp
bind_in_range.h
diff --git a/yql/essentials/utils/oom_helper/inject.cpp b/yql/essentials/utils/oom_helper/inject.cpp
index e0b6a2e0c8e..e4342813167 100644
--- a/yql/essentials/utils/oom_helper/inject.cpp
+++ b/yql/essentials/utils/oom_helper/inject.cpp
@@ -6,12 +6,11 @@
#include <stdio.h>
#include <sys/syscall.h>
-
#define SYSCALL_MMAP2_UNIT 4096ULL
#define UNIT SYSCALL_MMAP2_UNIT
-#define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | (UNIT-1))
+#define OFF_MASK ((-0x2000ULL << (8 * sizeof(long) - 1)) | (UNIT - 1))
-void *Mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
+void* Mmap(void* start, size_t len, int prot, int flags, int fd, off_t off)
{
void* ret = (void*)-1;
if (off & OFF_MASK) {
@@ -23,7 +22,7 @@ void *Mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
return ret;
}
#ifdef SYS_mmap2
- ret = (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
+ ret = (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off / UNIT);
#else
ret = (void*)syscall(SYS_mmap, start, len, prot, flags, fd, off);
#endif
@@ -36,11 +35,10 @@ void *Mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
return ret;
}
-
-void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
+void* mmap(void* start, size_t len, int prot, int flags, int fd, off_t off)
{
auto res = Mmap(start, len, prot, flags, fd, off);
- if (res == (void*) -1 && errno == ENOMEM) {
+ if (res == (void*)-1 && errno == ENOMEM) {
fprintf(stderr, "mmap failed with ENOMEM\n");
_exit(2);
}
diff --git a/yql/essentials/utils/oom_helper/ya.make b/yql/essentials/utils/oom_helper/ya.make
index 6049debee44..bc8dfa4d1d3 100644
--- a/yql/essentials/utils/oom_helper/ya.make
+++ b/yql/essentials/utils/oom_helper/ya.make
@@ -1,4 +1,5 @@
IF (OS_LINUX)
+ ENABLE(YQL_STYLE_CPP)
LIBRARY(oom_helper)
SRCS(inject.cpp)
END()
diff --git a/yql/essentials/utils/parse_double.cpp b/yql/essentials/utils/parse_double.cpp
index 90923160c55..a5cbebe50e6 100644
--- a/yql/essentials/utils/parse_double.cpp
+++ b/yql/essentials/utils/parse_double.cpp
@@ -16,7 +16,7 @@ bool GenericTryFloatFromString(TStringBuf buf, T& value) {
if (TryFromString(buf.data(), buf.size(), value)) {
return true;
}
-
+
const char* ptr = buf.data();
ui32 size = buf.size();
char sign = '+';
@@ -45,7 +45,7 @@ bool GenericTryFloatFromString(TStringBuf buf, T& value) {
return true;
}
-}
+} // namespace
float FloatFromString(TStringBuf buf) {
float result = 0;
@@ -73,4 +73,4 @@ bool TryDoubleFromString(TStringBuf buf, double& value) {
return GenericTryFloatFromString(buf, value);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/parse_double.h b/yql/essentials/utils/parse_double.h
index 61d1d940c96..85ca3b8560f 100644
--- a/yql/essentials/utils/parse_double.h
+++ b/yql/essentials/utils/parse_double.h
@@ -15,4 +15,4 @@ double DoubleFromString(TStringBuf buf);
bool TryFloatFromString(TStringBuf buf, float& value);
bool TryDoubleFromString(TStringBuf buf, double& value);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/parse_double_ut.cpp b/yql/essentials/utils/parse_double_ut.cpp
index 4aecf64f88b..b61594139c9 100644
--- a/yql/essentials/utils/parse_double_ut.cpp
+++ b/yql/essentials/utils/parse_double_ut.cpp
@@ -5,51 +5,51 @@ namespace NYql {
Y_UNIT_TEST_SUITE(TParseDouble) {
- template <typename T, typename F>
- void ParseAndCheck(TStringBuf buf, F f, T expected) {
- T result = 0;
- UNIT_ASSERT(f(buf, result));
- UNIT_ASSERT_DOUBLES_EQUAL(expected, result, 1e-6);
- }
+template <typename T, typename F>
+void ParseAndCheck(TStringBuf buf, F f, T expected) {
+ T result = 0;
+ UNIT_ASSERT(f(buf, result));
+ UNIT_ASSERT_DOUBLES_EQUAL(expected, result, 1e-6);
+}
- Y_UNIT_TEST(ExactValues) {
- ParseAndCheck(TStringBuf("nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
- ParseAndCheck(TStringBuf("nAn"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
+Y_UNIT_TEST(ExactValues) {
+ ParseAndCheck(TStringBuf("nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
+ ParseAndCheck(TStringBuf("nAn"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
- ParseAndCheck(TStringBuf("+nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
- ParseAndCheck(TStringBuf("+NAN"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
+ ParseAndCheck(TStringBuf("+nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
+ ParseAndCheck(TStringBuf("+NAN"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
- ParseAndCheck(TStringBuf("-nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
- ParseAndCheck(TStringBuf("-NaN"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
+ ParseAndCheck(TStringBuf("-nan"), TryFloatFromString, std::numeric_limits<float>::quiet_NaN());
+ ParseAndCheck(TStringBuf("-NaN"), TryDoubleFromString, std::numeric_limits<double>::quiet_NaN());
- ParseAndCheck(TStringBuf("inf"), TryFloatFromString, std::numeric_limits<float>::infinity());
- ParseAndCheck(TStringBuf("iNf"), TryDoubleFromString, std::numeric_limits<double>::infinity());
+ ParseAndCheck(TStringBuf("inf"), TryFloatFromString, std::numeric_limits<float>::infinity());
+ ParseAndCheck(TStringBuf("iNf"), TryDoubleFromString, std::numeric_limits<double>::infinity());
- ParseAndCheck(TStringBuf("+inf"), TryFloatFromString, std::numeric_limits<float>::infinity());
- ParseAndCheck(TStringBuf("+INF"), TryDoubleFromString, std::numeric_limits<double>::infinity());
+ ParseAndCheck(TStringBuf("+inf"), TryFloatFromString, std::numeric_limits<float>::infinity());
+ ParseAndCheck(TStringBuf("+INF"), TryDoubleFromString, std::numeric_limits<double>::infinity());
- ParseAndCheck(TStringBuf("-inf"), TryFloatFromString, -std::numeric_limits<float>::infinity());
- ParseAndCheck(TStringBuf("-InF"), TryDoubleFromString, -std::numeric_limits<double>::infinity());
+ ParseAndCheck(TStringBuf("-inf"), TryFloatFromString, -std::numeric_limits<float>::infinity());
+ ParseAndCheck(TStringBuf("-InF"), TryDoubleFromString, -std::numeric_limits<double>::infinity());
- ParseAndCheck<float>(TStringBuf("-12.3456"), TryFloatFromString, -12.3456);
- ParseAndCheck(TStringBuf("-12.3456"), TryDoubleFromString, -12.3456);
+ ParseAndCheck<float>(TStringBuf("-12.3456"), TryFloatFromString, -12.3456);
+ ParseAndCheck(TStringBuf("-12.3456"), TryDoubleFromString, -12.3456);
- ParseAndCheck<float>(TStringBuf("1.23e-2"), TryFloatFromString, 0.0123);
- ParseAndCheck(TStringBuf("1.23e-2"), TryDoubleFromString, 0.0123);
+ ParseAndCheck<float>(TStringBuf("1.23e-2"), TryFloatFromString, 0.0123);
+ ParseAndCheck(TStringBuf("1.23e-2"), TryDoubleFromString, 0.0123);
- UNIT_ASSERT_EQUAL(FloatFromString(TStringBuf("iNf")), std::numeric_limits<float>::infinity());
- UNIT_ASSERT_EQUAL(DoubleFromString(TStringBuf("iNf")), std::numeric_limits<float>::infinity());
- }
+ UNIT_ASSERT_EQUAL(FloatFromString(TStringBuf("iNf")), std::numeric_limits<float>::infinity());
+ UNIT_ASSERT_EQUAL(DoubleFromString(TStringBuf("iNf")), std::numeric_limits<float>::infinity());
+}
- Y_UNIT_TEST(Errors) {
- UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf("")), std::exception, "unable to parse float from ''");
- UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf("")), std::exception, "unable to parse double from ''");
+Y_UNIT_TEST(Errors) {
+ UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf("")), std::exception, "unable to parse float from ''");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf("")), std::exception, "unable to parse double from ''");
- UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf("info")), std::exception, "unable to parse float from 'info'");
- UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf("-nana")), std::exception, "unable to parse double from '-nana'");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf("info")), std::exception, "unable to parse float from 'info'");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf("-nana")), std::exception, "unable to parse double from '-nana'");
- UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf(nullptr)), std::exception, "unable to parse float from ''");
- UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf(nullptr)), std::exception, "unable to parse double from ''");
- }
-}
+ UNIT_ASSERT_EXCEPTION_CONTAINS(FloatFromString(TStringBuf(nullptr)), std::exception, "unable to parse float from ''");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(DoubleFromString(TStringBuf(nullptr)), std::exception, "unable to parse double from ''");
}
+} // Y_UNIT_TEST_SUITE(TParseDouble)
+} // namespace NYql
diff --git a/yql/essentials/utils/proc_alive.cpp b/yql/essentials/utils/proc_alive.cpp
index 7efb2584bcc..b81efa01eb7 100644
--- a/yql/essentials/utils/proc_alive.cpp
+++ b/yql/essentials/utils/proc_alive.cpp
@@ -7,7 +7,6 @@
#include <errno.h>
-
namespace NYql {
bool IsProcessAlive(TProcessId pid) {
@@ -33,5 +32,4 @@ bool IsProcessAlive(TProcessId pid) {
#endif
}
-} // NYql
-
+} // namespace NYql
diff --git a/yql/essentials/utils/proc_alive.h b/yql/essentials/utils/proc_alive.h
index c4b798b4ca6..2fc310f0817 100644
--- a/yql/essentials/utils/proc_alive.h
+++ b/yql/essentials/utils/proc_alive.h
@@ -6,4 +6,4 @@ namespace NYql {
bool IsProcessAlive(TProcessId pid);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/rand_guid.cpp b/yql/essentials/utils/rand_guid.cpp
index d89eefbd3b8..386706b85f5 100644
--- a/yql/essentials/utils/rand_guid.cpp
+++ b/yql/essentials/utils/rand_guid.cpp
@@ -29,4 +29,4 @@ TString TRandGuid::GenGuid() {
ui64 TRandGuid::GenNumber() {
return GetRnd().GenRand();
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/rand_guid.h b/yql/essentials/utils/rand_guid.h
index 30496bdd5f3..a19f02fcc99 100644
--- a/yql/essentials/utils/rand_guid.h
+++ b/yql/essentials/utils/rand_guid.h
@@ -23,8 +23,8 @@ private:
}
private:
- std::aligned_storage<sizeof(TMersenne<ui64>) ,alignof(TMersenne<ui64>)>::type Rnd_;
+ std::aligned_storage<sizeof(TMersenne<ui64>), alignof(TMersenne<ui64>)>::type Rnd_;
static TAtomic Counter;
};
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/range_walker.h b/yql/essentials/utils/range_walker.h
index 268fe364728..74805fb28d1 100644
--- a/yql/essentials/utils/range_walker.h
+++ b/yql/essentials/utils/range_walker.h
@@ -44,4 +44,4 @@ public:
return result;
}
};
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/range_walker_ut.cpp b/yql/essentials/utils/range_walker_ut.cpp
index d6a86cc8048..8bbb34cec86 100644
--- a/yql/essentials/utils/range_walker_ut.cpp
+++ b/yql/essentials/utils/range_walker_ut.cpp
@@ -5,31 +5,31 @@
using namespace NYql;
Y_UNIT_TEST_SUITE(TRangeWalkerTests) {
- Y_UNIT_TEST(InvalidRange) {
- UNIT_ASSERT_EXCEPTION_CONTAINS(TRangeWalker<int>(2, 1), yexception, "Invalid range for walker");
- }
+Y_UNIT_TEST(InvalidRange) {
+ UNIT_ASSERT_EXCEPTION_CONTAINS(TRangeWalker<int>(2, 1), yexception, "Invalid range for walker");
+}
- Y_UNIT_TEST(SingleValueRange) {
- TRangeWalker<int> w(5, 5);
- UNIT_ASSERT_EQUAL(5, w.GetStart());
- UNIT_ASSERT_EQUAL(5, w.GetFinish());
- UNIT_ASSERT_EQUAL(1, w.GetRangeSize());
+Y_UNIT_TEST(SingleValueRange) {
+ TRangeWalker<int> w(5, 5);
+ UNIT_ASSERT_EQUAL(5, w.GetStart());
+ UNIT_ASSERT_EQUAL(5, w.GetFinish());
+ UNIT_ASSERT_EQUAL(1, w.GetRangeSize());
- for (int i = 0; i < 10; ++i) {
- UNIT_ASSERT_EQUAL(5, w.MoveToNext());
- }
+ for (int i = 0; i < 10; ++i) {
+ UNIT_ASSERT_EQUAL(5, w.MoveToNext());
}
+}
- Y_UNIT_TEST(ManyValuesRange) {
- TRangeWalker<int> w(5, 7);
- UNIT_ASSERT_EQUAL(5, w.GetStart());
- UNIT_ASSERT_EQUAL(7, w.GetFinish());
- UNIT_ASSERT_EQUAL(3, w.GetRangeSize());
+Y_UNIT_TEST(ManyValuesRange) {
+ TRangeWalker<int> w(5, 7);
+ UNIT_ASSERT_EQUAL(5, w.GetStart());
+ UNIT_ASSERT_EQUAL(7, w.GetFinish());
+ UNIT_ASSERT_EQUAL(3, w.GetRangeSize());
- for (int i = 0; i < 10; ++i) {
- UNIT_ASSERT_EQUAL(5, w.MoveToNext());
- UNIT_ASSERT_EQUAL(6, w.MoveToNext());
- UNIT_ASSERT_EQUAL(7, w.MoveToNext());
- }
+ for (int i = 0; i < 10; ++i) {
+ UNIT_ASSERT_EQUAL(5, w.MoveToNext());
+ UNIT_ASSERT_EQUAL(6, w.MoveToNext());
+ UNIT_ASSERT_EQUAL(7, w.MoveToNext());
}
}
+} // Y_UNIT_TEST_SUITE(TRangeWalkerTests)
diff --git a/yql/essentials/utils/resetable_setting.h b/yql/essentials/utils/resetable_setting.h
index 0112105a3bf..21bba878f06 100644
--- a/yql/essentials/utils/resetable_setting.h
+++ b/yql/essentials/utils/resetable_setting.h
@@ -64,4 +64,4 @@ public:
}
};
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/retry.h b/yql/essentials/utils/retry.h
index aa8391fa48d..ab6d9bf809a 100644
--- a/yql/essentials/utils/retry.h
+++ b/yql/essentials/utils/retry.h
@@ -14,4 +14,4 @@ auto WithRetry(int attempts, TAction&& a, TExceptionHandler&& exceptionHandler)
return a();
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/retry_ut.cpp b/yql/essentials/utils/retry_ut.cpp
index 47cb35fd739..d3d42265180 100644
--- a/yql/essentials/utils/retry_ut.cpp
+++ b/yql/essentials/utils/retry_ut.cpp
@@ -6,68 +6,63 @@ using namespace NYql;
namespace {
-class TMyError : public yexception {
+class TMyError: public yexception {
};
-}
+} // namespace
Y_UNIT_TEST_SUITE(TRetryTests) {
- Y_UNIT_TEST(ZeroAttempts) {
- auto r = WithRetry<TMyError>(0,
- []() { return TString("abc"); },
- [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); });
+Y_UNIT_TEST(ZeroAttempts) {
+ auto r = WithRetry<TMyError>(0,
+ []() { return TString("abc"); },
+ [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); });
- UNIT_ASSERT_VALUES_EQUAL("abc", r);
- }
+ UNIT_ASSERT_VALUES_EQUAL("abc", r);
+}
- Y_UNIT_TEST(NoRetries) {
- auto r = WithRetry<TMyError>(5,
- []() { return TString("abc"); },
- [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); });
+Y_UNIT_TEST(NoRetries) {
+ auto r = WithRetry<TMyError>(5,
+ []() { return TString("abc"); },
+ [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); });
- UNIT_ASSERT_VALUES_EQUAL("abc", r);
- }
+ UNIT_ASSERT_VALUES_EQUAL("abc", r);
+}
- Y_UNIT_TEST(NoRetriesButException) {
- UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(5,
- []() { throw yexception() << "xxxx"; },
- [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); }), yexception, "xxxx");
- }
+Y_UNIT_TEST(NoRetriesButException) {
+ UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(5,
+ []() { throw yexception() << "xxxx"; },
+ [](auto, auto, auto) { UNIT_FAIL("Exception handler invoked"); }), yexception, "xxxx");
+}
- Y_UNIT_TEST(FewRetries) {
- int counter = 0;
- int exceptions = 0;
- auto r = WithRetry<TMyError>(3, [&]() {
+Y_UNIT_TEST(FewRetries) {
+ int counter = 0;
+ int exceptions = 0;
+ auto r = WithRetry<TMyError>(3, [&]() {
if (counter++ < 2) {
throw TMyError() << "yyyy";
}
- return counter;
- }, [&](const auto& e, int attempt, int attemptCount) {
+ return counter; }, [&](const auto& e, int attempt, int attemptCount) {
++exceptions;
UNIT_ASSERT_VALUES_EQUAL(e.what(), "yyyy");
UNIT_ASSERT_VALUES_EQUAL(attempt, counter);
- UNIT_ASSERT_VALUES_EQUAL(attemptCount, 3);
- });
+ UNIT_ASSERT_VALUES_EQUAL(attemptCount, 3); });
- UNIT_ASSERT_VALUES_EQUAL(2, exceptions);
- UNIT_ASSERT_VALUES_EQUAL(3, r);
- UNIT_ASSERT_VALUES_EQUAL(3, counter);
- }
+ UNIT_ASSERT_VALUES_EQUAL(2, exceptions);
+ UNIT_ASSERT_VALUES_EQUAL(3, r);
+ UNIT_ASSERT_VALUES_EQUAL(3, counter);
+}
- Y_UNIT_TEST(ManyRetries) {
- int counter = 0;
- int exceptions = 0;
- UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(3, [&]() {
- throw TMyError() << "yyyy" << counter++;
- }, [&](const auto& e, int attempt, int attemptCount) {
+Y_UNIT_TEST(ManyRetries) {
+ int counter = 0;
+ int exceptions = 0;
+ UNIT_ASSERT_EXCEPTION_CONTAINS(WithRetry<TMyError>(3, [&]() { throw TMyError() << "yyyy" << counter++; }, [&](const auto& e, int attempt, int attemptCount) {
++exceptions;
UNIT_ASSERT_STRING_CONTAINS(e.what(), "yyyy");
UNIT_ASSERT_VALUES_EQUAL(attempt, counter);
- UNIT_ASSERT_VALUES_EQUAL(attemptCount, 3);
- }), TMyError, "yyyy2");
+ UNIT_ASSERT_VALUES_EQUAL(attemptCount, 3); }), TMyError, "yyyy2");
- UNIT_ASSERT_VALUES_EQUAL(2, exceptions);
- UNIT_ASSERT_VALUES_EQUAL(3, counter);
- }
+ UNIT_ASSERT_VALUES_EQUAL(2, exceptions);
+ UNIT_ASSERT_VALUES_EQUAL(3, counter);
}
+} // Y_UNIT_TEST_SUITE(TRetryTests)
diff --git a/yql/essentials/utils/signals/signals.cpp b/yql/essentials/utils/signals/signals.cpp
index bb22e266240..6d3a3c05f7e 100644
--- a/yql/essentials/utils/signals/signals.cpp
+++ b/yql/essentials/utils/signals/signals.cpp
@@ -10,7 +10,7 @@
#include <util/system/getpid.h>
#ifdef _linux_
-# include <sys/prctl.h>
+ #include <sys/prctl.h>
#endif
#include <string.h>
@@ -18,7 +18,6 @@
#include <errno.h>
#include <stdlib.h>
-
namespace NYql {
volatile sig_atomic_t NeedTerminate = 0;
@@ -38,41 +37,41 @@ namespace {
void SignalHandler(int signo)
{
switch (signo) {
- case SIGTERM:
- NeedTerminate = 1;
- break;
+ case SIGTERM:
+ NeedTerminate = 1;
+ break;
- case SIGQUIT:
- NeedQuit = 1;
- break;
+ case SIGQUIT:
+ NeedQuit = 1;
+ break;
#ifdef _unix_
- case SIGHUP:
- NeedReconfigure = 1;
- break;
+ case SIGHUP:
+ NeedReconfigure = 1;
+ break;
- case SIGUSR1:
- NeedReopenLog = 1;
- break;
+ case SIGUSR1:
+ NeedReopenLog = 1;
+ break;
- case SIGCHLD:
- NeedReapZombies = 1;
- break;
+ case SIGCHLD:
+ NeedReapZombies = 1;
+ break;
#endif
- case SIGINT:
- if (CatchInterrupt) {
- NeedInterrupt = 1;
- } else {
- fprintf(stderr, "%s (pid=%d) captured SIGINT\n",
- GetProcTitle(), getpid());
- signal(signo, SIG_DFL);
- raise(signo);
- }
- break;
-
- default:
- break;
+ case SIGINT:
+ if (CatchInterrupt) {
+ NeedInterrupt = 1;
+ } else {
+ fprintf(stderr, "%s (pid=%d) captured SIGINT\n",
+ GetProcTitle(), getpid());
+ signal(signo, SIG_DFL);
+ raise(signo);
+ }
+ break;
+
+ default:
+ break;
}
}
@@ -84,7 +83,7 @@ void SignalHandlerWithSelfPipe(int signo)
if (write(SignalPipeW.GetHandle(), "x", 1) == -1 && errno != EAGAIN) {
static TStringBuf msg("cannot write to signal pipe");
#ifndef STDERR_FILENO
-#define STDERR_FILENO 2
+ #define STDERR_FILENO 2
#endif
write(STDERR_FILENO, msg.data(), msg.size());
abort();
@@ -92,21 +91,22 @@ void SignalHandlerWithSelfPipe(int signo)
errno = savedErrno;
}
-
#ifndef _unix_
const char* strsignal(int signo)
{
switch (signo) {
- case SIGTERM: return "SIGTERM";
- case SIGINT: return "SIGINT";
- case SIGQUIT: return "SIGQUIT";
- default:
- return "UNKNOWN";
+ case SIGTERM:
+ return "SIGTERM";
+ case SIGINT:
+ return "SIGINT";
+ case SIGQUIT:
+ return "SIGQUIT";
+ default:
+ return "UNKNOWN";
}
}
#endif
-
#ifdef _unix_
int SetSignalHandler(int signo, void (*handler)(int))
{
@@ -126,8 +126,7 @@ int SetSignalHandler(int signo, void (*handler)(int))
#endif
-struct TSignalHandlerDesc
-{
+struct TSignalHandlerDesc {
int Signo;
void (*Handler)(int);
};
@@ -156,21 +155,19 @@ void SetSignalHandlers(const TSignalHandlerDesc* handlerDescs)
} // namespace
-
void InitSignals()
{
TSignalHandlerDesc handlerDescs[] = {
- { SIGTERM, SignalHandler },
- { SIGINT, SignalHandler },
- { SIGQUIT, SignalHandler },
+ {SIGTERM, SignalHandler},
+ {SIGINT, SignalHandler},
+ {SIGQUIT, SignalHandler},
#ifdef _unix_
- { SIGPIPE, SIG_IGN },
- { SIGHUP, SignalHandler },
- { SIGUSR1, SignalHandler },
- { SIGCHLD, SignalHandler },
+ {SIGPIPE, SIG_IGN},
+ {SIGHUP, SignalHandler},
+ {SIGUSR1, SignalHandler},
+ {SIGCHLD, SignalHandler},
#endif
- { -1, nullptr }
- };
+ {-1, nullptr}};
SetSignalHandlers(handlerDescs);
}
@@ -178,17 +175,16 @@ void InitSignals()
void InitSignalsWithSelfPipe()
{
TSignalHandlerDesc handlerDescs[] = {
- { SIGTERM, SignalHandlerWithSelfPipe },
- { SIGINT, SignalHandlerWithSelfPipe },
- { SIGQUIT, SignalHandlerWithSelfPipe },
+ {SIGTERM, SignalHandlerWithSelfPipe},
+ {SIGINT, SignalHandlerWithSelfPipe},
+ {SIGQUIT, SignalHandlerWithSelfPipe},
#ifdef _unix_
- { SIGPIPE, SIG_IGN },
- { SIGHUP, SignalHandlerWithSelfPipe },
- { SIGUSR1, SignalHandlerWithSelfPipe },
- { SIGCHLD, SignalHandlerWithSelfPipe },
+ {SIGPIPE, SIG_IGN},
+ {SIGHUP, SignalHandlerWithSelfPipe},
+ {SIGUSR1, SignalHandlerWithSelfPipe},
+ {SIGCHLD, SignalHandlerWithSelfPipe},
#endif
- { -1, nullptr }
- };
+ {-1, nullptr}};
TPipe::Pipe(SignalPipeR, SignalPipeW);
SetNonBlock(SignalPipeR.GetHandle());
diff --git a/yql/essentials/utils/signals/signals.h b/yql/essentials/utils/signals/signals.h
index 612f9062072..3a10ad04578 100644
--- a/yql/essentials/utils/signals/signals.h
+++ b/yql/essentials/utils/signals/signals.h
@@ -6,7 +6,6 @@
#include <signal.h>
-
namespace NYql {
#ifdef _win_
diff --git a/yql/essentials/utils/signals/utils.cpp b/yql/essentials/utils/signals/utils.cpp
index b1de131b30f..f8f0dd00cea 100644
--- a/yql/essentials/utils/signals/utils.cpp
+++ b/yql/essentials/utils/signals/utils.cpp
@@ -73,7 +73,9 @@ void ProcTitleInit(int argc, const char* argv[])
void SetProcTitle(const char* title)
{
- if (!g_OriginalArgv) return;
+ if (!g_OriginalArgv) {
+ return;
+ }
char* p = g_OriginalArgv[0];
p += strlcpy(p, "yqlworker: ", g_OriginalArgvLast - p);
@@ -88,7 +90,9 @@ void SetProcTitle(const char* title)
void AddProcTitleSuffix(const char* suffix)
{
- if (!g_OriginalArgv) return;
+ if (!g_OriginalArgv) {
+ return;
+ }
char* p = g_OriginalArgv[0];
p += strlcat(p, " ", g_OriginalArgvLast - p);
diff --git a/yql/essentials/utils/signals/utils.h b/yql/essentials/utils/signals/utils.h
index 75c55244fac..845695e3469 100644
--- a/yql/essentials/utils/signals/utils.h
+++ b/yql/essentials/utils/signals/utils.h
@@ -4,7 +4,7 @@
namespace google {
namespace protobuf {
- class Message;
+class Message;
} // namespace protobuf
} // namespace google
diff --git a/yql/essentials/utils/signals/ya.make b/yql/essentials/utils/signals/ya.make
index 9a2ab2d0204..8d69ae7c088 100644
--- a/yql/essentials/utils/signals/ya.make
+++ b/yql/essentials/utils/signals/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
signals.cpp
signals.h
diff --git a/yql/essentials/utils/sort.cpp b/yql/essentials/utils/sort.cpp
index 67992aff39b..a5a69fa930f 100644
--- a/yql/essentials/utils/sort.cpp
+++ b/yql/essentials/utils/sort.cpp
@@ -1 +1 @@
-#include "sort.h" \ No newline at end of file
+#include "sort.h"
diff --git a/yql/essentials/utils/sort.h b/yql/essentials/utils/sort.h
index 4adb7c9225d..06e9584486b 100644
--- a/yql/essentials/utils/sort.h
+++ b/yql/essentials/utils/sort.h
@@ -24,4 +24,4 @@ void FastPartialSort(RandomIt first, RandomIt middle, RandomIt last, Compare com
::miniselect::floyd_rivest_partial_sort(first, middle, last, compare);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/swap_bytes.h b/yql/essentials/utils/swap_bytes.h
index bf09bb321ab..90f12cab341 100644
--- a/yql/essentials/utils/swap_bytes.h
+++ b/yql/essentials/utils/swap_bytes.h
@@ -6,8 +6,7 @@ namespace NYql {
// clang generates bswap for ui32 and ui64
template <typename TUnsigned>
-Y_FORCE_INLINE
-TUnsigned SwapBytes(TUnsigned value) {
+Y_FORCE_INLINE TUnsigned SwapBytes(TUnsigned value) {
TUnsigned result;
auto* from = (ui8*)&value + sizeof(TUnsigned) - 1;
auto* to = (ui8*)&result;
@@ -17,4 +16,4 @@ TUnsigned SwapBytes(TUnsigned value) {
return result;
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/sys/become_user.cpp b/yql/essentials/utils/sys/become_user.cpp
index bbb6b5735ca..af24dc0d555 100644
--- a/yql/essentials/utils/sys/become_user.cpp
+++ b/yql/essentials/utils/sys/become_user.cpp
@@ -1,29 +1,29 @@
#include "become_user.h"
#ifdef _linux_
-#include <yql/essentials/utils/sys/linux_version.h>
+ #include <yql/essentials/utils/sys/linux_version.h>
-#include <util/generic/yexception.h>
-#include <util/system/user.h>
+ #include <util/generic/yexception.h>
+ #include <util/system/user.h>
-#include <memory>
-#include <vector>
-#include <errno.h>
+ #include <memory>
+ #include <vector>
+ #include <errno.h>
-#include <grp.h>
-#include <pwd.h>
-#include <unistd.h>
+ #include <grp.h>
+ #include <pwd.h>
+ #include <unistd.h>
-#include <sys/prctl.h>
-#include <contrib/libs/libcap/include/sys/capability.h>
-#include <contrib/libs/libcap/include/sys/securebits.h>
+ #include <sys/prctl.h>
+ #include <contrib/libs/libcap/include/sys/capability.h>
+ #include <contrib/libs/libcap/include/sys/securebits.h>
-// strange, but sometimes we have to specify values manually
-#define PR_CAP_AMBIENT 47
-#define PR_CAP_AMBIENT_IS_SET 1
-#define PR_CAP_AMBIENT_RAISE 2
-#define PR_CAP_AMBIENT_LOWER 3
-#define PR_CAP_AMBIENT_CLEAR_ALL 4
+ // strange, but sometimes we have to specify values manually
+ #define PR_CAP_AMBIENT 47
+ #define PR_CAP_AMBIENT_IS_SET 1
+ #define PR_CAP_AMBIENT_RAISE 2
+ #define PR_CAP_AMBIENT_LOWER 3
+ #define PR_CAP_AMBIENT_CLEAR_ALL 4
namespace NYql {
@@ -90,7 +90,7 @@ void EnsureCapFlagsVectorCannotBeRaised(const std::vector<cap_value_t>& flags) {
for (auto f : flags) {
try {
// one-by-one
- SetCapFlagsVector({ f });
+ SetCapFlagsVector({f});
} catch (const TSystemError&) {
continue;
}
@@ -141,14 +141,14 @@ void DoBecomeUser(const char* username, const char* groupname) {
}
}
-}
+} // namespace
void BecomeUser(const TString& username, const TString& groupname) {
DoBecomeUser(username.data(), groupname.data());
}
void TurnOnBecomeUserAmbientCaps() {
- SetCapFlagsVector({ CAP_SETUID, CAP_SETGID, CAP_SETPCAP, CAP_KILL });
+ SetCapFlagsVector({CAP_SETUID, CAP_SETGID, CAP_SETPCAP, CAP_KILL});
if (prctl(PR_SET_SECUREBITS, SECBIT_NO_SETUID_FIXUP | SECBIT_NO_SETUID_FIXUP_LOCKED, 0, 0, 0) == -1) {
ythrow TSystemError() << "can't set secure bits for a process";
}
@@ -157,7 +157,7 @@ void TurnOnBecomeUserAmbientCaps() {
void TurnOffBecomeUserAbility() {
ClearAmbientCapFlags();
SetCapFlagsVector({});
- EnsureCapFlagsVectorCannotBeRaised({ CAP_SETUID, CAP_SETGID, CAP_SETPCAP, CAP_KILL });
+ EnsureCapFlagsVectorCannotBeRaised({CAP_SETUID, CAP_SETGID, CAP_SETPCAP, CAP_KILL});
// ensure we cannot get root access back
if (setuid(0) != -1) {
@@ -183,6 +183,6 @@ void SendSignalOnParentThreadExit(int signo)
}
}
-}
+} // namespace NYql
#endif
diff --git a/yql/essentials/utils/sys/become_user.h b/yql/essentials/utils/sys/become_user.h
index c5c2025d8b3..dc7710e2dba 100644
--- a/yql/essentials/utils/sys/become_user.h
+++ b/yql/essentials/utils/sys/become_user.h
@@ -23,4 +23,4 @@ void DumpCaps(const TString& title);
// subscribe child process on receiving signal on parent process death (particularly on parent thread exit)
void SendSignalOnParentThreadExit(int signo);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/sys/become_user_dummy.cpp b/yql/essentials/utils/sys/become_user_dummy.cpp
index 897d9c39774..ef8ca8ccafa 100644
--- a/yql/essentials/utils/sys/become_user_dummy.cpp
+++ b/yql/essentials/utils/sys/become_user_dummy.cpp
@@ -22,5 +22,5 @@ void SendSignalOnParentThreadExit(int signo)
Y_UNUSED(signo);
}
-}
+} // namespace NYql
#endif
diff --git a/yql/essentials/utils/sys/linux_version.cpp b/yql/essentials/utils/sys/linux_version.cpp
index 5d10af82948..e2be5fcce40 100644
--- a/yql/essentials/utils/sys/linux_version.cpp
+++ b/yql/essentials/utils/sys/linux_version.cpp
@@ -4,43 +4,43 @@
#include <util/system/platform.h>
#ifdef _linux_
-# include <sys/utsname.h>
+ #include <sys/utsname.h>
#endif
namespace NYql {
- std::tuple<int, int, int> DetectLinuxKernelVersion3() {
+std::tuple<int, int, int> DetectLinuxKernelVersion3() {
#ifdef _linux_
- // see https://github.com/torvalds/linux/blob/master/Makefile
- // version is composed as follows:
- // VERSION = 4
- // PATCHLEVEL = 18
- // SUBLEVEL = 0
- // EXTRAVERSION = -rc4
- // KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
+ // see https://github.com/torvalds/linux/blob/master/Makefile
+ // version is composed as follows:
+ // VERSION = 4
+ // PATCHLEVEL = 18
+ // SUBLEVEL = 0
+ // EXTRAVERSION = -rc4
+ // KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
- utsname buf = {};
- if (uname(&buf)) {
- ythrow TSystemError() << "uname call failed";
- }
+ utsname buf = {};
+ if (uname(&buf)) {
+ ythrow TSystemError() << "uname call failed";
+ }
- int v = 0;
- int p = 0;
- int s = 0;
- if (sscanf(buf.release, "%d.%d.%d", &v, &p, &s) != 3) {
- ythrow yexception() << "Failed to parse linux kernel version " << buf.release;
- }
- return std::make_tuple(v, p, s);
+ int v = 0;
+ int p = 0;
+ int s = 0;
+ if (sscanf(buf.release, "%d.%d.%d", &v, &p, &s) != 3) {
+ ythrow yexception() << "Failed to parse linux kernel version " << buf.release;
+ }
+ return std::make_tuple(v, p, s);
#else
- return {};
+ return {};
#endif
- }
+}
- std::pair<int, int> DetectLinuxKernelVersion2() {
- auto v = DetectLinuxKernelVersion3();
- return std::make_pair(std::get<0>(v), std::get<1>(v));
- }
+std::pair<int, int> DetectLinuxKernelVersion2() {
+ auto v = DetectLinuxKernelVersion3();
+ return std::make_pair(std::get<0>(v), std::get<1>(v));
+}
- bool IsLinuxKernelBelow4_3() {
- return DetectLinuxKernelVersion2() < std::make_pair(4, 3);
- }
+bool IsLinuxKernelBelow4_3() {
+ return DetectLinuxKernelVersion2() < std::make_pair(4, 3);
}
+} // namespace NYql
diff --git a/yql/essentials/utils/sys/linux_version.h b/yql/essentials/utils/sys/linux_version.h
index 7ae893d257d..567c92bedb3 100644
--- a/yql/essentials/utils/sys/linux_version.h
+++ b/yql/essentials/utils/sys/linux_version.h
@@ -3,11 +3,11 @@
#include <tuple>
namespace NYql {
- // returns version, patch level, sublevel, e.g. (4, 4, 114) for `uname -r` == "4.4.114-50"
- std::tuple<int, int, int> DetectLinuxKernelVersion3();
+// returns version, patch level, sublevel, e.g. (4, 4, 114) for `uname -r` == "4.4.114-50"
+std::tuple<int, int, int> DetectLinuxKernelVersion3();
- // returns version, patch level
- std::pair<int, int> DetectLinuxKernelVersion2();
+// returns version, patch level
+std::pair<int, int> DetectLinuxKernelVersion2();
- bool IsLinuxKernelBelow4_3(); // NOLINT(readability-identifier-naming)
-}
+bool IsLinuxKernelBelow4_3(); // NOLINT(readability-identifier-naming)
+} // namespace NYql
diff --git a/yql/essentials/utils/sys/ya.make b/yql/essentials/utils/sys/ya.make
index 698aeb8ba8c..b1d6f8be96c 100644
--- a/yql/essentials/utils/sys/ya.make
+++ b/yql/essentials/utils/sys/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
become_user.h
become_user_dummy.cpp
diff --git a/yql/essentials/utils/test_http_server/test_http_server.cpp b/yql/essentials/utils/test_http_server/test_http_server.cpp
index 5d55230c410..aa4c48badaf 100644
--- a/yql/essentials/utils/test_http_server/test_http_server.cpp
+++ b/yql/essentials/utils/test_http_server/test_http_server.cpp
@@ -7,8 +7,8 @@
namespace NYql {
-class TTestHttpServer::TImpl : public THttpServer::ICallBack {
- class TRequestProcessor : public THttpClientRequestEx {
+class TTestHttpServer::TImpl: public THttpServer::ICallBack {
+ class TRequestProcessor: public THttpClientRequestEx {
public:
explicit TRequestProcessor(TImpl* parent)
: Parent_(parent)
@@ -46,20 +46,20 @@ class TTestHttpServer::TImpl : public THttpServer::ICallBack {
auto reply = Parent_->ProcessNextRequest(r);
switch (reply.Code) {
- case HTTP_OK:
- Output() << "HTTP/1.1 200 Ok\r\n";
- break;
+ case HTTP_OK:
+ Output() << "HTTP/1.1 200 Ok\r\n";
+ break;
- case HTTP_NOT_MODIFIED:
- Output() << "HTTP/1.1 304 Not modified\r\n";
- break;
+ case HTTP_NOT_MODIFIED:
+ Output() << "HTTP/1.1 304 Not modified\r\n";
+ break;
- case HTTP_FORBIDDEN:
- Output() << "HTTP/1.1 403 Forbidden\r\n";
- break;
+ case HTTP_FORBIDDEN:
+ Output() << "HTTP/1.1 403 Forbidden\r\n";
+ break;
- default:
- return true;
+ default:
+ return true;
}
if (reply.ETag) {
@@ -94,7 +94,6 @@ public:
: HttpServer_(this, THttpServer::TOptions(port))
, Port_(port)
{
-
}
TClientRequest* CreateClient() override {
@@ -129,7 +128,8 @@ private:
};
TTestHttpServer::TTestHttpServer(int port)
- : Impl_(new TImpl(port)) {
+ : Impl_(new TImpl(port))
+{
}
TTestHttpServer::~TTestHttpServer() {
@@ -148,4 +148,4 @@ void TTestHttpServer::SetRequestHandler(TRequestHandler handler) {
return Impl_->SetRequestHandler(std::move(handler));
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/test_http_server/test_http_server.h b/yql/essentials/utils/test_http_server/test_http_server.h
index 385cfaf9706..762278eee86 100644
--- a/yql/essentials/utils/test_http_server/test_http_server.h
+++ b/yql/essentials/utils/test_http_server/test_http_server.h
@@ -74,4 +74,4 @@ private:
THolder<TImpl> Impl_;
};
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/test_http_server/ya.make b/yql/essentials/utils/test_http_server/ya.make
index 41c6710c5f9..9f4b1b02d0b 100644
--- a/yql/essentials/utils/test_http_server/ya.make
+++ b/yql/essentials/utils/test_http_server/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
test_http_server.cpp
)
diff --git a/yql/essentials/utils/threading/async_queue.cpp b/yql/essentials/utils/threading/async_queue.cpp
index 4021636b552..c910c68ef60 100644
--- a/yql/essentials/utils/threading/async_queue.cpp
+++ b/yql/essentials/utils/threading/async_queue.cpp
@@ -15,4 +15,4 @@ TAsyncQueue::TPtr TAsyncQueue::Make(size_t numThreads, const TString& poolName)
return new TAsyncQueue(numThreads, poolName);
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/threading/async_queue.h b/yql/essentials/utils/threading/async_queue.h
index 3dd75b9e08a..4c2b43aeca7 100644
--- a/yql/essentials/utils/threading/async_queue.h
+++ b/yql/essentials/utils/threading/async_queue.h
@@ -48,4 +48,4 @@ private:
THolder<IThreadPool> MtpQueue_;
};
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/threading/ya.make b/yql/essentials/utils/threading/ya.make
index d1cd6291a70..c68c12323ea 100644
--- a/yql/essentials/utils/threading/ya.make
+++ b/yql/essentials/utils/threading/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
async_queue.cpp
)
diff --git a/yql/essentials/utils/tty.cpp b/yql/essentials/utils/tty.cpp
index 57db2d9bf31..53dacef2f07 100644
--- a/yql/essentials/utils/tty.cpp
+++ b/yql/essentials/utils/tty.cpp
@@ -2,10 +2,10 @@
#include <util/system/platform.h>
#ifdef _win_
-#include <io.h>
-#include <stdio.h>
+ #include <io.h>
+ #include <stdio.h>
#else
-#include <unistd.h>
+ #include <unistd.h>
#endif
namespace NYql {
@@ -13,21 +13,21 @@ namespace NYql {
bool IsTty(EStdStream stream) {
#ifdef _win_
switch (stream) {
- case EStdStream::In:
- return _isatty(_fileno(stdin));
- case EStdStream::Out:
- return _isatty(_fileno(stdout));
- case EStdStream::Err:
- return _isatty(_fileno(stderr));
+ case EStdStream::In:
+ return _isatty(_fileno(stdin));
+ case EStdStream::Out:
+ return _isatty(_fileno(stdout));
+ case EStdStream::Err:
+ return _isatty(_fileno(stderr));
}
#else
switch (stream) {
- case EStdStream::In:
- return isatty(STDIN_FILENO);
- case EStdStream::Out:
- return isatty(STDOUT_FILENO);
- case EStdStream::Err:
- return isatty(STDERR_FILENO);
+ case EStdStream::In:
+ return isatty(STDIN_FILENO);
+ case EStdStream::Out:
+ return isatty(STDOUT_FILENO);
+ case EStdStream::Err:
+ return isatty(STDERR_FILENO);
}
#endif
}
diff --git a/yql/essentials/utils/url_builder.cpp b/yql/essentials/utils/url_builder.cpp
index e8a55561e84..a5c21ee9843 100644
--- a/yql/essentials/utils/url_builder.cpp
+++ b/yql/essentials/utils/url_builder.cpp
@@ -10,7 +10,7 @@ TUrlBuilder::TUrlBuilder(const TString& uri)
}
TUrlBuilder& TUrlBuilder::AddUrlParam(const TString& name, const TString& value) {
- Params_.emplace_back(TParam {name, value});
+ Params_.emplace_back(TParam{name, value});
return *this;
}
@@ -47,4 +47,4 @@ TString TUrlBuilder::Build() const {
return std::move(res);
}
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/url_builder.h b/yql/essentials/utils/url_builder.h
index c4d4cfb7854..f4beee9c1fd 100644
--- a/yql/essentials/utils/url_builder.h
+++ b/yql/essentials/utils/url_builder.h
@@ -10,6 +10,7 @@ class TUrlBuilder {
TString Name;
TString Value;
};
+
public:
explicit TUrlBuilder(const TString& uri);
@@ -18,9 +19,10 @@ public:
TUrlBuilder& AddPathComponent(const TString& value);
TString Build() const;
+
private:
std::vector<TParam> Params_;
TString MainUri_;
};
-} // NYql
+} // namespace NYql
diff --git a/yql/essentials/utils/url_builder_ut.cpp b/yql/essentials/utils/url_builder_ut.cpp
index ad15a916982..e4ec9b5e5d2 100644
--- a/yql/essentials/utils/url_builder_ut.cpp
+++ b/yql/essentials/utils/url_builder_ut.cpp
@@ -5,53 +5,53 @@
using namespace NYql;
Y_UNIT_TEST_SUITE(TUrlBuilder) {
- Y_UNIT_TEST(UriOnly) {
- TUrlBuilder builder("https://localhost/abc");
- UNIT_ASSERT_VALUES_EQUAL(builder.Build(), "https://localhost/abc");
- }
-
- Y_UNIT_TEST(Basic) {
- TUrlBuilder builder("https://localhost/abc");
- builder.AddUrlParam("param1", "val1");
- builder.AddUrlParam("param2", "val2");
-
- UNIT_ASSERT_VALUES_EQUAL(builder.Build(), "https://localhost/abc?param1=val1&param2=val2");
- }
-
- Y_UNIT_TEST(BasicWithEncoding) {
- auto url = TUrlBuilder("https://localhost/abc")
- .AddUrlParam("param1", "=!@#$%^&*(){}[]\" ")
- .AddUrlParam("param2", "val2")
- .Build();
-
- UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc?param1=%3D!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+&param2=val2");
- }
-
- Y_UNIT_TEST(EmptyPathComponent) {
- TUrlBuilder builder("https://localhost/abc");
- UNIT_ASSERT_EXCEPTION_CONTAINS(builder.AddPathComponent(""), std::exception, "Empty path component is not allowed");
- auto url = builder.Build();
- // not changed
- UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc");
- }
-
- Y_UNIT_TEST(SeveralPathComponents) {
- auto url = TUrlBuilder("https://localhost/abc")
- .AddPathComponent("oops")
- .AddPathComponent("long oops")
- .AddUrlParam("param1", "val1")
- .AddUrlParam("param1", "long param")
- .Build();
- UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc/oops/long%20oops?param1=val1&param1=long+param");
- }
-
- Y_UNIT_TEST(SeveralPathComponentsWithSlashInBaseUri) {
- // base uri ends with '/'
- auto url = TUrlBuilder("https://localhost/abc/")
- .AddPathComponent("oops%1234")
- .AddPathComponent("long&oops=xxx")
- .AddUrlParam("param1", "a&b=cdef")
- .Build();
- UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc/oops%251234/long&oops=xxx?param1=a%26b%3Dcdef");
- }
+Y_UNIT_TEST(UriOnly) {
+ TUrlBuilder builder("https://localhost/abc");
+ UNIT_ASSERT_VALUES_EQUAL(builder.Build(), "https://localhost/abc");
}
+
+Y_UNIT_TEST(Basic) {
+ TUrlBuilder builder("https://localhost/abc");
+ builder.AddUrlParam("param1", "val1");
+ builder.AddUrlParam("param2", "val2");
+
+ UNIT_ASSERT_VALUES_EQUAL(builder.Build(), "https://localhost/abc?param1=val1&param2=val2");
+}
+
+Y_UNIT_TEST(BasicWithEncoding) {
+ auto url = TUrlBuilder("https://localhost/abc")
+ .AddUrlParam("param1", "=!@#$%^&*(){}[]\" ")
+ .AddUrlParam("param2", "val2")
+ .Build();
+
+ UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc?param1=%3D!@%23$%25%5E%26*%28%29%7B%7D%5B%5D%22+&param2=val2");
+}
+
+Y_UNIT_TEST(EmptyPathComponent) {
+ TUrlBuilder builder("https://localhost/abc");
+ UNIT_ASSERT_EXCEPTION_CONTAINS(builder.AddPathComponent(""), std::exception, "Empty path component is not allowed");
+ auto url = builder.Build();
+ // not changed
+ UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc");
+}
+
+Y_UNIT_TEST(SeveralPathComponents) {
+ auto url = TUrlBuilder("https://localhost/abc")
+ .AddPathComponent("oops")
+ .AddPathComponent("long oops")
+ .AddUrlParam("param1", "val1")
+ .AddUrlParam("param1", "long param")
+ .Build();
+ UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc/oops/long%20oops?param1=val1&param1=long+param");
+}
+
+Y_UNIT_TEST(SeveralPathComponentsWithSlashInBaseUri) {
+ // base uri ends with '/'
+ auto url = TUrlBuilder("https://localhost/abc/")
+ .AddPathComponent("oops%1234")
+ .AddPathComponent("long&oops=xxx")
+ .AddUrlParam("param1", "a&b=cdef")
+ .Build();
+ UNIT_ASSERT_VALUES_EQUAL(url, "https://localhost/abc/oops%251234/long&oops=xxx?param1=a%26b%3Dcdef");
+}
+} // Y_UNIT_TEST_SUITE(TUrlBuilder)
diff --git a/yql/essentials/utils/ut/ya.make b/yql/essentials/utils/ut/ya.make
index 30639f4c11f..8bc04c8be60 100644
--- a/yql/essentials/utils/ut/ya.make
+++ b/yql/essentials/utils/ut/ya.make
@@ -1,5 +1,7 @@
UNITTEST_FOR(yql/essentials/utils)
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
checkpoint_map_ut.cpp
fp_bits_ut.cpp
diff --git a/yql/essentials/utils/utf8.cpp b/yql/essentials/utils/utf8.cpp
index af284849a83..d47743e2b7a 100644
--- a/yql/essentials/utils/utf8.cpp
+++ b/yql/essentials/utils/utf8.cpp
@@ -12,6 +12,7 @@ namespace {
unsigned char GetRange(unsigned char c) {
// Referring to DFA of http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
// With new mapping 1 -> 0x10, 7 -> 0x20, 9 -> 0x40, such that AND operation can test multiple types.
+ // clang-format off
static const unsigned char type[] = {
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,
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,
@@ -24,6 +25,7 @@ unsigned char GetRange(unsigned char c) {
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
};
+ // clang-format on
return type[c];
}
@@ -38,6 +40,7 @@ struct TUtf8Ranges {
};
// see https://lemire.me/blog/2018/05/09/how-quickly-can-you-check-that-a-string-is-valid-unicode-utf-8
+// clang-format off
inline static const std::vector<TUtf8Ranges> Utf8Ranges = {
{ 1, { {0x00, 0x7f}, {0x00, 0x00}, {0x00, 0x00}, {0x00, 0x00}, } },
{ 2, { {0xc2, 0xdf}, {0x80, 0xbf}, {0x00, 0x00}, {0x00, 0x00}, } },
@@ -49,9 +52,10 @@ inline static const std::vector<TUtf8Ranges> Utf8Ranges = {
{ 4, { {0xf1, 0xf3}, {0x80, 0xbf}, {0x80, 0xbf}, {0x80, 0xbf}, } },
{ 4, { {0xf4, 0xf4}, {0x80, 0x8f}, {0x80, 0xbf}, {0x80, 0xbf}, } },
};
+// clang-format on
std::optional<std::string> RoundBadUtf8(size_t range, std::string_view inputString, size_t pos,
- bool roundDown)
+ bool roundDown)
{
Y_ENSURE(range > 0);
Y_ENSURE(range < Utf8Ranges.size());
@@ -119,35 +123,72 @@ std::optional<std::string> RoundBadUtf8(size_t range, std::string_view inputStri
}
}
}
-
}
return prefix + newSuffix;
}
-}
+} // namespace
bool IsUtf8(const std::string_view& str) {
for (auto it = str.cbegin(); str.cend() != it;) {
-#define COPY() if (str.cend() != it) { c = *it++; } else { return false; }
+#define COPY() \
+ if (str.cend() != it) { \
+ c = *it++; \
+ } else { \
+ return false; \
+ }
#define TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
-#define TAIL() COPY(); TRANS(0x70)
+#define TAIL() \
+ COPY(); \
+ TRANS(0x70)
auto c = *it++;
- if (!(c & 0x80))
+ if (!(c & 0x80)) {
continue;
+ }
bool result = true;
switch (GetRange(static_cast<unsigned char>(c))) {
- case 2: TAIL(); break;
- case 3: TAIL(); TAIL(); break;
- case 4: COPY(); TRANS(0x50); TAIL(); break;
- case 5: COPY(); TRANS(0x10); TAIL(); TAIL(); break;
- case 6: TAIL(); TAIL(); TAIL(); break;
- case 10: COPY(); TRANS(0x20); TAIL(); break;
- case 11: COPY(); TRANS(0x60); TAIL(); TAIL(); break;
- default: return false;
+ case 2:
+ TAIL();
+ break;
+ case 3:
+ TAIL();
+ TAIL();
+ break;
+ case 4:
+ COPY();
+ TRANS(0x50);
+ TAIL();
+ break;
+ case 5:
+ COPY();
+ TRANS(0x10);
+ TAIL();
+ TAIL();
+ break;
+ case 6:
+ TAIL();
+ TAIL();
+ TAIL();
+ break;
+ case 10:
+ COPY();
+ TRANS(0x20);
+ TAIL();
+ break;
+ case 11:
+ COPY();
+ TRANS(0x60);
+ TAIL();
+ TAIL();
+ break;
+ default:
+ return false;
}
- if (!result) return false;
+ if (!result) {
+ return false;
+ }
#undef COPY
#undef TRANS
#undef TAIL
@@ -157,21 +198,30 @@ bool IsUtf8(const std::string_view& str) {
unsigned char WideCharSize(char head) {
switch (GetRange(static_cast<unsigned char>(head))) {
- case 0: return 1;
- case 2: return 2;
- case 3: return 3;
- case 4: return 3;
- case 5: return 4;
- case 6: return 4;
- case 10: return 3;
- case 11: return 4;
- default: return 0;
+ case 0:
+ return 1;
+ case 2:
+ return 2;
+ case 3:
+ return 3;
+ case 4:
+ return 3;
+ case 5:
+ return 4;
+ case 6:
+ return 4;
+ case 10:
+ return 3;
+ case 11:
+ return 4;
+ default:
+ return 0;
}
}
std::optional<std::string> RoundToNearestValidUtf8(const std::string_view& str, bool roundDown) {
const size_t ss = str.size();
- for (size_t pos = 0; pos < ss; ) {
+ for (size_t pos = 0; pos < ss;) {
ui8 c = str[pos];
for (size_t i = 0; i < Utf8Ranges.size(); ++i) {
@@ -197,7 +247,7 @@ std::optional<std::string> RoundToNearestValidUtf8(const std::string_view& str,
break;
} else if (i + 1 == Utf8Ranges.size()) {
if (!roundDown) {
- return NextValidUtf8(str.substr(0, pos));
+ return NextValidUtf8(str.substr(0, pos));
}
return RoundBadUtf8(i, str, pos, roundDown);
}
@@ -257,4 +307,4 @@ std::optional<std::string> NextLexicographicString(const std::string_view& str)
return result;
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/utf8.h b/yql/essentials/utils/utf8.h
index 5c28353416a..9bd463ffd16 100644
--- a/yql/essentials/utils/utf8.h
+++ b/yql/essentials/utils/utf8.h
@@ -13,4 +13,4 @@ std::optional<std::string> RoundToNearestValidUtf8(const std::string_view& str,
std::optional<std::string> NextValidUtf8(const std::string_view& str);
std::optional<std::string> NextLexicographicString(const std::string_view& str);
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/utf8_ut.cpp b/yql/essentials/utils/utf8_ut.cpp
index 7479acd7a11..417658cea05 100644
--- a/yql/essentials/utils/utf8_ut.cpp
+++ b/yql/essentials/utils/utf8_ut.cpp
@@ -3,97 +3,97 @@
#include <library/cpp/testing/unittest/registar.h>
Y_UNIT_TEST_SUITE(TUtf8Tests) {
- Y_UNIT_TEST(Simple) {
- UNIT_ASSERT(NYql::IsUtf8(""));
- UNIT_ASSERT(NYql::IsUtf8("\x01_ASCII_\x7F"));
- UNIT_ASSERT(NYql::IsUtf8("Привет!"));
- UNIT_ASSERT(NYql::IsUtf8("\xF0\x9F\x94\xA2"));
+Y_UNIT_TEST(Simple) {
+ UNIT_ASSERT(NYql::IsUtf8(""));
+ UNIT_ASSERT(NYql::IsUtf8("\x01_ASCII_\x7F"));
+ UNIT_ASSERT(NYql::IsUtf8("Привет!"));
+ UNIT_ASSERT(NYql::IsUtf8("\xF0\x9F\x94\xA2"));
- UNIT_ASSERT(!NYql::IsUtf8("\xf5\x80\x80\x80"));
- UNIT_ASSERT(!NYql::IsUtf8("\xed\xa6\x80"));
- UNIT_ASSERT(!NYql::IsUtf8("\xF0\x9F\x94"));
- UNIT_ASSERT(!NYql::IsUtf8("\xE3\x85\xB6\xE7\x9C\xB0\xE3\x9C\xBA\xE2\xAA\x96\xEE\xA2\x8C\xEC\xAF\xB8\xE1\xB2\xBB\xEC\xA3\x9C\xE3\xAB\x8B\xEC\x95\x92\xE1\x8A\xBF\xE2\x8E\x86\xEC\x9B\x8D\xE2\x8E\xAE\xE3\x8A\xA3\xE0\xAC\xBC\xED\xB6\x85"));
- UNIT_ASSERT(!NYql::IsUtf8("\xc0\xbe\xd0\xb1\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x8e"));
- }
+ UNIT_ASSERT(!NYql::IsUtf8("\xf5\x80\x80\x80"));
+ UNIT_ASSERT(!NYql::IsUtf8("\xed\xa6\x80"));
+ UNIT_ASSERT(!NYql::IsUtf8("\xF0\x9F\x94"));
+ UNIT_ASSERT(!NYql::IsUtf8("\xE3\x85\xB6\xE7\x9C\xB0\xE3\x9C\xBA\xE2\xAA\x96\xEE\xA2\x8C\xEC\xAF\xB8\xE1\xB2\xBB\xEC\xA3\x9C\xE3\xAB\x8B\xEC\x95\x92\xE1\x8A\xBF\xE2\x8E\x86\xEC\x9B\x8D\xE2\x8E\xAE\xE3\x8A\xA3\xE0\xAC\xBC\xED\xB6\x85"));
+ UNIT_ASSERT(!NYql::IsUtf8("\xc0\xbe\xd0\xb1\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x8e"));
+}
- Y_UNIT_TEST(CharSize) {
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize(' '), 1);
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\x00'), 1);
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\x7F'), 1);
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xD1'), 2);
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xF0'), 4);
- UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xFF'), 0);
- }
+Y_UNIT_TEST(CharSize) {
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize(' '), 1);
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\x00'), 1);
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\x7F'), 1);
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xD1'), 2);
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xF0'), 4);
+ UNIT_ASSERT_VALUES_EQUAL(NYql::WideCharSize('\xFF'), 0);
+}
- Y_UNIT_TEST(RoundingDown) {
- auto checkDown = [](std::string_view in, std::string_view out) {
- auto res = NYql::RoundToNearestValidUtf8(in, true);
- UNIT_ASSERT(res);
- UNIT_ASSERT(NYql::IsUtf8(*res));
- UNIT_ASSERT_VALUES_EQUAL(*res, out);
- UNIT_ASSERT(*res <= in);
- };
- checkDown("привет", "привет");
- checkDown("тест\x80", "тест\x7f");
- checkDown("привет\xf5", "привет\xf4\x8f\xbf\xbf");
- checkDown("тест2\xee\x80\x7f", "тест2\xed\x9f\xbf");
- checkDown("ага\xf0\xaa\xaa\xff", "ага\xf0\xaa\xaa\xbf");
- }
+Y_UNIT_TEST(RoundingDown) {
+ auto checkDown = [](std::string_view in, std::string_view out) {
+ auto res = NYql::RoundToNearestValidUtf8(in, true);
+ UNIT_ASSERT(res);
+ UNIT_ASSERT(NYql::IsUtf8(*res));
+ UNIT_ASSERT_VALUES_EQUAL(*res, out);
+ UNIT_ASSERT(*res <= in);
+ };
+ checkDown("привет", "привет");
+ checkDown("тест\x80", "тест\x7f");
+ checkDown("привет\xf5", "привет\xf4\x8f\xbf\xbf");
+ checkDown("тест2\xee\x80\x7f", "тест2\xed\x9f\xbf");
+ checkDown("ага\xf0\xaa\xaa\xff", "ага\xf0\xaa\xaa\xbf");
+}
- Y_UNIT_TEST(RoundingUp) {
- auto checkUp = [](std::string_view in, std::string_view out) {
- auto res = NYql::RoundToNearestValidUtf8(in, false);
- UNIT_ASSERT(res);
- UNIT_ASSERT(NYql::IsUtf8(*res));
- UNIT_ASSERT_VALUES_EQUAL(*res, out);
- UNIT_ASSERT(*res >= in);
- };
+Y_UNIT_TEST(RoundingUp) {
+ auto checkUp = [](std::string_view in, std::string_view out) {
+ auto res = NYql::RoundToNearestValidUtf8(in, false);
+ UNIT_ASSERT(res);
+ UNIT_ASSERT(NYql::IsUtf8(*res));
+ UNIT_ASSERT_VALUES_EQUAL(*res, out);
+ UNIT_ASSERT(*res >= in);
+ };
- checkUp("", "");
- checkUp("привет", "привет");
- checkUp("а\xf6", "б");
- checkUp("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf\xf5", "\xf4\x8f\xbf\xbfб");
- UNIT_ASSERT(!NYql::RoundToNearestValidUtf8("\xf4\x8f\xbf\xbf\xf5", false));
- UNIT_ASSERT(!NYql::RoundToNearestValidUtf8("\xf5", false));
- checkUp("тест\x80", "тест\xc2\x80");
- checkUp("тест\xdf", "тест\xdf\x80");
- checkUp("тест\xf0\x90\xff", "тест\xf0\x91\x80\x80");
- checkUp("ааа\xff", "ааб");
- }
+ checkUp("", "");
+ checkUp("привет", "привет");
+ checkUp("а\xf6", "б");
+ checkUp("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf\xf5", "\xf4\x8f\xbf\xbfб");
+ UNIT_ASSERT(!NYql::RoundToNearestValidUtf8("\xf4\x8f\xbf\xbf\xf5", false));
+ UNIT_ASSERT(!NYql::RoundToNearestValidUtf8("\xf5", false));
+ checkUp("тест\x80", "тест\xc2\x80");
+ checkUp("тест\xdf", "тест\xdf\x80");
+ checkUp("тест\xf0\x90\xff", "тест\xf0\x91\x80\x80");
+ checkUp("ааа\xff", "ааб");
+}
- Y_UNIT_TEST(NextValid) {
- auto checkNext = [](std::string_view in, std::string_view out) {
- auto res = NYql::NextValidUtf8(in);
- UNIT_ASSERT(res);
- UNIT_ASSERT(NYql::IsUtf8(*res));
- UNIT_ASSERT_VALUES_EQUAL(*res, out);
- UNIT_ASSERT(*res > in);
- };
+Y_UNIT_TEST(NextValid) {
+ auto checkNext = [](std::string_view in, std::string_view out) {
+ auto res = NYql::NextValidUtf8(in);
+ UNIT_ASSERT(res);
+ UNIT_ASSERT(NYql::IsUtf8(*res));
+ UNIT_ASSERT_VALUES_EQUAL(*res, out);
+ UNIT_ASSERT(*res > in);
+ };
- UNIT_ASSERT(!NYql::NextValidUtf8(""));
- checkNext("привет", "привеу");
- checkNext("а", "б");
- checkNext(std::string_view("\x00", 1), "\x01");
- checkNext("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf", "\xf4\x8f\xbf\xbfб");
- UNIT_ASSERT(!NYql::NextValidUtf8("\xf4\x8f\xbf\xbf"));
- UNIT_ASSERT(!NYql::NextValidUtf8("\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbf"));
- }
+ UNIT_ASSERT(!NYql::NextValidUtf8(""));
+ checkNext("привет", "привеу");
+ checkNext("а", "б");
+ checkNext(std::string_view("\x00", 1), "\x01");
+ checkNext("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf", "\xf4\x8f\xbf\xbfб");
+ UNIT_ASSERT(!NYql::NextValidUtf8("\xf4\x8f\xbf\xbf"));
+ UNIT_ASSERT(!NYql::NextValidUtf8("\xf4\x8f\xbf\xbf\xf4\x8f\xbf\xbf"));
+}
- Y_UNIT_TEST(NextValidString) {
- auto checkNext = [](std::string_view in, std::string_view out) {
- auto res = NYql::NextLexicographicString(in);
- UNIT_ASSERT(res);
- UNIT_ASSERT_VALUES_EQUAL(*res, out);
- UNIT_ASSERT(*res > in);
- };
+Y_UNIT_TEST(NextValidString) {
+ auto checkNext = [](std::string_view in, std::string_view out) {
+ auto res = NYql::NextLexicographicString(in);
+ UNIT_ASSERT(res);
+ UNIT_ASSERT_VALUES_EQUAL(*res, out);
+ UNIT_ASSERT(*res > in);
+ };
- UNIT_ASSERT(!NYql::NextLexicographicString(""));
- checkNext("привет", "привеу");
- checkNext("а", "б");
- checkNext(std::string_view("\x00", 1), "\x01");
- checkNext("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf", "\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xc0");
- UNIT_ASSERT(!NYql::NextLexicographicString("\xff"));
- UNIT_ASSERT(!NYql::NextLexicographicString("\xff\xff"));
- checkNext(std::string_view("x\x00\xff\xff", 4), "x\x01");
- }
+ UNIT_ASSERT(!NYql::NextLexicographicString(""));
+ checkNext("привет", "привеу");
+ checkNext("а", "б");
+ checkNext(std::string_view("\x00", 1), "\x01");
+ checkNext("\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xbf", "\xf4\x8f\xbf\xbfа\xf4\x8f\xbf\xc0");
+ UNIT_ASSERT(!NYql::NextLexicographicString("\xff"));
+ UNIT_ASSERT(!NYql::NextLexicographicString("\xff\xff"));
+ checkNext(std::string_view("x\x00\xff\xff", 4), "x\x01");
}
+} // Y_UNIT_TEST_SUITE(TUtf8Tests)
diff --git a/yql/essentials/utils/ya.make b/yql/essentials/utils/ya.make
index 1797655ae68..4c42d50206a 100644
--- a/yql/essentials/utils/ya.make
+++ b/yql/essentials/utils/ya.make
@@ -1,5 +1,7 @@
LIBRARY()
+ENABLE(YQL_STYLE_CPP)
+
SRCS(
cast.h
checkpoint_map.cpp
diff --git a/yql/essentials/utils/yql_panic.cpp b/yql/essentials/utils/yql_panic.cpp
index 83c6acc21fe..3910426dc40 100644
--- a/yql/essentials/utils/yql_panic.cpp
+++ b/yql/essentials/utils/yql_panic.cpp
@@ -4,9 +4,9 @@ namespace NYql {
namespace NDetail {
void YqlPanic(const ::NPrivate::TStaticBuf& file, int line, const char* function,
- const TStringBuf& condition, const TStringBuf& message) {
+ const TStringBuf& condition, const TStringBuf& message) {
auto err = TYqlPanic() << file.As<TStringBuf>() << ":" << line << " "
- << function << "(): requirement " << condition << " failed";
+ << function << "(): requirement " << condition << " failed";
if (!message.empty()) {
err << ", message: " << message;
}
diff --git a/yql/essentials/utils/yql_panic.h b/yql/essentials/utils/yql_panic.h
index e7e559b2c50..00dedf2a7de 100644
--- a/yql/essentials/utils/yql_panic.h
+++ b/yql/essentials/utils/yql_panic.h
@@ -5,18 +5,17 @@
namespace NYql {
-class TYqlPanic : public yexception
-{};
+class TYqlPanic: public yexception {};
namespace NDetail {
- [[noreturn]] void YqlPanic(const ::NPrivate::TStaticBuf& file, int line, const char* function, const TStringBuf& condition, const TStringBuf& message);
-}
+[[noreturn]] void YqlPanic(const ::NPrivate::TStaticBuf& file, int line, const char* function, const TStringBuf& condition, const TStringBuf& message);
+} // namespace NDetail
-#define YQL_ENSURE(CONDITION, ...) \
- do { \
- if (Y_UNLIKELY(!(CONDITION))) { \
+#define YQL_ENSURE(CONDITION, ...) \
+ do { \
+ if (Y_UNLIKELY(!(CONDITION))) { \
::NYql::NDetail::YqlPanic(__SOURCE_FILE_IMPL__, __LINE__, __FUNCTION__, #CONDITION, TStringBuilder() << "" __VA_ARGS__); \
- } \
+ } \
} while (0)
} // namespace NYql
diff --git a/yql/essentials/utils/yql_paths.cpp b/yql/essentials/utils/yql_paths.cpp
index cc7dd29bfbe..ca359f1ca87 100644
--- a/yql/essentials/utils/yql_paths.cpp
+++ b/yql/essentials/utils/yql_paths.cpp
@@ -20,4 +20,4 @@ TString BuildTablePath(TStringBuf prefixPath, TStringBuf path) {
return prefixPathSplit.AppendMany(pathSplit.begin(), pathSplit.end()).Reconstruct();
}
-}
+} // namespace NYql
diff --git a/yql/essentials/utils/yql_paths.h b/yql/essentials/utils/yql_paths.h
index 3ec05e7df82..7ad08d2914f 100644
--- a/yql/essentials/utils/yql_paths.h
+++ b/yql/essentials/utils/yql_paths.h
@@ -6,4 +6,4 @@ namespace NYql {
TString BuildTablePath(TStringBuf prefixPath, TStringBuf path);
-}
+} // namespace NYql