Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
667db6b5
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,发现更多精彩内容 >>
提交
667db6b5
编写于
11月 13, 2016
作者:
A
alexey-milovidov
提交者:
GitHub
11月 13, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #182 from artpaul/master
move function bodies to cpp
上级
b3646825
e1cda4b7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
231 addition
and
143 deletion
+231
-143
dbms/CMakeLists.txt
dbms/CMakeLists.txt
+1
-0
dbms/include/DB/DataStreams/DistinctBlockInputStream.h
dbms/include/DB/DataStreams/DistinctBlockInputStream.h
+6
-18
dbms/include/DB/Functions/FunctionsMiscellaneous.h
dbms/include/DB/Functions/FunctionsMiscellaneous.h
+12
-12
dbms/include/DB/Interpreters/InterpreterSelectQuery.h
dbms/include/DB/Interpreters/InterpreterSelectQuery.h
+3
-17
dbms/include/DB/Parsers/CommonParsers.h
dbms/include/DB/Parsers/CommonParsers.h
+18
-94
dbms/include/DB/Parsers/ParserSelectQuery.h
dbms/include/DB/Parsers/ParserSelectQuery.h
+2
-2
dbms/src/DataStreams/DistinctBlockInputStream.cpp
dbms/src/DataStreams/DistinctBlockInputStream.cpp
+15
-0
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+22
-0
dbms/src/Parsers/CommonParsers.cpp
dbms/src/Parsers/CommonParsers.cpp
+152
-0
未找到文件。
dbms/CMakeLists.txt
浏览文件 @
667db6b5
...
...
@@ -829,6 +829,7 @@ add_library (dbms
src/Parsers/ASTIdentifier.cpp
src/Parsers/ASTSampleRatio.cpp
src/Parsers/ASTTablesInSelectQuery.cpp
src/Parsers/CommonParsers.cpp
src/Parsers/IAST.cpp
src/Parsers/IParserBase.cpp
src/Parsers/ExpressionElementParsers.cpp
...
...
dbms/include/DB/DataStreams/DistinctBlockInputStream.h
浏览文件 @
667db6b5
#pragma once
#include <DB/DataStreams/IProfilingBlockInputStream.h>
#include <DB/Common/HashTable/HashSet.h>
#include <DB/Interpreters/AggregationCommon.h>
#include <DB/Common/SipHash.h>
#include <DB/Common/UInt128.h>
#include <DB/DataStreams/IProfilingBlockInputStream.h>
#include <DB/Interpreters/Limits.h>
namespace
DB
{
...
...
@@ -22,25 +22,13 @@ public:
String
getName
()
const
override
{
return
"Distinct"
;
}
String
getID
()
const
override
{
std
::
stringstream
res
;
res
<<
"Distinct("
<<
children
.
back
()
->
getID
()
<<
")"
;
return
res
.
str
();
}
String
getID
()
const
override
;
protected:
Block
readImpl
()
override
;
private:
bool
checkLimits
()
const
{
if
(
max_rows
&&
set
.
size
()
>
max_rows
)
return
false
;
if
(
max_bytes
&&
set
.
getBufferSizeInBytes
()
>
max_bytes
)
return
false
;
return
true
;
}
private:
bool
checkLimits
()
const
;
Names
columns_names
;
...
...
dbms/include/DB/Functions/FunctionsMiscellaneous.h
浏览文件 @
667db6b5
...
...
@@ -1299,18 +1299,18 @@ private:
template
<
typename
F
>
void
dispatchForSourceType
(
const
IDataType
&
src_type
,
F
&&
f
)
const
{
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeUInt8
*>
(
&
src_type
))
f
(
UInt8
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeUInt16
*>
(
&
src_type
))
f
(
UInt16
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeUInt32
*>
(
&
src_type
))
f
(
UInt32
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeUInt64
*>
(
&
src_type
))
f
(
UInt64
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeInt8
*>
(
&
src_type
))
f
(
Int8
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeInt16
*>
(
&
src_type
))
f
(
Int16
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeInt32
*>
(
&
src_type
))
f
(
Int32
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeInt64
*>
(
&
src_type
))
f
(
Int64
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeFloat32
*>
(
&
src_type
))
f
(
Float32
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeFloat64
*>
(
&
src_type
))
f
(
Float64
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeDate
*>
(
&
src_type
))
f
(
DataTypeDate
::
FieldType
());
else
if
(
auto
src_type_concrete
=
typeid_cast
<
const
DataTypeDateTime
*>
(
&
src_type
))
f
(
DataTypeDateTime
::
FieldType
());
if
(
typeid_cast
<
const
DataTypeUInt8
*>
(
&
src_type
))
f
(
UInt8
());
else
if
(
typeid_cast
<
const
DataTypeUInt16
*>
(
&
src_type
))
f
(
UInt16
());
else
if
(
typeid_cast
<
const
DataTypeUInt32
*>
(
&
src_type
))
f
(
UInt32
());
else
if
(
typeid_cast
<
const
DataTypeUInt64
*>
(
&
src_type
))
f
(
UInt64
());
else
if
(
typeid_cast
<
const
DataTypeInt8
*>
(
&
src_type
))
f
(
Int8
());
else
if
(
typeid_cast
<
const
DataTypeInt16
*>
(
&
src_type
))
f
(
Int16
());
else
if
(
typeid_cast
<
const
DataTypeInt32
*>
(
&
src_type
))
f
(
Int32
());
else
if
(
typeid_cast
<
const
DataTypeInt64
*>
(
&
src_type
))
f
(
Int64
());
else
if
(
typeid_cast
<
const
DataTypeFloat32
*>
(
&
src_type
))
f
(
Float32
());
else
if
(
typeid_cast
<
const
DataTypeFloat64
*>
(
&
src_type
))
f
(
Float64
());
else
if
(
typeid_cast
<
const
DataTypeDate
*>
(
&
src_type
))
f
(
DataTypeDate
::
FieldType
());
else
if
(
typeid_cast
<
const
DataTypeDateTime
*>
(
&
src_type
))
f
(
DataTypeDateTime
::
FieldType
());
else
throw
Exception
(
"Argument for function "
+
getName
()
+
" must have numeric type."
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
);
...
...
dbms/include/DB/Interpreters/InterpreterSelectQuery.h
浏览文件 @
667db6b5
...
...
@@ -144,25 +144,11 @@ private:
void
executeSubqueriesInSetsAndJoins
(
std
::
unordered_map
<
String
,
SubqueryForSet
>
&
subqueries_for_sets
);
template
<
typename
Transform
>
void
transformStreams
(
Transform
&&
transform
)
{
for
(
auto
&
stream
:
streams
)
transform
(
stream
);
void
transformStreams
(
Transform
&&
transform
);
if
(
stream_with_non_joined_data
)
transform
(
stream_with_non_joined_data
);
}
bool
hasNoData
()
const
{
return
streams
.
empty
()
&&
!
stream_with_non_joined_data
;
}
bool
hasMoreThanOneStream
()
const
{
return
streams
.
size
()
+
(
stream_with_non_joined_data
?
1
:
0
)
>
1
;
}
bool
hasNoData
()
const
;
bool
hasMoreThanOneStream
()
const
;
void
ignoreWithTotals
();
...
...
dbms/include/DB/Parsers/CommonParsers.h
浏览文件 @
667db6b5
#pragma once
#include <string.h> /// strncmp, strncasecmp
#include <DB/Parsers/IParserBase.h>
namespace
DB
{
/** Если прямо сейчас не s, то ошибка.
* Если word_boundary установлен в true, и последний символ строки - словарный (\w),
* то проверяется, что последующий символ строки не словарный.
...
...
@@ -22,26 +18,12 @@ private:
bool
case_insensitive
;
public:
ParserString
(
const
char
*
s_
,
bool
word_boundary_
=
false
,
bool
case_insensitive_
=
false
)
:
s
(
s_
),
s_size
(
strlen
(
s
)),
word_boundary
(
word_boundary_
),
case_insensitive
(
case_insensitive_
)
{}
ParserString
(
const
char
*
s_
,
bool
word_boundary_
=
false
,
bool
case_insensitive_
=
false
);
protected:
const
char
*
getName
()
const
{
return
s
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
static_cast
<
ssize_t
>
(
s_size
)
>
end
-
pos
||
(
case_insensitive
?
strncasecmp
:
strncmp
)(
pos
,
s
,
s_size
))
return
false
;
else
{
if
(
word_boundary
&&
s_size
&&
isWordCharASCII
(
s
[
s_size
-
1
])
&&
pos
+
s_size
!=
end
&&
isWordCharASCII
(
pos
[
s_size
]))
return
false
;
pos
+=
s_size
;
return
true
;
}
}
const
char
*
getName
()
const
override
;
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
...
...
@@ -50,74 +32,32 @@ protected:
class
ParserWhiteSpace
:
public
IParserBase
{
public:
ParserWhiteSpace
(
bool
allow_newlines_
=
true
)
:
allow_newlines
(
allow_newlines_
)
{}
ParserWhiteSpace
(
bool
allow_newlines_
=
true
)
;
protected:
bool
allow_newlines
;
const
char
*
getName
()
const
{
return
"white space"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
Pos
begin
=
pos
;
while
(
pos
<
end
&&
(
*
pos
==
' '
||
*
pos
==
'\t'
||
(
allow_newlines
&&
*
pos
==
'\n'
)
||
*
pos
==
'\r'
||
*
pos
==
'\f'
))
++
pos
;
const
char
*
getName
()
const
override
;
return
pos
!=
begin
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
class
ParserCStyleComment
:
public
IParserBase
{
protected:
const
char
*
getName
()
const
{
return
"C-style comment"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
end
-
pos
>=
4
&&
pos
[
0
]
==
'/'
&&
pos
[
1
]
==
'*'
)
{
pos
+=
2
;
while
(
end
-
pos
>=
2
&&
(
pos
[
0
]
!=
'*'
||
pos
[
1
]
!=
'/'
))
++
pos
;
if
(
end
-
pos
<
2
)
{
expected
=
"closing of C-style comment '*/'"
;
return
false
;
}
else
{
pos
+=
2
;
return
true
;
}
}
else
return
false
;
}
const
char
*
getName
()
const
override
;
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
class
ParserSQLStyleComment
:
public
IParserBase
{
protected:
const
char
*
getName
()
const
{
return
"SQL-style comment"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
end
-
pos
>=
2
&&
pos
[
0
]
==
'-'
&&
pos
[
1
]
==
'-'
)
{
pos
+=
2
;
while
(
pos
!=
end
&&
*
pos
!=
'\n'
)
++
pos
;
if
(
pos
!=
end
)
++
pos
;
return
true
;
}
else
return
false
;
}
const
char
*
getName
()
const
override
;
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
...
...
@@ -126,39 +66,23 @@ protected:
class
ParserComment
:
public
IParserBase
{
protected:
const
char
*
getName
()
const
{
return
"comment"
;
}
const
char
*
getName
()
const
override
;
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
ParserCStyleComment
p1
;
ParserSQLStyleComment
p2
;
return
p1
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
)
||
p2
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
);
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
class
ParserWhiteSpaceOrComments
:
public
IParserBase
{
public:
ParserWhiteSpaceOrComments
(
bool
allow_newlines_outside_comments_
=
true
)
:
allow_newlines_outside_comments
(
allow_newlines_outside_comments_
)
{}
ParserWhiteSpaceOrComments
(
bool
allow_newlines_outside_comments_
=
true
)
;
protected:
bool
allow_newlines_outside_comments
;
const
char
*
getName
()
const
{
return
"white space or comments"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
ParserWhiteSpace
p1
(
allow_newlines_outside_comments
);
ParserComment
p2
;
const
char
*
getName
()
const
override
;
bool
res
=
false
;
while
(
p1
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
)
||
p2
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
))
res
=
true
;
return
res
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
}
dbms/include/DB/Parsers/ParserSelectQuery.h
浏览文件 @
667db6b5
...
...
@@ -10,8 +10,8 @@ namespace DB
class
ParserSelectQuery
:
public
ParserQueryWithOutput
{
protected:
const
char
*
getName
()
const
{
return
"SELECT query"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
);
const
char
*
getName
()
const
override
{
return
"SELECT query"
;
}
bool
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
override
;
};
}
dbms/src/DataStreams/DistinctBlockInputStream.cpp
浏览文件 @
667db6b5
...
...
@@ -20,6 +20,12 @@ DistinctBlockInputStream::DistinctBlockInputStream(BlockInputStreamPtr input_, c
children
.
push_back
(
input_
);
}
String
DistinctBlockInputStream
::
getID
()
const
{
std
::
stringstream
res
;
res
<<
"Distinct("
<<
children
.
back
()
->
getID
()
<<
")"
;
return
res
.
str
();
}
Block
DistinctBlockInputStream
::
readImpl
()
{
...
...
@@ -114,4 +120,13 @@ Block DistinctBlockInputStream::readImpl()
}
}
bool
DistinctBlockInputStream
::
checkLimits
()
const
{
if
(
max_rows
&&
set
.
size
()
>
max_rows
)
return
false
;
if
(
max_bytes
&&
set
.
getBufferSizeInBytes
()
>
max_bytes
)
return
false
;
return
true
;
}
}
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
667db6b5
...
...
@@ -1229,6 +1229,28 @@ void InterpreterSelectQuery::executeSubqueriesInSetsAndJoins(SubqueriesForSets &
streams
[
0
]
=
std
::
make_shared
<
CreatingSetsBlockInputStream
>
(
streams
[
0
],
subqueries_for_sets
,
settings
.
limits
);
}
template
<
typename
Transform
>
void
InterpreterSelectQuery
::
transformStreams
(
Transform
&&
transform
)
{
for
(
auto
&
stream
:
streams
)
transform
(
stream
);
if
(
stream_with_non_joined_data
)
transform
(
stream_with_non_joined_data
);
}
bool
InterpreterSelectQuery
::
hasNoData
()
const
{
return
streams
.
empty
()
&&
!
stream_with_non_joined_data
;
}
bool
InterpreterSelectQuery
::
hasMoreThanOneStream
()
const
{
return
streams
.
size
()
+
(
stream_with_non_joined_data
?
1
:
0
)
>
1
;
}
void
InterpreterSelectQuery
::
ignoreWithTotals
()
{
...
...
dbms/src/Parsers/CommonParsers.cpp
0 → 100644
浏览文件 @
667db6b5
#include <DB/Parsers/CommonParsers.h>
#include <string.h> /// strncmp, strncasecmp
namespace
DB
{
ParserString
::
ParserString
(
const
char
*
s_
,
bool
word_boundary_
,
bool
case_insensitive_
)
:
s
(
s_
)
,
s_size
(
strlen
(
s
))
,
word_boundary
(
word_boundary_
)
,
case_insensitive
(
case_insensitive_
)
{
}
const
char
*
ParserString
::
getName
()
const
{
return
s
;
}
bool
ParserString
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
static_cast
<
ssize_t
>
(
s_size
)
>
end
-
pos
||
(
case_insensitive
?
strncasecmp
:
strncmp
)(
pos
,
s
,
s_size
))
return
false
;
else
{
if
(
word_boundary
&&
s_size
&&
isWordCharASCII
(
s
[
s_size
-
1
])
&&
pos
+
s_size
!=
end
&&
isWordCharASCII
(
pos
[
s_size
]))
return
false
;
pos
+=
s_size
;
return
true
;
}
}
ParserWhiteSpace
::
ParserWhiteSpace
(
bool
allow_newlines_
)
:
allow_newlines
(
allow_newlines_
)
{
}
const
char
*
ParserWhiteSpace
::
getName
()
const
{
return
"white space"
;
}
bool
ParserWhiteSpace
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
Pos
begin
=
pos
;
while
(
pos
<
end
&&
(
*
pos
==
' '
||
*
pos
==
'\t'
||
(
allow_newlines
&&
*
pos
==
'\n'
)
||
*
pos
==
'\r'
||
*
pos
==
'\f'
))
++
pos
;
return
pos
!=
begin
;
}
const
char
*
ParserCStyleComment
::
getName
()
const
{
return
"C-style comment"
;
}
bool
ParserCStyleComment
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
end
-
pos
>=
4
&&
pos
[
0
]
==
'/'
&&
pos
[
1
]
==
'*'
)
{
pos
+=
2
;
while
(
end
-
pos
>=
2
&&
(
pos
[
0
]
!=
'*'
||
pos
[
1
]
!=
'/'
))
++
pos
;
if
(
end
-
pos
<
2
)
{
expected
=
"closing of C-style comment '*/'"
;
return
false
;
}
else
{
pos
+=
2
;
return
true
;
}
}
else
return
false
;
}
const
char
*
ParserSQLStyleComment
::
getName
()
const
{
return
"SQL-style comment"
;
}
bool
ParserSQLStyleComment
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
if
(
end
-
pos
>=
2
&&
pos
[
0
]
==
'-'
&&
pos
[
1
]
==
'-'
)
{
pos
+=
2
;
while
(
pos
!=
end
&&
*
pos
!=
'\n'
)
++
pos
;
if
(
pos
!=
end
)
++
pos
;
return
true
;
}
else
return
false
;
}
const
char
*
ParserComment
::
getName
()
const
{
return
"comment"
;
}
bool
ParserComment
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
ParserCStyleComment
p1
;
ParserSQLStyleComment
p2
;
return
p1
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
)
||
p2
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
);
}
ParserWhiteSpaceOrComments
::
ParserWhiteSpaceOrComments
(
bool
allow_newlines_outside_comments_
)
:
allow_newlines_outside_comments
(
allow_newlines_outside_comments_
)
{
}
const
char
*
ParserWhiteSpaceOrComments
::
getName
()
const
{
return
"white space or comments"
;
}
bool
ParserWhiteSpaceOrComments
::
parseImpl
(
Pos
&
pos
,
Pos
end
,
ASTPtr
&
node
,
Pos
&
max_parsed_pos
,
Expected
&
expected
)
{
ParserWhiteSpace
p1
(
allow_newlines_outside_comments
);
ParserComment
p2
;
bool
res
=
false
;
while
(
p1
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
)
||
p2
.
ignore
(
pos
,
end
,
max_parsed_pos
,
expected
))
res
=
true
;
return
res
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录