Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
b7ee1be6
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,发现更多精彩内容 >>
提交
b7ee1be6
编写于
3月 14, 2018
作者:
N
Nikolai Kochetov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added ColumnUnique [#CLICKHOUSE-3621]
上级
b7475b1d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
116 addition
and
0 deletion
+116
-0
dbms/src/Columns/ColumnUnique.h
dbms/src/Columns/ColumnUnique.h
+50
-0
dbms/src/Columns/IColumnUnique.h
dbms/src/Columns/IColumnUnique.h
+32
-0
dbms/src/DataTypes/DataTypeWithDictionary.cpp
dbms/src/DataTypes/DataTypeWithDictionary.cpp
+0
-0
dbms/src/DataTypes/DataTypeWithDictionary.h
dbms/src/DataTypes/DataTypeWithDictionary.h
+34
-0
未找到文件。
dbms/src/Columns/ColumnUnique.h
0 → 100644
浏览文件 @
b7ee1be6
#include <Columns/IColumnUnique.h>
#include <Common/HashTable/HashMap.h>
namespace
DB
{
template
<
typename
ColumnType
,
typename
IndexType
,
bool
is_nullable
,
bool
may_has_empty_data
>
class
ColumnUnique
:
public
IColumnUnique
{
public:
ColumnPtr
getColumn
()
const
overrdie
;
size_t
insert
(
const
Field
&
x
)
overrdie
;
ColumnPtr
insertRangeFrom
(
const
IColumn
&
src
,
size_t
start
,
size_t
length
)
override
;
size_t
insertData
(
const
char
*
pos
,
size_t
length
)
overrdie
;
private:
struct
StringRefWrapper
{
const
ColumnType
*
column
=
nullptr
;
size_t
offset
=
0
;
size_t
size
=
0
;
StringRefWrapper
(
const
ColumnType
*
column
,
size_t
row
)
:
column
(
column
)
{
auto
ref
=
column
->
getDataAt
(
row
);
offset
=
ref
.
data
-
column
->
getDataAt
(
0
).
data
;
size
=
res
.
size
;
}
operator
StringRef
()
const
{
return
StringRef
(
column
->
getDataAt
(
0
).
data
+
offset
,
size
);
}
bool
operator
==
(
const
StringRefWrapper
&
other
)
{
return
(
column
==
other
.
column
&&
offset
==
other
.
offset
&&
size
==
other
.
size
)
||
StringRef
(
*
this
)
==
other
;
}
};
using
IndexType
=
HashMap
<
StringRefWrapper
,
IndexType
,
StringRefHash
>
;
MutableColumnPtr
column
;
/// Lazy initialized.
std
::
unique_ptr
<
IndexType
>
index
;
};
}
dbms/src/Columns/IColumnUnique.h
0 → 100644
浏览文件 @
b7ee1be6
#include <Columns/IColumn.h>
namespace
DB
{
class
IColumnUnique
{
public:
/// Column always contains Null if it's Nullable and empty string if it's String or Nullable(String).
/// So, size may be greater than the number of inserted unique values.
virtual
ColumnPtr
getColumn
()
const
=
0
;
virtual
size_t
size
()
const
{
return
getColumn
()
->
size
();
}
/// Appends new value at the end of column (column's size is increased by 1).
/// Is used to transform raw strings to Blocks (for example, inside input format parsers)
virtual
size_t
insert
(
const
Field
&
x
)
=
0
;
/// Appends range of elements from other column.
/// Could be used to concatenate columns.
virtual
ColumnPtr
insertRangeFrom
(
const
IColumn
&
src
,
size_t
start
,
size_t
length
)
=
0
;
/// Appends data located in specified memory chunk if it is possible (throws an exception if it cannot be implemented).
/// Is used to optimize some computations (in aggregation, for example).
/// Parameter length could be ignored if column values have fixed size.
virtual
size_t
insertData
(
const
char
*
pos
,
size_t
length
)
=
0
;
virtual
size_t
getInsertionPoint
(
const
char
*
pos
,
size_t
length
)
const
=
0
;
virtual
bool
has
(
const
char
*
pos
,
size_t
length
)
const
{
return
getInsertionPoint
(
pos
,
length
)
!=
size
();
}
};
}
dbms/src/DataTypes/DataTypeWithDictionary.cpp
0 → 100644
浏览文件 @
b7ee1be6
dbms/src/DataTypes/DataTypeWithDictionary.h
0 → 100644
浏览文件 @
b7ee1be6
#include <Columns/IColumn.h>
#include <memory>
#include <Common/HashTable/HashMap.h>
namespace
DB
{
template
<
typename
IndexType
>
class
CountingRecursiveDictionary
{
public:
using
DictionaryType
=
HashMap
<
StringRef
,
IndexType
,
StringRefHash
>
;
void
insertData
(
const
char
*
pos
,
size_t
length
)
{
column
->
insertData
(
pos
,
length
);
}
StringRef
getDataAt
(
size_t
n
)
const
{
if
(
n
<
prev_dictionary_size
)
return
prev_dictionary
->
getDataAt
(
n
);
else
return
column
->
getDataAt
(
n
-
prev_dictionary_size
);
}
private:
ColumnPtr
column
;
DictionaryType
dictionary
;
std
::
shared_ptr
<
CountingRecursiveDictionary
>
prev_dictionary
;
size_t
prev_dictionary_size
=
0
;
};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录