Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
310ed66b
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
310ed66b
编写于
5月 03, 2015
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "dbms: improvement (incomplete) [#METR-16164]."
This reverts commit 6f4f44ce7980cace32edd0913b8d1d53cd51682b.
上级
3b5fe94b
变更
33
显示空白变更内容
内联
并排
Showing
33 changed file
with
109 addition
and
343 deletion
+109
-343
dbms/include/DB/Common/UInt128.h
dbms/include/DB/Common/UInt128.h
+0
-5
dbms/include/DB/Core/Field.h
dbms/include/DB/Core/Field.h
+0
-59
dbms/include/DB/Interpreters/LogicalExpressionsOptimizer.h
dbms/include/DB/Interpreters/LogicalExpressionsOptimizer.h
+2
-2
dbms/include/DB/Parsers/ASTAlterQuery.h
dbms/include/DB/Parsers/ASTAlterQuery.h
+0
-7
dbms/include/DB/Parsers/ASTAsterisk.h
dbms/include/DB/Parsers/ASTAsterisk.h
+0
-5
dbms/include/DB/Parsers/ASTCheckQuery.h
dbms/include/DB/Parsers/ASTCheckQuery.h
+0
-7
dbms/include/DB/Parsers/ASTColumnDeclaration.h
dbms/include/DB/Parsers/ASTColumnDeclaration.h
+0
-6
dbms/include/DB/Parsers/ASTCreateQuery.h
dbms/include/DB/Parsers/ASTCreateQuery.h
+1
-9
dbms/include/DB/Parsers/ASTDropQuery.h
dbms/include/DB/Parsers/ASTDropQuery.h
+1
-9
dbms/include/DB/Parsers/ASTExpressionList.h
dbms/include/DB/Parsers/ASTExpressionList.h
+2
-7
dbms/include/DB/Parsers/ASTFunction.h
dbms/include/DB/Parsers/ASTFunction.h
+32
-6
dbms/include/DB/Parsers/ASTIdentifier.h
dbms/include/DB/Parsers/ASTIdentifier.h
+0
-6
dbms/include/DB/Parsers/ASTInsertQuery.h
dbms/include/DB/Parsers/ASTInsertQuery.h
+1
-8
dbms/include/DB/Parsers/ASTJoin.h
dbms/include/DB/Parsers/ASTJoin.h
+0
-8
dbms/include/DB/Parsers/ASTLiteral.h
dbms/include/DB/Parsers/ASTLiteral.h
+0
-6
dbms/include/DB/Parsers/ASTNameTypePair.h
dbms/include/DB/Parsers/ASTNameTypePair.h
+0
-6
dbms/include/DB/Parsers/ASTOptimizeQuery.h
dbms/include/DB/Parsers/ASTOptimizeQuery.h
+1
-8
dbms/include/DB/Parsers/ASTOrderByElement.h
dbms/include/DB/Parsers/ASTOrderByElement.h
+3
-8
dbms/include/DB/Parsers/ASTQueryWithOutput.h
dbms/include/DB/Parsers/ASTQueryWithOutput.h
+2
-7
dbms/include/DB/Parsers/ASTQueryWithTableAndOutput.h
dbms/include/DB/Parsers/ASTQueryWithTableAndOutput.h
+6
-13
dbms/include/DB/Parsers/ASTRenameQuery.h
dbms/include/DB/Parsers/ASTRenameQuery.h
+1
-6
dbms/include/DB/Parsers/ASTSelectQuery.h
dbms/include/DB/Parsers/ASTSelectQuery.h
+0
-5
dbms/include/DB/Parsers/ASTSet.h
dbms/include/DB/Parsers/ASTSet.h
+0
-5
dbms/include/DB/Parsers/ASTSetQuery.h
dbms/include/DB/Parsers/ASTSetQuery.h
+2
-7
dbms/include/DB/Parsers/ASTShowTablesQuery.h
dbms/include/DB/Parsers/ASTShowTablesQuery.h
+4
-9
dbms/include/DB/Parsers/ASTSubquery.h
dbms/include/DB/Parsers/ASTSubquery.h
+2
-11
dbms/include/DB/Parsers/ASTUseQuery.h
dbms/include/DB/Parsers/ASTUseQuery.h
+1
-7
dbms/include/DB/Parsers/IAST.h
dbms/include/DB/Parsers/IAST.h
+41
-64
dbms/src/DataStreams/tests/filter_stream.cpp
dbms/src/DataStreams/tests/filter_stream.cpp
+1
-0
dbms/src/DataStreams/tests/filter_stream_hitlog.cpp
dbms/src/DataStreams/tests/filter_stream_hitlog.cpp
+1
-0
dbms/src/Interpreters/ExpressionAnalyzer.cpp
dbms/src/Interpreters/ExpressionAnalyzer.cpp
+3
-36
dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp
dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp
+1
-1
dbms/src/Parsers/tests/select_parser.cpp
dbms/src/Parsers/tests/select_parser.cpp
+1
-0
未找到文件。
dbms/include/DB/Common/UInt128.h
浏览文件 @
310ed66b
...
...
@@ -21,11 +21,6 @@ struct UInt128
bool
operator
!=
(
const
UInt64
rhs
)
const
{
return
first
!=
rhs
||
second
!=
0
;
}
UInt128
&
operator
=
(
const
UInt64
rhs
)
{
first
=
rhs
;
second
=
0
;
return
*
this
;
}
bool
operator
<
(
const
UInt128
rhs
)
const
{
return
std
::
tie
(
first
,
second
)
<
std
::
tie
(
rhs
.
first
,
rhs
.
second
);
}
};
struct
UInt128Hash
...
...
dbms/include/DB/Core/Field.h
浏览文件 @
310ed66b
...
...
@@ -18,7 +18,6 @@
#include <DB/IO/WriteBufferFromString.h>
#include <DB/IO/DoubleConverter.h>
#include <DB/Common/SipHash.h>
namespace
DB
...
...
@@ -573,64 +572,6 @@ public:
}
};
/** Обновляет состояние хэш-функции значением. */
class
FieldVisitorUpdateHash
:
public
StaticVisitor
<>
{
private:
SipHash
&
hash
;
public:
FieldVisitorUpdateHash
(
SipHash
&
hash_
)
:
hash
(
hash_
)
{}
void
operator
()
(
const
Null
&
x
)
const
{
auto
type
=
Field
::
Types
::
Null
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
}
void
operator
()
(
const
UInt64
&
x
)
const
{
auto
type
=
Field
::
Types
::
UInt64
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
x
),
sizeof
(
x
));
}
void
operator
()
(
const
Int64
&
x
)
const
{
auto
type
=
Field
::
Types
::
Int64
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
x
),
sizeof
(
x
));
}
void
operator
()
(
const
Float64
&
x
)
const
{
auto
type
=
Field
::
Types
::
Float64
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
x
),
sizeof
(
x
));
}
void
operator
()
(
const
String
&
x
)
const
{
auto
type
=
Field
::
Types
::
String
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
size_t
size
=
x
.
size
();
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
size
),
sizeof
(
size
));
hash
.
update
(
x
.
data
(),
x
.
size
());
}
void
operator
()
(
const
Array
&
x
)
const
{
auto
type
=
Field
::
Types
::
Array
;
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
type
),
1
);
size_t
size
=
x
.
size
();
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
size
),
sizeof
(
size
));
for
(
const
auto
&
elem
:
x
)
apply_visitor
(
*
this
,
elem
);
}
};
/** Выводит текстовое представление типа, как литерала в SQL запросе */
class
FieldVisitorToString
:
public
StaticVisitor
<
String
>
{
...
...
dbms/include/DB/Interpreters/LogicalExpressionsOptimizer.h
浏览文件 @
310ed66b
...
...
@@ -39,11 +39,11 @@ private:
*/
struct
OrWithExpression
{
OrWithExpression
(
ASTFunction
*
or_function_
,
UInt128
expression_
);
OrWithExpression
(
ASTFunction
*
or_function_
,
const
std
::
string
&
expression_
);
bool
operator
<
(
const
OrWithExpression
&
rhs
)
const
;
ASTFunction
*
or_function
;
const
UInt128
expression
;
const
std
::
string
expression
;
};
struct
Equalities
...
...
dbms/include/DB/Parsers/ASTAlterQuery.h
浏览文件 @
310ed66b
...
...
@@ -89,13 +89,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
(
"AlterQuery_"
+
database
+
"_"
+
table
);
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"AlterQuery"
,
strlen
(
"AlterQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
ASTAlterQuery
*
res
=
new
ASTAlterQuery
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTAsterisk.h
浏览文件 @
310ed66b
...
...
@@ -16,11 +16,6 @@ public:
String
getID
()
const
override
{
return
"Asterisk"
;
}
ASTPtr
clone
()
const
override
{
return
new
ASTAsterisk
(
*
this
);
}
String
getColumnName
()
const
override
{
return
"*"
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Asterisk"
,
strlen
(
"Asterisk"
)
+
1
);
}
};
}
dbms/include/DB/Parsers/ASTCheckQuery.h
浏览文件 @
310ed66b
...
...
@@ -12,13 +12,6 @@ struct ASTCheckQuery : public IAST
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
(
"CheckQuery_"
+
database
+
"_"
+
table
);
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"CheckQuery"
,
strlen
(
"CheckQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTCheckQuery
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTColumnDeclaration.h
浏览文件 @
310ed66b
...
...
@@ -21,12 +21,6 @@ public:
String
getID
()
const
override
{
return
"ColumnDeclaration_"
+
name
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"ColumnDeclaration"
,
strlen
(
"ColumnDeclaration"
)
+
1
);
hash
.
update
(
name
.
data
(),
name
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
const
auto
res
=
new
ASTColumnDeclaration
{
*
this
};
...
...
dbms/include/DB/Parsers/ASTCreateQuery.h
浏览文件 @
310ed66b
...
...
@@ -34,14 +34,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
(
attach
?
"AttachQuery_"
:
"CreateQuery_"
)
+
database
+
"_"
+
table
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
attach
),
sizeof
(
attach
));
hash
.
update
(
"CreateQuery"
,
strlen
(
"CreateQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
ASTCreateQuery
*
res
=
new
ASTCreateQuery
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTDropQuery.h
浏览文件 @
310ed66b
...
...
@@ -23,14 +23,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
(
detach
?
"DetachQuery_"
:
"DropQuery_"
)
+
database
+
"_"
+
table
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
detach
),
sizeof
(
detach
));
hash
.
update
(
"DropQuery"
,
strlen
(
"DropQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTDropQuery
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTExpressionList.h
浏览文件 @
310ed66b
...
...
@@ -20,11 +20,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"ExpressionList"
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"ExpressionList"
,
strlen
(
"ExpressionList"
)
+
1
);
}
ASTPtr
clone
()
const
override
{
const
auto
res
=
new
ASTExpressionList
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTFunction.h
浏览文件 @
310ed66b
...
...
@@ -5,6 +5,7 @@
#include <DB/Functions/IFunction.h>
#include <DB/AggregateFunctions/IAggregateFunction.h>
#include <DB/IO/WriteBufferFromString.h>
#include <DB/Common/SipHash.h>
namespace
DB
...
...
@@ -37,15 +38,40 @@ public:
ASTFunction
()
=
default
;
ASTFunction
(
const
StringRange
range_
)
:
ASTWithAlias
(
range_
)
{}
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Function_"
+
name
;
}
String
getColumnName
()
const
override
{
SipHash
hash
;
hash
.
update
(
name
.
data
(),
name
.
size
());
void
updateHashWith
(
SipHash
&
hash
)
const
override
if
(
parameters
)
{
hash
.
update
(
"Function"
,
strlen
(
"Function"
)
+
1
);
hash
.
update
(
name
.
data
(),
name
.
size
()
+
1
);
hash
.
update
(
"("
,
1
);
for
(
const
auto
&
param
:
parameters
->
children
)
{
String
param_name
=
param
->
getColumnName
();
/// TODO Сделать метод updateHashWith.
hash
.
update
(
param_name
.
data
(),
param_name
.
size
()
+
1
);
}
hash
.
update
(
")"
,
1
);
}
hash
.
update
(
"("
,
1
);
for
(
const
auto
&
arg
:
arguments
->
children
)
{
String
arg_name
=
arg
->
getColumnName
();
hash
.
update
(
arg_name
.
data
(),
arg_name
.
size
()
+
1
);
}
hash
.
update
(
")"
,
1
);
UInt64
low
,
high
;
hash
.
get128
(
low
,
high
);
return
toString
(
high
)
+
"_"
+
toString
(
low
);
/// TODO hex.
}
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Function_"
+
name
;
}
ASTPtr
clone
()
const
override
{
ASTFunction
*
res
=
new
ASTFunction
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTIdentifier.h
浏览文件 @
310ed66b
...
...
@@ -35,12 +35,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Identifier_"
+
name
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Identifier"
,
strlen
(
"Identifier"
)
+
1
);
hash
.
update
(
name
.
data
(),
name
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTIdentifier
(
*
this
);
}
void
collectIdentifierNames
(
IdentifierNameSet
&
set
)
const
override
...
...
dbms/include/DB/Parsers/ASTInsertQuery.h
浏览文件 @
310ed66b
...
...
@@ -30,13 +30,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"InsertQuery_"
+
database
+
"_"
+
table
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"InsertQuery"
,
strlen
(
"InsertQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
ASTInsertQuery
*
res
=
new
ASTInsertQuery
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTJoin.h
浏览文件 @
310ed66b
...
...
@@ -69,14 +69,6 @@ public:
return
res
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Join"
,
strlen
(
"Join"
)
+
1
);
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
locality
),
sizeof
(
locality
));
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
strictness
),
sizeof
(
strictness
));
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
kind
),
sizeof
(
kind
));
}
ASTPtr
clone
()
const
override
{
ASTJoin
*
res
=
new
ASTJoin
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTLiteral.h
浏览文件 @
310ed66b
...
...
@@ -25,12 +25,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Literal_"
+
apply_visitor
(
FieldVisitorDump
(),
value
);
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Literal"
,
strlen
(
"Literal"
)
+
1
);
apply_visitor
(
FieldVisitorUpdateHash
(
hash
),
value
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTLiteral
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTNameTypePair.h
浏览文件 @
310ed66b
...
...
@@ -23,12 +23,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"NameTypePair_"
+
name
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"NameTypePair"
,
strlen
(
"NameTypePair"
)
+
1
);
hash
.
update
(
name
.
data
(),
name
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
ASTNameTypePair
*
res
=
new
ASTNameTypePair
(
*
this
);
...
...
dbms/include/DB/Parsers/ASTOptimizeQuery.h
浏览文件 @
310ed66b
...
...
@@ -21,13 +21,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"OptimizeQuery_"
+
database
+
"_"
+
table
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"OptimizeQuery"
,
strlen
(
"OptimizeQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
hash
.
update
(
table
.
data
(),
table
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTOptimizeQuery
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTOrderByElement.h
浏览文件 @
310ed66b
...
...
@@ -28,11 +28,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"OrderByElement"
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"OrderByElement"
,
strlen
(
"OrderByElement"
)
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTOrderByElement
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTQueryWithOutput.h
浏览文件 @
310ed66b
...
...
@@ -28,11 +28,6 @@ public: \
Name(StringRange range_) : ASTQueryWithOutput(range_) {} \
String getID() const override { return ID; }; \
\
void updateHashWith(SipHash & hash) const override \
{ \
hash.update(ID, strlen(ID) + 1); \
} \
\
ASTPtr clone() const override \
{ \
Name * res = new Name(*this); \
...
...
dbms/include/DB/Parsers/ASTQueryWithTableAndOutput.h
浏览文件 @
310ed66b
...
...
@@ -30,13 +30,6 @@ public: \
Name(const StringRange range_) : ASTQueryWithTableAndOutput(range_) {} \
String getID() const override { return ID"_" + database + "_" + table; }; \
\
void updateHashWith(SipHash & hash) const override \
{ \
hash.update(ID, strlen(ID) + 1); \
hash.update(database.data(), database.size() + 1); \
hash.update(table.data(), table.size() + 1); \
} \
\
ASTPtr clone() const override \
{ \
Name * res = new Name(*this); \
...
...
dbms/include/DB/Parsers/ASTRenameQuery.h
浏览文件 @
310ed66b
...
...
@@ -33,11 +33,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Rename"
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Rename"
,
strlen
(
"Rename"
)
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTRenameQuery
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTSelectQuery.h
浏览文件 @
310ed66b
...
...
@@ -39,11 +39,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"SelectQuery"
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"SelectQuery"
,
strlen
(
"SelectQuery"
)
+
1
);
}
/// Проверить наличие функции arrayJoin. (Не большого ARRAY JOIN.)
static
bool
hasArrayJoin
(
const
ASTPtr
&
ast
)
{
...
...
dbms/include/DB/Parsers/ASTSet.h
浏览文件 @
310ed66b
...
...
@@ -22,11 +22,6 @@ public:
String
getID
()
const
override
{
return
"Set_"
+
getColumnName
();
}
ASTPtr
clone
()
const
override
{
return
new
ASTSet
(
*
this
);
}
String
getColumnName
()
const
override
{
return
column_name
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Set"
,
strlen
(
"Set"
)
+
1
);
}
};
}
dbms/include/DB/Parsers/ASTSetQuery.h
浏览文件 @
310ed66b
...
...
@@ -28,12 +28,7 @@ public:
ASTSetQuery
(
const
StringRange
range_
)
:
IAST
(
range_
)
{}
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"SetQuery"
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"SetQuery"
,
strlen
(
"SetQuery"
)
+
1
);
}
String
getID
()
const
override
{
return
"Set"
;
};
ASTPtr
clone
()
const
override
{
return
new
ASTSetQuery
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/ASTShowTablesQuery.h
浏览文件 @
310ed66b
...
...
@@ -22,12 +22,7 @@ public:
ASTShowTablesQuery
(
const
StringRange
range_
)
:
ASTQueryWithOutput
(
range_
)
{}
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"ShowTablesQuery"
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"ShowTablesQuery"
,
strlen
(
"ShowTablesQuery"
)
+
1
);
}
String
getID
()
const
override
{
return
"ShowTables"
;
};
ASTPtr
clone
()
const
override
{
...
...
dbms/include/DB/Parsers/ASTSubquery.h
浏览文件 @
310ed66b
...
...
@@ -20,11 +20,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"Subquery"
;
}
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"Subquery"
,
strlen
(
"Subquery"
)
+
1
);
}
ASTPtr
clone
()
const
override
{
const
auto
res
=
new
ASTSubquery
{
*
this
};
...
...
@@ -38,11 +33,7 @@ public:
return
ptr
;
}
String
getColumnName
()
const
override
{
auto
id
=
getTreeID
();
return
toString
(
id
.
first
)
+
"_"
+
toString
(
id
.
second
);
}
String
getColumnName
()
const
override
{
return
getTreeID
();
}
};
}
dbms/include/DB/Parsers/ASTUseQuery.h
浏览文件 @
310ed66b
...
...
@@ -20,12 +20,6 @@ public:
/** Получить текст, который идентифицирует этот элемент. */
String
getID
()
const
override
{
return
"UseQuery_"
+
database
;
};
void
updateHashWith
(
SipHash
&
hash
)
const
override
{
hash
.
update
(
"UseQuery"
,
strlen
(
"UseQuery"
)
+
1
);
hash
.
update
(
database
.
data
(),
database
.
size
()
+
1
);
}
ASTPtr
clone
()
const
override
{
return
new
ASTUseQuery
(
*
this
);
}
};
...
...
dbms/include/DB/Parsers/IAST.h
浏览文件 @
310ed66b
...
...
@@ -9,10 +9,8 @@
#include <Yandex/Common.h>
#include <DB/Core/Types.h>
#include <DB/Common/UInt128.h>
#include <DB/Core/Exception.h>
#include <DB/Core/ErrorCodes.h>
#include <DB/Common/SipHash.h>
#include <DB/IO/WriteHelpers.h>
#include <DB/Parsers/StringRange.h>
...
...
@@ -45,67 +43,15 @@ public:
IAST
(
const
StringRange
range_
)
:
range
(
range_
)
{}
virtual
~
IAST
()
=
default
;
/** Получить имя, однозначно идентифицирующее выражение, если элемент является столбцом. У одинаковых выражений будет одинаковое имя. */
virtual
String
getColumnName
()
const
{
/// По-умолчанию - подчёркивание, а затем getTreeID в hex-е.
union
{
UInt128
id
;
UInt8
id_bytes
[
16
];
};
id
=
getTreeID
();
String
res
(
1
+
2
*
sizeof
(
id
),
'_'
);
for
(
size_t
i
=
0
;
i
<
sizeof
(
id
);
++
i
)
{
res
[
i
*
2
+
1
]
=
(
id_bytes
[
i
]
/
16
)
<
10
?
(
'0'
+
(
id_bytes
[
i
]
/
16
))
:
(
'A'
+
(
id_bytes
[
i
]
/
16
-
10
));
res
[
i
*
2
+
2
]
=
(
id_bytes
[
i
]
%
16
)
<
10
?
(
'0'
+
(
id_bytes
[
i
]
%
16
))
:
(
'A'
+
(
id_bytes
[
i
]
%
16
-
10
));
}
return
res
;
}
/** Получить каноническое имя столбца, если элемент является столбцом */
virtual
String
getColumnName
()
const
{
throw
Exception
(
"Trying to get name of not a column: "
+
getID
(),
ErrorCodes
::
NOT_A_COLUMN
);
}
/** Получить алиас, если он есть, или имя столбца, если его нет. */
/** Получить алиас, если он есть, или
каноническое
имя столбца, если его нет. */
virtual
String
getAliasOrColumnName
()
const
{
return
getColumnName
();
}
/** Получить алиас, если он есть, или пустую строку, если его нет, или если элемент не поддерживает алиасы. */
virtual
String
tryGetAlias
()
const
{
return
String
();
}
/** Обновить состояние хэш-функции элементом дерева. */
virtual
void
updateHashWith
(
SipHash
&
hash
)
const
=
0
;
/** Обновить состояние хэш-функции целым поддеревом. Используется для склейки одинаковых выражений. */
void
updateHashWithTree
(
SipHash
&
hash
)
const
{
updateHashWith
(
hash
);
if
(
!
children
.
empty
())
{
size_t
size
=
children
.
size
();
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
size
),
sizeof
(
size
));
for
(
size_t
i
=
0
;
i
<
size
;
++
i
)
{
hash
.
update
(
reinterpret_cast
<
const
char
*>
(
&
i
),
sizeof
(
i
));
children
[
i
]
->
updateHashWithTree
(
hash
);
}
}
}
/** Получить идентификатор поддерева. Используется для склейки одинаковых выражений.
*/
UInt128
getTreeID
()
const
{
SipHash
hash
;
updateHashWithTree
(
hash
);
UInt128
res
;
hash
.
get128
(
reinterpret_cast
<
char
*>
(
&
res
));
return
res
;
}
/** Установить алиас. */
virtual
void
setAlias
(
const
String
&
to
)
{
...
...
@@ -125,6 +71,37 @@ public:
(
*
it
)
->
is_visited
=
false
;
}
/** Получить текст, который идентифицирует этот элемент и всё поддерево.
* Обычно он содержит идентификатор элемента и getTreeID от всех детей.
*/
String
getTreeID
()
const
{
std
::
stringstream
s
;
s
<<
getID
();
if
(
!
children
.
empty
())
{
s
<<
"("
;
for
(
ASTs
::
const_iterator
it
=
children
.
begin
();
it
!=
children
.
end
();
++
it
)
{
if
(
it
!=
children
.
begin
())
s
<<
", "
;
s
<<
(
*
it
)
->
getTreeID
();
}
s
<<
")"
;
}
return
s
.
str
();
}
void
dumpTree
(
std
::
ostream
&
ostr
,
size_t
indent
=
0
)
const
{
String
indent_str
(
indent
,
'-'
);
ostr
<<
indent_str
<<
getID
()
<<
", "
<<
this
<<
std
::
endl
;
for
(
ASTs
::
const_iterator
it
=
children
.
begin
();
it
!=
children
.
end
();
++
it
)
(
*
it
)
->
dumpTree
(
ostr
,
indent
+
1
);
}
/** Проверить глубину дерева.
* Если задано max_depth и глубина больше - кинуть исключение.
* Возвращает глубину дерева.
...
...
@@ -139,8 +116,8 @@ public:
size_t
checkSize
(
size_t
max_size
)
const
{
size_t
res
=
1
;
for
(
const
auto
&
ast
:
children
)
res
+=
ast
->
checkSize
(
max_size
);
for
(
ASTs
::
const_iterator
it
=
children
.
begin
();
it
!=
children
.
end
();
++
it
)
res
+=
(
*
it
)
->
checkSize
(
max_size
);
if
(
res
>
max_size
)
throw
Exception
(
"AST is too big. Maximum: "
+
toString
(
max_size
),
ErrorCodes
::
TOO_BIG_AST
);
...
...
@@ -152,19 +129,19 @@ public:
*/
virtual
void
collectIdentifierNames
(
IdentifierNameSet
&
set
)
const
{
for
(
const
auto
&
ast
:
children
)
ast
->
collectIdentifierNames
(
set
);
for
(
ASTs
::
const_iterator
it
=
children
.
begin
();
it
!=
children
.
end
();
++
it
)
(
*
it
)
->
collectIdentifierNames
(
set
);
}
private:
size_t
checkDepthImpl
(
size_t
max_depth
,
size_t
level
)
const
{
size_t
res
=
level
+
1
;
for
(
const
auto
&
ast
:
children
)
for
(
ASTs
::
const_iterator
it
=
children
.
begin
();
it
!=
children
.
end
();
++
it
)
{
if
(
level
>=
max_depth
)
throw
Exception
(
"AST is too deep. Maximum: "
+
toString
(
max_depth
),
ErrorCodes
::
TOO_DEEP_AST
);
res
=
std
::
max
(
res
,
ast
->
checkDepthImpl
(
max_depth
,
level
+
1
));
res
=
std
::
max
(
res
,
(
*
it
)
->
checkDepthImpl
(
max_depth
,
level
+
1
));
}
return
res
;
...
...
dbms/src/DataStreams/tests/filter_stream.cpp
浏览文件 @
310ed66b
...
...
@@ -41,6 +41,7 @@ int main(int argc, char ** argv)
formatAST
(
*
ast
,
std
::
cerr
);
std
::
cerr
<<
std
::
endl
;
std
::
cerr
<<
ast
->
getTreeID
()
<<
std
::
endl
;
Context
context
;
context
.
getColumns
().
push_back
(
NameAndTypePair
(
"number"
,
new
DataTypeUInt64
));
...
...
dbms/src/DataStreams/tests/filter_stream_hitlog.cpp
浏览文件 @
310ed66b
...
...
@@ -106,6 +106,7 @@ int main(int argc, char ** argv)
formatAST
(
*
ast
,
std
::
cerr
);
std
::
cerr
<<
std
::
endl
;
std
::
cerr
<<
ast
->
getTreeID
()
<<
std
::
endl
;
/// создаём объект существующей таблицы хит лога
...
...
dbms/src/Interpreters/ExpressionAnalyzer.cpp
浏览文件 @
310ed66b
...
...
@@ -1653,43 +1653,10 @@ void ExpressionAnalyzer::appendProjectResult(DB::ExpressionActionsChain & chain,
NamesWithAliases
result_columns
;
ASTs
asts
=
select_query
->
select_expression_list
->
children
;
/// Выбор имён для столбцов результата.
size_t
i
=
1
;
for
(
const
auto
&
ast
:
asts
)
{
String
source_column_name
=
ast
->
getColumnName
();
String
result_column_name
=
ast
->
tryGetAlias
();
/// Если не задан алиас - нужно сгенерировать какое-нибудь имя автоматически.
if
(
result_column_name
.
empty
())
{
if
(
typeid_cast
<
const
ASTLiteral
*>
(
ast
.
get
())
||
typeid_cast
<
const
ASTIdentifier
*>
(
ast
.
get
()))
{
/// Если выражение простое, то будем использовать его имя.
result_column_name
=
source_column_name
;
}
else
if
(
auto
func
=
typeid_cast
<
const
ASTFunction
*>
(
ast
.
get
()))
{
/// Для функций используем имя вида _1_func, где func - имя функции.
WriteBufferFromString
wb
(
result_column_name
);
writeChar
(
'_'
,
wb
);
writeIntText
(
i
,
wb
);
writeChar
(
'_'
,
wb
);
writeString
(
func
->
name
,
wb
);
}
else
for
(
size_t
i
=
0
;
i
<
asts
.
size
();
++
i
)
{
/// Если выражение сложное и для него не задан алиас, будем использовать имя вида _1, _2, ...
WriteBufferFromString
wb
(
result_column_name
);
writeChar
(
'_'
,
wb
);
writeIntText
(
i
,
wb
);
}
}
result_columns
.
emplace_back
(
source_column_name
,
result_column_name
);
step
.
required_output
.
emplace_back
(
result_columns
.
back
().
second
);
++
i
;
result_columns
.
emplace_back
(
asts
[
i
]
->
getColumnName
(),
asts
[
i
]
->
getAliasOrColumnName
());
step
.
required_output
.
push_back
(
result_columns
.
back
().
second
);
}
step
.
actions
->
add
(
ExpressionAction
::
project
(
result_columns
));
...
...
dbms/src/Interpreters/LogicalExpressionsOptimizer.cpp
浏览文件 @
310ed66b
...
...
@@ -12,7 +12,7 @@
namespace
DB
{
LogicalExpressionsOptimizer
::
OrWithExpression
::
OrWithExpression
(
ASTFunction
*
or_function_
,
UInt128
expression_
)
LogicalExpressionsOptimizer
::
OrWithExpression
::
OrWithExpression
(
ASTFunction
*
or_function_
,
const
std
::
string
&
expression_
)
:
or_function
(
or_function_
),
expression
(
expression_
)
{
}
...
...
dbms/src/Parsers/tests/select_parser.cpp
浏览文件 @
310ed66b
...
...
@@ -27,6 +27,7 @@ int main(int argc, char ** argv)
std
::
cout
<<
"Success."
<<
std
::
endl
;
formatAST
(
*
ast
,
std
::
cerr
);
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
<<
ast
->
getTreeID
()
<<
std
::
endl
;
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录