Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
166018e4
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,发现更多精彩内容 >>
提交
166018e4
编写于
6月 19, 2019
作者:
Z
zhang2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code style & rename minmax, set
上级
a50aea09
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
114 addition
and
113 deletion
+114
-113
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp
+2
-2
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h
+1
-1
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp
+4
-3
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h
+1
-1
dbms/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h
...c/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h
+5
-5
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.cpp
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.cpp
+1
-1
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.h
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.h
+2
-2
dbms/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp
dbms/src/Storages/MergeTree/MergeTreeIndexMinMax.cpp
+25
-25
dbms/src/Storages/MergeTree/MergeTreeIndexMinMax.h
dbms/src/Storages/MergeTree/MergeTreeIndexMinMax.h
+19
-19
dbms/src/Storages/MergeTree/MergeTreeIndexSet.cpp
dbms/src/Storages/MergeTree/MergeTreeIndexSet.cpp
+29
-29
dbms/src/Storages/MergeTree/MergeTreeIndexSet.h
dbms/src/Storages/MergeTree/MergeTreeIndexSet.h
+19
-19
dbms/src/Storages/MergeTree/MergeTreeIndices.h
dbms/src/Storages/MergeTree/MergeTreeIndices.h
+4
-4
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
+2
-2
未找到文件。
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp
浏览文件 @
166018e4
...
...
@@ -518,7 +518,7 @@ BlockInputStreams MergeTreeDataSelectExecutor::readFromParts(
RangesInDataParts
parts_with_ranges
;
std
::
vector
<
std
::
pair
<
MergeTreeIndexPtr
,
IndexConditionPtr
>>
useful_indices
;
std
::
vector
<
std
::
pair
<
MergeTreeIndexPtr
,
MergeTree
IndexConditionPtr
>>
useful_indices
;
for
(
const
auto
&
index
:
data
.
skip_indices
)
{
auto
condition
=
index
->
createIndexCondition
(
query_info
,
context
);
...
...
@@ -998,7 +998,7 @@ MarkRanges MergeTreeDataSelectExecutor::markRangesFromPKRange(
MarkRanges
MergeTreeDataSelectExecutor
::
filterMarksUsingIndex
(
MergeTreeIndexPtr
index
,
IndexConditionPtr
condition
,
MergeTree
IndexConditionPtr
condition
,
MergeTreeData
::
DataPartPtr
part
,
const
MarkRanges
&
ranges
,
const
Settings
&
settings
)
const
...
...
dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h
浏览文件 @
166018e4
...
...
@@ -84,7 +84,7 @@ private:
MarkRanges
filterMarksUsingIndex
(
MergeTreeIndexPtr
index
,
IndexConditionPtr
condition
,
MergeTree
IndexConditionPtr
condition
,
MergeTreeData
::
DataPartPtr
part
,
const
MarkRanges
&
ranges
,
const
Settings
&
settings
)
const
;
...
...
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.cpp
浏览文件 @
166018e4
...
...
@@ -58,12 +58,12 @@ MergeTreeIndexAggregatorPtr MergeTreeIndexBloomFilter::createIndexAggregator() c
return
std
::
make_shared
<
MergeTreeIndexAggregatorBloomFilter
>
(
bits_per_row
,
hash_functions
,
columns
);
}
IndexConditionPtr
MergeTreeIndexBloomFilter
::
createIndexCondition
(
const
SelectQueryInfo
&
query_info
,
const
Context
&
context
)
const
MergeTree
IndexConditionPtr
MergeTreeIndexBloomFilter
::
createIndexCondition
(
const
SelectQueryInfo
&
query_info
,
const
Context
&
context
)
const
{
return
std
::
make_shared
<
MergeTreeIndexConditionBloomFilter
>
(
query_info
,
context
,
header
,
hash_functions
);
}
static
void
assertIndexColumnsType
(
const
Block
&
header
)
static
void
assertIndexColumnsType
(
const
Block
&
header
)
{
if
(
!
header
||
!
header
.
columns
())
throw
Exception
(
"Index must have columns."
,
ErrorCodes
::
INCORRECT_QUERY
);
...
...
@@ -81,7 +81,8 @@ static void assertIndexColumnsType(const Block &header)
}
}
std
::
unique_ptr
<
IMergeTreeIndex
>
bloomFilterIndexCreatorNew
(
const
NamesAndTypesList
&
columns
,
std
::
shared_ptr
<
ASTIndexDeclaration
>
node
,
const
Context
&
context
)
std
::
unique_ptr
<
IMergeTreeIndex
>
bloomFilterIndexCreatorNew
(
const
NamesAndTypesList
&
columns
,
std
::
shared_ptr
<
ASTIndexDeclaration
>
node
,
const
Context
&
context
)
{
if
(
node
->
name
.
empty
())
throw
Exception
(
"Index must have unique name."
,
ErrorCodes
::
INCORRECT_QUERY
);
...
...
dbms/src/Storages/MergeTree/MergeTreeIndexBloomFilter.h
浏览文件 @
166018e4
...
...
@@ -19,7 +19,7 @@ public:
MergeTreeIndexAggregatorPtr
createIndexAggregator
()
const
override
;
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query_info
,
const
Context
&
context
)
const
override
;
MergeTree
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query_info
,
const
Context
&
context
)
const
override
;
bool
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
override
;
...
...
dbms/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h
浏览文件 @
166018e4
...
...
@@ -9,7 +9,7 @@
namespace
DB
{
class
MergeTreeIndexConditionBloomFilter
:
public
IIndexCondition
class
MergeTreeIndexConditionBloomFilter
:
public
I
MergeTree
IndexCondition
{
public:
struct
RPNElement
...
...
@@ -44,9 +44,7 @@ public:
bool
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
granule
)
const
override
{
if
(
const
auto
&
bf_granule
=
typeid_cast
<
const
MergeTreeIndexGranuleBloomFilter
*>
(
granule
.
get
()))
{
return
mayBeTrueOnGranule
(
bf_granule
);
}
throw
Exception
(
"LOGICAL ERROR: require bloom filter index granule."
,
ErrorCodes
::
LOGICAL_ERROR
);
}
...
...
@@ -66,9 +64,11 @@ private:
bool
traverseASTIn
(
const
String
&
function_name
,
const
ASTPtr
&
key_ast
,
const
SetPtr
&
prepared_set
,
RPNElement
&
out
);
bool
traverseASTIn
(
const
String
&
function_name
,
const
ASTPtr
&
key_ast
,
const
DataTypePtr
&
type
,
const
ColumnPtr
&
column
,
RPNElement
&
out
);
bool
traverseASTIn
(
const
String
&
function_name
,
const
ASTPtr
&
key_ast
,
const
DataTypePtr
&
type
,
const
ColumnPtr
&
column
,
RPNElement
&
out
);
bool
traverseASTEquals
(
const
String
&
function_name
,
const
ASTPtr
&
key_ast
,
const
DataTypePtr
&
value_type
,
const
Field
&
value_field
,
RPNElement
&
out
);
bool
traverseASTEquals
(
const
String
&
function_name
,
const
ASTPtr
&
key_ast
,
const
DataTypePtr
&
value_type
,
const
Field
&
value_field
,
RPNElement
&
out
);
};
}
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.cpp
浏览文件 @
166018e4
...
...
@@ -486,7 +486,7 @@ MergeTreeIndexAggregatorPtr MergeTreeIndexFullText::createIndexAggregator() cons
return
std
::
make_shared
<
MergeTreeIndexAggregatorFullText
>
(
*
this
);
}
IndexConditionPtr
MergeTreeIndexFullText
::
createIndexCondition
(
MergeTree
IndexConditionPtr
MergeTreeIndexFullText
::
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
{
return
std
::
make_shared
<
MergeTreeConditionFullText
>
(
query
,
context
,
*
this
);
...
...
dbms/src/Storages/MergeTree/MergeTreeIndexFullText.h
浏览文件 @
166018e4
...
...
@@ -49,7 +49,7 @@ struct MergeTreeIndexAggregatorFullText : IMergeTreeIndexAggregator
};
class
MergeTreeConditionFullText
:
public
IIndexCondition
class
MergeTreeConditionFullText
:
public
I
MergeTree
IndexCondition
{
public:
MergeTreeConditionFullText
(
...
...
@@ -189,7 +189,7 @@ public:
MergeTreeIndexGranulePtr
createIndexGranule
()
const
override
;
MergeTreeIndexAggregatorPtr
createIndexAggregator
()
const
override
;
IndexConditionPtr
createIndexCondition
(
MergeTree
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
override
;
bool
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
override
;
...
...
dbms/src/Storages/MergeTree/MergeTree
MinMaxInde
x.cpp
→
dbms/src/Storages/MergeTree/MergeTree
IndexMinMa
x.cpp
浏览文件 @
166018e4
#include <Storages/MergeTree/MergeTree
MinMaxInde
x.h>
#include <Storages/MergeTree/MergeTree
IndexMinMa
x.h>
#include <Interpreters/ExpressionActions.h>
#include <Interpreters/ExpressionAnalyzer.h>
...
...
@@ -16,14 +16,14 @@ namespace ErrorCodes
}
MergeTree
MinMaxGranule
::
MergeTreeMinMaxGranule
(
const
MergeTreeMinMaxInde
x
&
index
)
MergeTree
IndexGranuleMinMax
::
MergeTreeIndexGranuleMinMax
(
const
MergeTreeIndexMinMa
x
&
index
)
:
IMergeTreeIndexGranule
(),
index
(
index
),
parallelogram
()
{}
MergeTree
MinMaxGranule
::
MergeTreeMinMaxGranule
(
const
MergeTree
MinMaxInde
x
&
index
,
std
::
vector
<
Range
>
&&
parallelogram
)
MergeTree
IndexGranuleMinMax
::
MergeTreeIndexGranuleMinMax
(
const
MergeTree
IndexMinMa
x
&
index
,
std
::
vector
<
Range
>
&&
parallelogram
)
:
IMergeTreeIndexGranule
(),
index
(
index
),
parallelogram
(
std
::
move
(
parallelogram
))
{}
void
MergeTree
MinMaxGranule
::
serializeBinary
(
WriteBuffer
&
ostr
)
const
void
MergeTree
IndexGranuleMinMax
::
serializeBinary
(
WriteBuffer
&
ostr
)
const
{
if
(
empty
())
throw
Exception
(
...
...
@@ -50,7 +50,7 @@ void MergeTreeMinMaxGranule::serializeBinary(WriteBuffer & ostr) const
}
}
void
MergeTree
MinMaxGranule
::
deserializeBinary
(
ReadBuffer
&
istr
)
void
MergeTree
IndexGranuleMinMax
::
deserializeBinary
(
ReadBuffer
&
istr
)
{
parallelogram
.
clear
();
Field
min_val
;
...
...
@@ -83,15 +83,15 @@ void MergeTreeMinMaxGranule::deserializeBinary(ReadBuffer & istr)
}
MergeTree
MinMaxAggregator
::
MergeTreeMinMaxAggregator
(
const
MergeTreeMinMaxInde
x
&
index
)
MergeTree
IndexAggregatorMinMax
::
MergeTreeIndexAggregatorMinMax
(
const
MergeTreeIndexMinMa
x
&
index
)
:
index
(
index
)
{}
MergeTreeIndexGranulePtr
MergeTree
MinMaxAggregator
::
getGranuleAndReset
()
MergeTreeIndexGranulePtr
MergeTree
IndexAggregatorMinMax
::
getGranuleAndReset
()
{
return
std
::
make_shared
<
MergeTree
MinMaxGranule
>
(
index
,
std
::
move
(
parallelogram
));
return
std
::
make_shared
<
MergeTree
IndexGranuleMinMax
>
(
index
,
std
::
move
(
parallelogram
));
}
void
MergeTree
MinMaxAggregator
::
update
(
const
Block
&
block
,
size_t
*
pos
,
size_t
limit
)
void
MergeTree
IndexAggregatorMinMax
::
update
(
const
Block
&
block
,
size_t
*
pos
,
size_t
limit
)
{
if
(
*
pos
>=
block
.
rows
())
throw
Exception
(
...
...
@@ -122,21 +122,21 @@ void MergeTreeMinMaxAggregator::update(const Block & block, size_t * pos, size_t
}
M
inMaxCondition
::
MinMaxCondition
(
M
ergeTreeIndexConditionMinMax
::
MergeTreeIndexConditionMinMax
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
,
const
MergeTree
MinMaxInde
x
&
index
)
:
IIndexCondition
(),
index
(
index
),
condition
(
query
,
context
,
index
.
columns
,
index
.
expr
)
{}
const
MergeTree
IndexMinMa
x
&
index
)
:
I
MergeTree
IndexCondition
(),
index
(
index
),
condition
(
query
,
context
,
index
.
columns
,
index
.
expr
)
{}
bool
M
inMaxCondition
::
alwaysUnknownOrTrue
()
const
bool
M
ergeTreeIndexConditionMinMax
::
alwaysUnknownOrTrue
()
const
{
return
condition
.
alwaysUnknownOrTrue
();
}
bool
M
inMaxCondition
::
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
bool
M
ergeTreeIndexConditionMinMax
::
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
{
std
::
shared_ptr
<
MergeTree
MinMaxGranule
>
granule
=
std
::
dynamic_pointer_cast
<
MergeTree
MinMaxGranule
>
(
idx_granule
);
std
::
shared_ptr
<
MergeTree
IndexGranuleMinMax
>
granule
=
std
::
dynamic_pointer_cast
<
MergeTree
IndexGranuleMinMax
>
(
idx_granule
);
if
(
!
granule
)
throw
Exception
(
"Minmax index condition got a granule with the wrong type."
,
ErrorCodes
::
LOGICAL_ERROR
);
...
...
@@ -147,25 +147,25 @@ bool MinMaxCondition::mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule) c
}
MergeTreeIndexGranulePtr
MergeTree
MinMaxInde
x
::
createIndexGranule
()
const
MergeTreeIndexGranulePtr
MergeTree
IndexMinMa
x
::
createIndexGranule
()
const
{
return
std
::
make_shared
<
MergeTree
MinMaxGranule
>
(
*
this
);
return
std
::
make_shared
<
MergeTree
IndexGranuleMinMax
>
(
*
this
);
}
MergeTreeIndexAggregatorPtr
MergeTree
MinMaxInde
x
::
createIndexAggregator
()
const
MergeTreeIndexAggregatorPtr
MergeTree
IndexMinMa
x
::
createIndexAggregator
()
const
{
return
std
::
make_shared
<
MergeTree
MinMaxAggregator
>
(
*
this
);
return
std
::
make_shared
<
MergeTree
IndexAggregatorMinMax
>
(
*
this
);
}
IndexConditionPtr
MergeTreeMinMaxInde
x
::
createIndexCondition
(
MergeTreeIndexConditionPtr
MergeTreeIndexMinMa
x
::
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
{
return
std
::
make_shared
<
M
inMaxCondition
>
(
query
,
context
,
*
this
);
return
std
::
make_shared
<
M
ergeTreeIndexConditionMinMax
>
(
query
,
context
,
*
this
);
};
bool
MergeTree
MinMaxInde
x
::
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
bool
MergeTree
IndexMinMa
x
::
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
{
const
String
column_name
=
node
->
getColumnName
();
...
...
@@ -210,7 +210,7 @@ std::unique_ptr<IMergeTreeIndex> minmaxIndexCreator(
data_types
.
emplace_back
(
column
.
type
);
}
return
std
::
make_unique
<
MergeTree
MinMaxInde
x
>
(
return
std
::
make_unique
<
MergeTree
IndexMinMa
x
>
(
node
->
name
,
std
::
move
(
minmax_expr
),
columns
,
data_types
,
sample
,
node
->
granularity
);
}
...
...
dbms/src/Storages/MergeTree/MergeTree
MinMaxInde
x.h
→
dbms/src/Storages/MergeTree/MergeTree
IndexMinMa
x.h
浏览文件 @
166018e4
...
...
@@ -10,62 +10,62 @@
namespace
DB
{
class
MergeTree
MinMaxInde
x
;
class
MergeTree
IndexMinMa
x
;
struct
MergeTree
MinMaxGranule
:
public
IMergeTreeIndexGranule
struct
MergeTree
IndexGranuleMinMax
:
public
IMergeTreeIndexGranule
{
explicit
MergeTree
MinMaxGranule
(
const
MergeTreeMinMaxInde
x
&
index
);
MergeTree
MinMaxGranule
(
const
MergeTreeMinMaxInde
x
&
index
,
std
::
vector
<
Range
>
&&
parallelogram
);
~
MergeTree
MinMaxGranule
()
override
=
default
;
explicit
MergeTree
IndexGranuleMinMax
(
const
MergeTreeIndexMinMa
x
&
index
);
MergeTree
IndexGranuleMinMax
(
const
MergeTreeIndexMinMa
x
&
index
,
std
::
vector
<
Range
>
&&
parallelogram
);
~
MergeTree
IndexGranuleMinMax
()
override
=
default
;
void
serializeBinary
(
WriteBuffer
&
ostr
)
const
override
;
void
deserializeBinary
(
ReadBuffer
&
istr
)
override
;
bool
empty
()
const
override
{
return
parallelogram
.
empty
();
}
const
MergeTree
MinMaxInde
x
&
index
;
const
MergeTree
IndexMinMa
x
&
index
;
std
::
vector
<
Range
>
parallelogram
;
};
struct
MergeTree
MinMaxAggregator
:
IMergeTreeIndexAggregator
struct
MergeTree
IndexAggregatorMinMax
:
IMergeTreeIndexAggregator
{
explicit
MergeTree
MinMaxAggregator
(
const
MergeTreeMinMaxInde
x
&
index
);
~
MergeTree
MinMaxAggregator
()
override
=
default
;
explicit
MergeTree
IndexAggregatorMinMax
(
const
MergeTreeIndexMinMa
x
&
index
);
~
MergeTree
IndexAggregatorMinMax
()
override
=
default
;
bool
empty
()
const
override
{
return
parallelogram
.
empty
();
}
MergeTreeIndexGranulePtr
getGranuleAndReset
()
override
;
void
update
(
const
Block
&
block
,
size_t
*
pos
,
size_t
limit
)
override
;
const
MergeTree
MinMaxInde
x
&
index
;
const
MergeTree
IndexMinMa
x
&
index
;
std
::
vector
<
Range
>
parallelogram
;
};
class
M
inMaxCondition
:
public
I
IndexCondition
class
M
ergeTreeIndexConditionMinMax
:
public
IMergeTree
IndexCondition
{
public:
M
inMaxCondition
(
M
ergeTreeIndexConditionMinMax
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
,
const
MergeTree
MinMaxInde
x
&
index
);
const
MergeTree
IndexMinMa
x
&
index
);
bool
alwaysUnknownOrTrue
()
const
override
;
bool
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
override
;
~
M
inMaxCondition
()
override
=
default
;
~
M
ergeTreeIndexConditionMinMax
()
override
=
default
;
private:
const
MergeTree
MinMaxInde
x
&
index
;
const
MergeTree
IndexMinMa
x
&
index
;
KeyCondition
condition
;
};
class
MergeTree
MinMaxInde
x
:
public
IMergeTreeIndex
class
MergeTree
IndexMinMa
x
:
public
IMergeTreeIndex
{
public:
MergeTree
MinMaxInde
x
(
MergeTree
IndexMinMa
x
(
String
name_
,
ExpressionActionsPtr
expr_
,
const
Names
&
columns_
,
...
...
@@ -74,12 +74,12 @@ public:
size_t
granularity_
)
:
IMergeTreeIndex
(
name_
,
expr_
,
columns_
,
data_types_
,
header_
,
granularity_
)
{}
~
MergeTree
MinMaxInde
x
()
override
=
default
;
~
MergeTree
IndexMinMa
x
()
override
=
default
;
MergeTreeIndexGranulePtr
createIndexGranule
()
const
override
;
MergeTreeIndexAggregatorPtr
createIndexAggregator
()
const
override
;
IndexConditionPtr
createIndexCondition
(
MergeTree
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
override
;
bool
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
override
;
...
...
dbms/src/Storages/MergeTree/MergeTree
SetSkippingIndex
.cpp
→
dbms/src/Storages/MergeTree/MergeTree
IndexSet
.cpp
浏览文件 @
166018e4
#include <Storages/MergeTree/MergeTree
SetSkippingIndex
.h>
#include <Storages/MergeTree/MergeTree
IndexSet
.h>
#include <Interpreters/ExpressionActions.h>
#include <Interpreters/ExpressionAnalyzer.h>
...
...
@@ -21,18 +21,18 @@ namespace ErrorCodes
const
Field
UNKNOWN_FIELD
(
3u
);
MergeTree
SetIndexGranule
::
MergeTreeSetIndexGranule
(
const
MergeTreeSetSkippingIndex
&
index
)
MergeTree
IndexGranuleSet
::
MergeTreeIndexGranuleSet
(
const
MergeTreeIndexSet
&
index
)
:
IMergeTreeIndexGranule
()
,
index
(
index
)
,
block
(
index
.
header
.
cloneEmpty
())
{}
MergeTree
SetIndexGranule
::
MergeTreeSetIndexGranule
(
const
MergeTree
SetSkippingIndex
&
index
,
MutableColumns
&&
mutable_columns
)
MergeTree
IndexGranuleSet
::
MergeTreeIndexGranuleSet
(
const
MergeTree
IndexSet
&
index
,
MutableColumns
&&
mutable_columns
)
:
IMergeTreeIndexGranule
()
,
index
(
index
)
,
block
(
index
.
header
.
cloneWithColumns
(
std
::
move
(
mutable_columns
)))
{}
void
MergeTree
SetIndexGranule
::
serializeBinary
(
WriteBuffer
&
ostr
)
const
void
MergeTree
IndexGranuleSet
::
serializeBinary
(
WriteBuffer
&
ostr
)
const
{
if
(
empty
())
throw
Exception
(
...
...
@@ -64,7 +64,7 @@ void MergeTreeSetIndexGranule::serializeBinary(WriteBuffer & ostr) const
}
}
void
MergeTree
SetIndexGranule
::
deserializeBinary
(
ReadBuffer
&
istr
)
void
MergeTree
IndexGranuleSet
::
deserializeBinary
(
ReadBuffer
&
istr
)
{
block
.
clear
();
...
...
@@ -94,7 +94,7 @@ void MergeTreeSetIndexGranule::deserializeBinary(ReadBuffer & istr)
}
MergeTree
SetIndexAggregator
::
MergeTreeSetIndexAggregator
(
const
MergeTreeSetSkippingIndex
&
index
)
MergeTree
IndexAggregatorSet
::
MergeTreeIndexAggregatorSet
(
const
MergeTreeIndexSet
&
index
)
:
index
(
index
),
columns
(
index
.
header
.
cloneEmptyColumns
())
{
ColumnRawPtrs
column_ptrs
;
...
...
@@ -111,7 +111,7 @@ MergeTreeSetIndexAggregator::MergeTreeSetIndexAggregator(const MergeTreeSetSkipp
columns
=
index
.
header
.
cloneEmptyColumns
();
}
void
MergeTree
SetIndexAggregator
::
update
(
const
Block
&
block
,
size_t
*
pos
,
size_t
limit
)
void
MergeTree
IndexAggregatorSet
::
update
(
const
Block
&
block
,
size_t
*
pos
,
size_t
limit
)
{
if
(
*
pos
>=
block
.
rows
())
throw
Exception
(
...
...
@@ -164,7 +164,7 @@ void MergeTreeSetIndexAggregator::update(const Block & block, size_t * pos, size
}
template
<
typename
Method
>
bool
MergeTree
SetIndexAggregator
::
buildFilter
(
bool
MergeTree
IndexAggregatorSet
::
buildFilter
(
Method
&
method
,
const
ColumnRawPtrs
&
column_ptrs
,
IColumn
::
Filter
&
filter
,
...
...
@@ -190,9 +190,9 @@ bool MergeTreeSetIndexAggregator::buildFilter(
return
has_new_data
;
}
MergeTreeIndexGranulePtr
MergeTree
SetIndexAggregator
::
getGranuleAndReset
()
MergeTreeIndexGranulePtr
MergeTree
IndexAggregatorSet
::
getGranuleAndReset
()
{
auto
granule
=
std
::
make_shared
<
MergeTree
SetIndexGranule
>
(
index
,
std
::
move
(
columns
));
auto
granule
=
std
::
make_shared
<
MergeTree
IndexGranuleSet
>
(
index
,
std
::
move
(
columns
));
switch
(
data
.
type
)
{
...
...
@@ -212,11 +212,11 @@ MergeTreeIndexGranulePtr MergeTreeSetIndexAggregator::getGranuleAndReset()
}
SetIndexCondition
::
SetIndexCondition
(
MergeTreeIndexConditionSet
::
MergeTreeIndexConditionSet
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
,
const
MergeTree
SetSkippingIndex
&
index
)
:
IIndexCondition
(),
index
(
index
)
const
MergeTree
IndexSet
&
index
)
:
I
MergeTree
IndexCondition
(),
index
(
index
)
{
for
(
size_t
i
=
0
,
size
=
index
.
columns
.
size
();
i
<
size
;
++
i
)
{
...
...
@@ -253,14 +253,14 @@ SetIndexCondition::SetIndexCondition(
actions
=
ExpressionAnalyzer
(
expression_ast
,
syntax_analyzer_result
,
context
).
getActions
(
true
);
}
bool
SetIndexCondition
::
alwaysUnknownOrTrue
()
const
bool
MergeTreeIndexConditionSet
::
alwaysUnknownOrTrue
()
const
{
return
useless
;
}
bool
SetIndexCondition
::
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
bool
MergeTreeIndexConditionSet
::
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
{
auto
granule
=
std
::
dynamic_pointer_cast
<
MergeTree
SetIndexGranule
>
(
idx_granule
);
auto
granule
=
std
::
dynamic_pointer_cast
<
MergeTree
IndexGranuleSet
>
(
idx_granule
);
if
(
!
granule
)
throw
Exception
(
"Set index condition got a granule with the wrong type."
,
ErrorCodes
::
LOGICAL_ERROR
);
...
...
@@ -294,7 +294,7 @@ bool SetIndexCondition::mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule)
return
false
;
}
void
SetIndexCondition
::
traverseAST
(
ASTPtr
&
node
)
const
void
MergeTreeIndexConditionSet
::
traverseAST
(
ASTPtr
&
node
)
const
{
if
(
operatorFromAST
(
node
))
{
...
...
@@ -309,7 +309,7 @@ void SetIndexCondition::traverseAST(ASTPtr & node) const
node
=
std
::
make_shared
<
ASTLiteral
>
(
UNKNOWN_FIELD
);
}
bool
SetIndexCondition
::
atomFromAST
(
ASTPtr
&
node
)
const
bool
MergeTreeIndexConditionSet
::
atomFromAST
(
ASTPtr
&
node
)
const
{
/// Function, literal or column
...
...
@@ -340,7 +340,7 @@ bool SetIndexCondition::atomFromAST(ASTPtr & node) const
return
false
;
}
bool
SetIndexCondition
::
operatorFromAST
(
ASTPtr
&
node
)
const
bool
MergeTreeIndexConditionSet
::
operatorFromAST
(
ASTPtr
&
node
)
const
{
/// Functions AND, OR, NOT. Replace with bit*.
auto
*
func
=
node
->
as
<
ASTFunction
>
();
...
...
@@ -416,7 +416,7 @@ static bool checkAtomName(const String & name)
return
atoms
.
find
(
name
)
!=
atoms
.
end
();
}
bool
SetIndexCondition
::
checkASTUseless
(
const
ASTPtr
&
node
,
bool
atomic
)
const
bool
MergeTreeIndexConditionSet
::
checkASTUseless
(
const
ASTPtr
&
node
,
bool
atomic
)
const
{
if
(
const
auto
*
func
=
node
->
as
<
ASTFunction
>
())
{
...
...
@@ -446,23 +446,23 @@ bool SetIndexCondition::checkASTUseless(const ASTPtr &node, bool atomic) const
}
MergeTreeIndexGranulePtr
MergeTree
SetSkippingIndex
::
createIndexGranule
()
const
MergeTreeIndexGranulePtr
MergeTree
IndexSet
::
createIndexGranule
()
const
{
return
std
::
make_shared
<
MergeTree
SetIndexGranule
>
(
*
this
);
return
std
::
make_shared
<
MergeTree
IndexGranuleSet
>
(
*
this
);
}
MergeTreeIndexAggregatorPtr
MergeTree
SetSkippingIndex
::
createIndexAggregator
()
const
MergeTreeIndexAggregatorPtr
MergeTree
IndexSet
::
createIndexAggregator
()
const
{
return
std
::
make_shared
<
MergeTree
SetIndexAggregator
>
(
*
this
);
return
std
::
make_shared
<
MergeTree
IndexAggregatorSet
>
(
*
this
);
}
IndexConditionPtr
MergeTreeSetSkippingIndex
::
createIndexCondition
(
MergeTreeIndexConditionPtr
MergeTreeIndexSet
::
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
{
return
std
::
make_shared
<
SetIndexCondition
>
(
query
,
context
,
*
this
);
return
std
::
make_shared
<
MergeTreeIndexConditionSet
>
(
query
,
context
,
*
this
);
};
bool
MergeTree
SetSkippingIndex
::
mayBenefitFromIndexForIn
(
const
ASTPtr
&
)
const
bool
MergeTree
IndexSet
::
mayBenefitFromIndexForIn
(
const
ASTPtr
&
)
const
{
return
false
;
}
...
...
@@ -506,7 +506,7 @@ std::unique_ptr<IMergeTreeIndex> setIndexCreator(
header
.
insert
(
ColumnWithTypeAndName
(
column
.
type
->
createColumn
(),
column
.
type
,
column
.
name
));
}
return
std
::
make_unique
<
MergeTree
SetSkippingIndex
>
(
return
std
::
make_unique
<
MergeTree
IndexSet
>
(
node
->
name
,
std
::
move
(
unique_expr
),
columns
,
data_types
,
header
,
node
->
granularity
,
max_rows
);
}
...
...
dbms/src/Storages/MergeTree/MergeTree
SetSkippingIndex
.h
→
dbms/src/Storages/MergeTree/MergeTree
IndexSet
.h
浏览文件 @
166018e4
...
...
@@ -12,12 +12,12 @@
namespace
DB
{
class
MergeTree
SetSkippingIndex
;
class
MergeTree
IndexSet
;
struct
MergeTree
SetIndexGranule
:
public
IMergeTreeIndexGranule
struct
MergeTree
IndexGranuleSet
:
public
IMergeTreeIndexGranule
{
explicit
MergeTree
SetIndexGranule
(
const
MergeTreeSetSkippingIndex
&
index
);
MergeTree
SetIndexGranule
(
const
MergeTreeSetSkippingIndex
&
index
,
MutableColumns
&&
columns
);
explicit
MergeTree
IndexGranuleSet
(
const
MergeTreeIndexSet
&
index
);
MergeTree
IndexGranuleSet
(
const
MergeTreeIndexSet
&
index
,
MutableColumns
&&
columns
);
void
serializeBinary
(
WriteBuffer
&
ostr
)
const
override
;
void
deserializeBinary
(
ReadBuffer
&
istr
)
override
;
...
...
@@ -25,17 +25,17 @@ struct MergeTreeSetIndexGranule : public IMergeTreeIndexGranule
size_t
size
()
const
{
return
block
.
rows
();
}
bool
empty
()
const
override
{
return
!
size
();
}
~
MergeTree
SetIndexGranule
()
override
=
default
;
~
MergeTree
IndexGranuleSet
()
override
=
default
;
const
MergeTree
SetSkippingIndex
&
index
;
const
MergeTree
IndexSet
&
index
;
Block
block
;
};
struct
MergeTree
SetIndexAggregator
:
IMergeTreeIndexAggregator
struct
MergeTree
IndexAggregatorSet
:
IMergeTreeIndexAggregator
{
explicit
MergeTree
SetIndexAggregator
(
const
MergeTreeSetSkippingIndex
&
index
);
~
MergeTree
SetIndexAggregator
()
override
=
default
;
explicit
MergeTree
IndexAggregatorSet
(
const
MergeTreeIndexSet
&
index
);
~
MergeTree
IndexAggregatorSet
()
override
=
default
;
size_t
size
()
const
{
return
data
.
getTotalRowCount
();
}
bool
empty
()
const
override
{
return
!
size
();
}
...
...
@@ -55,26 +55,26 @@ private:
size_t
limit
,
ClearableSetVariants
&
variants
)
const
;
const
MergeTree
SetSkippingIndex
&
index
;
const
MergeTree
IndexSet
&
index
;
ClearableSetVariants
data
;
Sizes
key_sizes
;
MutableColumns
columns
;
};
class
SetIndexCondition
:
public
I
IndexCondition
class
MergeTreeIndexConditionSet
:
public
IMergeTree
IndexCondition
{
public:
SetIndexCondition
(
MergeTreeIndexConditionSet
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
,
const
MergeTree
SetSkippingIndex
&
index
);
const
MergeTree
IndexSet
&
index
);
bool
alwaysUnknownOrTrue
()
const
override
;
bool
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
idx_granule
)
const
override
;
~
SetIndexCondition
()
override
=
default
;
~
MergeTreeIndexConditionSet
()
override
=
default
;
private:
void
traverseAST
(
ASTPtr
&
node
)
const
;
bool
atomFromAST
(
ASTPtr
&
node
)
const
;
...
...
@@ -82,7 +82,7 @@ private:
bool
checkASTUseless
(
const
ASTPtr
&
node
,
bool
atomic
=
false
)
const
;
const
MergeTree
SetSkippingIndex
&
index
;
const
MergeTree
IndexSet
&
index
;
bool
useless
;
std
::
set
<
String
>
key_columns
;
...
...
@@ -91,10 +91,10 @@ private:
};
class
MergeTree
SetSkippingIndex
:
public
IMergeTreeIndex
class
MergeTree
IndexSet
:
public
IMergeTreeIndex
{
public:
MergeTree
SetSkippingIndex
(
MergeTree
IndexSet
(
String
name_
,
ExpressionActionsPtr
expr_
,
const
Names
&
columns_
,
...
...
@@ -104,12 +104,12 @@ public:
size_t
max_rows_
)
:
IMergeTreeIndex
(
std
::
move
(
name_
),
std
::
move
(
expr_
),
columns_
,
data_types_
,
header_
,
granularity_
),
max_rows
(
max_rows_
)
{}
~
MergeTree
SetSkippingIndex
()
override
=
default
;
~
MergeTree
IndexSet
()
override
=
default
;
MergeTreeIndexGranulePtr
createIndexGranule
()
const
override
;
MergeTreeIndexAggregatorPtr
createIndexAggregator
()
const
override
;
IndexConditionPtr
createIndexCondition
(
MergeTree
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query
,
const
Context
&
context
)
const
override
;
bool
mayBenefitFromIndexForIn
(
const
ASTPtr
&
node
)
const
override
;
...
...
dbms/src/Storages/MergeTree/MergeTreeIndices.h
浏览文件 @
166018e4
...
...
@@ -59,17 +59,17 @@ using MergeTreeIndexAggregators = std::vector<MergeTreeIndexAggregatorPtr>;
/// Condition on the index.
class
IIndexCondition
class
I
MergeTree
IndexCondition
{
public:
virtual
~
IIndexCondition
()
=
default
;
virtual
~
I
MergeTree
IndexCondition
()
=
default
;
/// Checks if this index is useful for query.
virtual
bool
alwaysUnknownOrTrue
()
const
=
0
;
virtual
bool
mayBeTrueOnGranule
(
MergeTreeIndexGranulePtr
granule
)
const
=
0
;
};
using
IndexConditionPtr
=
std
::
shared_ptr
<
I
IndexCondition
>
;
using
MergeTreeIndexConditionPtr
=
std
::
shared_ptr
<
IMergeTree
IndexCondition
>
;
/// Structure for storing basic index info like columns, expression, arguments, ...
...
...
@@ -101,7 +101,7 @@ public:
virtual
MergeTreeIndexGranulePtr
createIndexGranule
()
const
=
0
;
virtual
MergeTreeIndexAggregatorPtr
createIndexAggregator
()
const
=
0
;
virtual
IndexConditionPtr
createIndexCondition
(
virtual
MergeTree
IndexConditionPtr
createIndexCondition
(
const
SelectQueryInfo
&
query_info
,
const
Context
&
context
)
const
=
0
;
String
name
;
...
...
dbms/src/Storages/MergeTree/registerStorageMergeTree.cpp
浏览文件 @
166018e4
...
...
@@ -2,8 +2,8 @@
#include <Storages/StorageMergeTree.h>
#include <Storages/StorageReplicatedMergeTree.h>
#include <Storages/MergeTree/MergeTreeIndices.h>
#include <Storages/MergeTree/MergeTree
MinMaxInde
x.h>
#include <Storages/MergeTree/MergeTree
SetSkippingIndex
.h>
#include <Storages/MergeTree/MergeTree
IndexMinMa
x.h>
#include <Storages/MergeTree/MergeTree
IndexSet
.h>
#include <Common/typeid_cast.h>
#include <Common/OptimizedRegularExpression.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录