summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/reflect/sql_reflect.cpp
diff options
context:
space:
mode:
authorvityaman <[email protected]>2025-05-19 11:17:12 +0300
committerrobot-piglet <[email protected]>2025-05-19 11:31:23 +0300
commit50dbbb6a1e90cf9d1da40a92d563b02712b00b9e (patch)
treec9c2952f8521851540e08338d093f2067a68fdb4 /yql/essentials/sql/v1/reflect/sql_reflect.cpp
parent511e56c14b85e20b29e77f9da53d5bb29a3e996c (diff)
YQL-19616: Fix TRegexLexer performance
Fix `TRegexLexer` performance. Now it is just 2 times slower than a reference ANTLR implementation on Release mode, so merged regexes are 3 times better than scan&compare. ![image](https://github.com/user-attachments/assets/4e0cb27a-491d-4dbd-b10a-5725ffa6d902) --- - Related to `YQL-19616` - Related to https://github.com/ydb-platform/ydb/issues/15129 - Related to https://github.com/vityaman/ydb/issues/42 --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1278 commit_hash:1529f641172fea13f0d33fbfd06a4827c6efde01
Diffstat (limited to 'yql/essentials/sql/v1/reflect/sql_reflect.cpp')
-rw-r--r--yql/essentials/sql/v1/reflect/sql_reflect.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/yql/essentials/sql/v1/reflect/sql_reflect.cpp b/yql/essentials/sql/v1/reflect/sql_reflect.cpp
index 262209cfc39..5e652db4fc0 100644
--- a/yql/essentials/sql/v1/reflect/sql_reflect.cpp
+++ b/yql/essentials/sql/v1/reflect/sql_reflect.cpp
@@ -1,9 +1,11 @@
#include "sql_reflect.h"
#include <library/cpp/resource/resource.h>
+#include <library/cpp/case_insensitive_string/case_insensitive_string.h>
#include <util/string/split.h>
#include <util/string/strip.h>
+#include <util/charset/utf8.h>
namespace NSQLReflect {
@@ -15,13 +17,20 @@ namespace NSQLReflect {
const TStringBuf SectionOther = "//! section:other";
const TStringBuf FragmentPrefix = "fragment ";
- const TStringBuf TLexerGrammar::KeywordBlock(const TStringBuf name) {
+ const TStringBuf TLexerGrammar::KeywordBlockByName(const TStringBuf name Y_LIFETIME_BOUND) {
if (name == "TSKIP") {
return "SKIP";
}
return name;
}
+ const TString TLexerGrammar::KeywordNameByBlock(const TStringBuf block) {
+ if (TCaseInsensitiveStringBuf(block) == "SKIP") {
+ return "TSKIP";
+ }
+ return ToUpperUTF8(block);
+ }
+
TVector<TString> GetResourceLines(const TStringBuf key) {
TString text;
Y_ENSURE(NResource::FindExact(key, &text));
@@ -133,7 +142,7 @@ namespace NSQLReflect {
SubstGlobal(block, "'", "");
SubstGlobal(block, " ", "");
- Y_ENSURE(name == block || (name == "TSKIP" && block == TLexerGrammar::KeywordBlock("TSKIP")));
+ Y_ENSURE(name == block || (name == "TSKIP" && block == TLexerGrammar::KeywordBlockByName("TSKIP")));
grammar.KeywordNames.emplace(std::move(name));
}