Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
4cbd0ed2
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,发现更多精彩内容 >>
未验证
提交
4cbd0ed2
编写于
2月 03, 2021
作者:
A
alexey-milovidov
提交者:
GitHub
2月 03, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20010 from ClickHouse/coverity
Fix some of the issues found by Coverity
上级
a4d86c43
191389d0
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
64 addition
and
219 deletion
+64
-219
base/common/ReplxxLineReader.cpp
base/common/ReplxxLineReader.cpp
+6
-4
base/daemon/BaseDaemon.cpp
base/daemon/BaseDaemon.cpp
+3
-3
base/mysqlxx/Connection.h
base/mysqlxx/Connection.h
+0
-1
base/mysqlxx/Query.cpp
base/mysqlxx/Query.cpp
+0
-10
base/mysqlxx/Query.h
base/mysqlxx/Query.h
+0
-6
base/mysqlxx/ResultBase.h
base/mysqlxx/ResultBase.h
+1
-1
base/mysqlxx/Row.h
base/mysqlxx/Row.h
+1
-1
base/mysqlxx/UseQueryResult.h
base/mysqlxx/UseQueryResult.h
+1
-2
base/mysqlxx/Value.h
base/mysqlxx/Value.h
+1
-1
base/mysqlxx/tests/mysqlxx_test.cpp
base/mysqlxx/tests/mysqlxx_test.cpp
+0
-139
src/Columns/ColumnDecimal.h
src/Columns/ColumnDecimal.h
+1
-1
src/Parsers/ASTWithElement.cpp
src/Parsers/ASTWithElement.cpp
+1
-1
src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp
src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp
+43
-43
src/Processors/Formats/Impl/ORCBlockOutputFormat.h
src/Processors/Formats/Impl/ORCBlockOutputFormat.h
+5
-5
src/Storages/MergeTree/MergeTreeIndexFullText.cpp
src/Storages/MergeTree/MergeTreeIndexFullText.cpp
+1
-1
未找到文件。
base/common/ReplxxLineReader.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -12,6 +12,8 @@
#include <dlfcn.h>
#include <fcntl.h>
#include <fstream>
#include <fmt/format.h>
namespace
{
...
...
@@ -189,8 +191,8 @@ void ReplxxLineReader::openEditor()
return
;
}
String
editor
=
std
::
getenv
(
"EDITOR"
);
if
(
editor
.
empty
()
)
const
char
*
editor
=
std
::
getenv
(
"EDITOR"
);
if
(
!
editor
||
!*
editor
)
editor
=
"vim"
;
replxx
::
Replxx
::
State
state
(
rx
.
get_state
());
...
...
@@ -204,7 +206,7 @@ void ReplxxLineReader::openEditor()
if
((
-
1
==
res
||
0
==
res
)
&&
errno
!=
EINTR
)
{
rx
.
print
(
"Cannot write to temporary query file %s: %s
\n
"
,
filename
,
errnoToString
(
errno
).
c_str
());
return
;
break
;
}
bytes_written
+=
res
;
}
...
...
@@ -215,7 +217,7 @@ void ReplxxLineReader::openEditor()
return
;
}
if
(
0
==
execute
(
editor
+
" "
+
filename
))
if
(
0
==
execute
(
fmt
::
format
(
"{} {}"
,
editor
,
filename
)
))
{
try
{
...
...
base/daemon/BaseDaemon.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -230,10 +230,10 @@ public:
}
else
{
siginfo_t
info
;
ucontext_t
context
;
siginfo_t
info
{}
;
ucontext_t
context
{}
;
StackTrace
stack_trace
(
NoCapture
{});
UInt32
thread_num
;
UInt32
thread_num
{}
;
std
::
string
query_id
;
DB
::
ThreadStatus
*
thread_ptr
{};
...
...
base/mysqlxx/Connection.h
浏览文件 @
4cbd0ed2
...
...
@@ -39,7 +39,6 @@ private:
/** MySQL connection.
* Usage:
* mysqlxx::Connection connection("Test", "127.0.0.1", "root", "qwerty", 3306);
* std::cout << connection.query("SELECT 'Hello, World!'").store().at(0).at(0).getString() << std::endl;
*
* Or with Poco library configuration:
* mysqlxx::Connection connection("mysql_params");
...
...
base/mysqlxx/Query.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -71,16 +71,6 @@ UseQueryResult Query::use()
return
UseQueryResult
(
res
,
conn
,
this
);
}
StoreQueryResult
Query
::
store
()
{
executeImpl
();
MYSQL_RES
*
res
=
mysql_store_result
(
conn
->
getDriver
());
if
(
!
res
)
checkError
(
conn
->
getDriver
());
return
StoreQueryResult
(
res
,
conn
,
this
);
}
void
Query
::
execute
()
{
executeImpl
();
...
...
base/mysqlxx/Query.h
浏览文件 @
4cbd0ed2
...
...
@@ -3,7 +3,6 @@
#include <sstream>
#include <mysqlxx/UseQueryResult.h>
#include <mysqlxx/StoreQueryResult.h>
namespace
mysqlxx
...
...
@@ -46,11 +45,6 @@ public:
*/
UseQueryResult
use
();
/** Выполнить запрос с загрузкой на клиента всех строк.
* Требуется оперативка, чтобы вместить весь результат, зато к строкам можно обращаться в произвольном порядке.
*/
StoreQueryResult
store
();
/// Значение auto increment после последнего INSERT-а.
UInt64
insertID
();
...
...
base/mysqlxx/ResultBase.h
浏览文件 @
4cbd0ed2
...
...
@@ -9,7 +9,7 @@ class Connection;
class
Query
;
/** Базовый класс для UseQueryResult
и StoreQueryResult
.
/** Базовый класс для UseQueryResult.
* Содержит общую часть реализации,
* Ссылается на Connection. Если уничтожить Connection, то пользоваться ResultBase и любым результатом нельзя.
* Использовать объект можно только для результата одного запроса!
...
...
base/mysqlxx/Row.h
浏览文件 @
4cbd0ed2
...
...
@@ -35,7 +35,7 @@ public:
{
}
/** Для того, чтобы создать Row, используйте соответствующие методы UseQueryResult
или StoreQueryResult
. */
/** Для того, чтобы создать Row, используйте соответствующие методы UseQueryResult. */
Row
(
MYSQL_ROW
row_
,
ResultBase
*
res_
,
MYSQL_LENGTHS
lengths_
)
:
row
(
row_
),
res
(
res_
),
lengths
(
lengths_
)
{
...
...
base/mysqlxx/UseQueryResult.h
浏览文件 @
4cbd0ed2
...
...
@@ -12,8 +12,7 @@ class Connection;
/** Результат выполнения запроса, предназначенный для чтения строк, одна за другой.
* В памяти при этом хранится только одна, текущая строка.
* В отличие от StoreQueryResult, произвольный доступ к строкам невозможен,
* а также, при чтении следующей строки, предыдущая становится некорректной.
* При чтении следующей строки, предыдущая становится некорректной.
* Вы обязаны прочитать все строки из результата
* (вызывать функцию fetch(), пока она не вернёт значение, преобразующееся к false),
* иначе при следующем запросе будет выкинуто исключение с текстом "Commands out of sync".
...
...
base/mysqlxx/Value.h
浏览文件 @
4cbd0ed2
...
...
@@ -25,7 +25,7 @@ class ResultBase;
/** Represents a single value read from MySQL.
* It doesn't owns the value. It's just a wrapper of a pair (const char *, size_t).
* If the UseQueryResult
/StoreQueryResult
or Connection is destroyed,
* If the UseQueryResult or Connection is destroyed,
* or you have read the next Row while using UseQueryResult, then the object is invalidated.
* Allows to transform (parse) the value to various data types:
* - with getUInt(), getString(), ... (recommended);
...
...
base/mysqlxx/tests/mysqlxx_test.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -38,15 +38,6 @@ int main(int, char **)
}
}
{
mysqlxx
::
Query
query
=
connection
.
query
();
query
<<
"SELECT 1234567890 abc, 12345.67890 def UNION ALL SELECT 9876543210, 98765.43210"
;
mysqlxx
::
StoreQueryResult
result
=
query
.
store
();
std
::
cerr
<<
result
.
at
(
0
)[
"abc"
].
getUInt
()
<<
", "
<<
result
.
at
(
0
)[
"def"
].
getDouble
()
<<
std
::
endl
<<
result
.
at
(
1
)[
"abc"
].
getUInt
()
<<
", "
<<
result
.
at
(
1
)[
"def"
].
getDouble
()
<<
std
::
endl
;
}
{
mysqlxx
::
UseQueryResult
result
=
connection
.
query
(
"SELECT 'abc
\\\\
def' x"
).
use
();
mysqlxx
::
Row
row
=
result
.
fetch
();
...
...
@@ -54,27 +45,6 @@ int main(int, char **)
std
::
cerr
<<
row
<<
std
::
endl
;
}
{
mysqlxx
::
Query
query
=
connection
.
query
(
"SEL"
);
query
<<
"ECT 1"
;
std
::
cerr
<<
query
.
store
().
at
(
0
).
at
(
0
)
<<
std
::
endl
;
}
{
/// Копирование Query
mysqlxx
::
Query
query
=
connection
.
query
(
"SELECT 'Ok' x"
);
using
Queries
=
std
::
vector
<
mysqlxx
::
Query
>
;
Queries
queries
;
queries
.
push_back
(
query
);
for
(
auto
&
q
:
queries
)
{
std
::
cerr
<<
q
.
str
()
<<
std
::
endl
;
std
::
cerr
<<
q
.
store
().
at
(
0
)
<<
std
::
endl
;
}
}
{
/// Копирование Query
mysqlxx
::
Query
query1
=
connection
.
query
(
"SELECT"
);
...
...
@@ -84,62 +54,6 @@ int main(int, char **)
std
::
cerr
<<
query1
.
str
()
<<
", "
<<
query2
.
str
()
<<
std
::
endl
;
}
{
/// Копирование Query
using
Queries
=
std
::
list
<
mysqlxx
::
Query
>
;
Queries
queries
;
queries
.
push_back
(
connection
.
query
(
"SELECT"
));
mysqlxx
::
Query
&
qref
=
queries
.
back
();
qref
<<
" 1"
;
for
(
auto
&
query
:
queries
)
{
std
::
cerr
<<
query
.
str
()
<<
std
::
endl
;
std
::
cerr
<<
query
.
store
().
at
(
0
)
<<
std
::
endl
;
}
}
{
/// Транзакции
connection
.
query
(
"DROP TABLE IF EXISTS tmp"
).
execute
();
connection
.
query
(
"CREATE TABLE tmp (x INT, PRIMARY KEY (x)) ENGINE = InnoDB"
).
execute
();
mysqlxx
::
Transaction
trans
(
connection
);
connection
.
query
(
"INSERT INTO tmp VALUES (1)"
).
execute
();
std
::
cerr
<<
connection
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
trans
.
rollback
();
std
::
cerr
<<
connection
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
}
{
/// Транзакции
connection
.
query
(
"DROP TABLE IF EXISTS tmp"
).
execute
();
connection
.
query
(
"CREATE TABLE tmp (x INT, PRIMARY KEY (x)) ENGINE = InnoDB"
).
execute
();
{
mysqlxx
::
Transaction
trans
(
connection
);
connection
.
query
(
"INSERT INTO tmp VALUES (1)"
).
execute
();
std
::
cerr
<<
connection
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
}
std
::
cerr
<<
connection
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
}
{
/// Транзакции
mysqlxx
::
Connection
connection2
(
"test"
,
"127.0.0.1"
,
"root"
,
"qwerty"
,
3306
);
connection2
.
query
(
"DROP TABLE IF EXISTS tmp"
).
execute
();
connection2
.
query
(
"CREATE TABLE tmp (x INT, PRIMARY KEY (x)) ENGINE = InnoDB"
).
execute
();
mysqlxx
::
Transaction
trans
(
connection2
);
connection2
.
query
(
"INSERT INTO tmp VALUES (1)"
).
execute
();
std
::
cerr
<<
connection2
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
}
std
::
cerr
<<
connection
.
query
(
"SELECT * FROM tmp"
).
store
().
size
()
<<
std
::
endl
;
{
/// NULL
mysqlxx
::
Null
<
int
>
x
=
mysqlxx
::
null
;
...
...
@@ -152,59 +66,6 @@ int main(int, char **)
std
::
cerr
<<
(
x
==
1
?
"Ok"
:
"Fail"
)
<<
std
::
endl
;
std
::
cerr
<<
(
x
.
isNull
()
?
"Fail"
:
"Ok"
)
<<
std
::
endl
;
}
{
/// Исключения при попытке достать значение не того типа
try
{
connection
.
query
(
"SELECT -1"
).
store
().
at
(
0
).
at
(
0
).
getUInt
();
std
::
cerr
<<
"Fail"
<<
std
::
endl
;
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
std
::
cerr
<<
"Ok, "
<<
e
.
message
()
<<
std
::
endl
;
}
try
{
connection
.
query
(
"SELECT 'xxx'"
).
store
().
at
(
0
).
at
(
0
).
getInt
();
std
::
cerr
<<
"Fail"
<<
std
::
endl
;
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
std
::
cerr
<<
"Ok, "
<<
e
.
message
()
<<
std
::
endl
;
}
try
{
connection
.
query
(
"SELECT NULL"
).
store
().
at
(
0
).
at
(
0
).
getString
();
std
::
cerr
<<
"Fail"
<<
std
::
endl
;
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
std
::
cerr
<<
"Ok, "
<<
e
.
message
()
<<
std
::
endl
;
}
try
{
connection
.
query
(
"SELECT 123"
).
store
().
at
(
0
).
at
(
0
).
getDate
();
std
::
cerr
<<
"Fail"
<<
std
::
endl
;
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
std
::
cerr
<<
"Ok, "
<<
e
.
message
()
<<
std
::
endl
;
}
try
{
connection
.
query
(
"SELECT '2011-01-01'"
).
store
().
at
(
0
).
at
(
0
).
getDateTime
();
std
::
cerr
<<
"Fail"
<<
std
::
endl
;
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
std
::
cerr
<<
"Ok, "
<<
e
.
message
()
<<
std
::
endl
;
}
}
}
catch
(
const
mysqlxx
::
Exception
&
e
)
{
...
...
src/Columns/ColumnDecimal.h
浏览文件 @
4cbd0ed2
...
...
@@ -136,7 +136,7 @@ public:
Field
operator
[](
size_t
n
)
const
override
{
return
DecimalField
(
data
[
n
],
scale
);
}
void
get
(
size_t
n
,
Field
&
res
)
const
override
{
res
=
(
*
this
)[
n
];
}
bool
getBool
(
size_t
n
)
const
override
{
return
bool
(
data
[
n
].
value
);
}
Int64
getInt
(
size_t
n
)
const
override
{
return
Int64
(
data
[
n
].
value
*
scale
)
;
}
Int64
getInt
(
size_t
n
)
const
override
{
return
Int64
(
data
[
n
].
value
)
*
scale
;
}
UInt64
get64
(
size_t
n
)
const
override
;
bool
isDefaultAt
(
size_t
n
)
const
override
{
return
data
[
n
].
value
==
0
;
}
...
...
src/Parsers/ASTWithElement.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -18,7 +18,7 @@ void ASTWithElement::formatImpl(const FormatSettings & settings, FormatState & s
{
settings
.
writeIdentifier
(
name
);
settings
.
ostr
<<
(
settings
.
hilite
?
hilite_keyword
:
""
)
<<
" AS "
<<
(
settings
.
hilite
?
hilite_none
:
""
);
dynamic_cast
<
const
ASTWithAlias
*>
(
subquery
.
get
())
->
formatImplWithoutAlias
(
settings
,
state
,
frame
);
dynamic_cast
<
const
ASTWithAlias
&>
(
*
subquery
).
formatImplWithoutAlias
(
settings
,
state
,
frame
);
}
}
src/Processors/Formats/Impl/ORCBlockOutputFormat.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -133,112 +133,112 @@ ORC_UNIQUE_PTR<orc::Type> ORCBlockOutputFormat::getORCType(const DataTypePtr & t
template
<
typename
NumberType
,
typename
NumberVectorBatch
,
typename
ConvertFunc
>
void
ORCBlockOutputFormat
::
writeNumbers
(
orc
::
ColumnVectorBatch
*
orc_column
,
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
ConvertFunc
convert
)
{
NumberVectorBatch
*
number_orc_column
=
dynamic_cast
<
NumberVectorBatch
*
>
(
orc_column
);
NumberVectorBatch
&
number_orc_column
=
dynamic_cast
<
NumberVectorBatch
&
>
(
orc_column
);
const
auto
&
number_column
=
assert_cast
<
const
ColumnVector
<
NumberType
>
&>
(
column
);
number_orc_column
->
resize
(
number_column
.
size
());
number_orc_column
.
resize
(
number_column
.
size
());
for
(
size_t
i
=
0
;
i
!=
number_column
.
size
();
++
i
)
{
if
(
null_bytemap
&&
(
*
null_bytemap
)[
i
])
{
number_orc_column
->
notNull
[
i
]
=
0
;
number_orc_column
.
notNull
[
i
]
=
0
;
continue
;
}
number_orc_column
->
data
[
i
]
=
convert
(
number_column
.
getElement
(
i
));
number_orc_column
.
data
[
i
]
=
convert
(
number_column
.
getElement
(
i
));
}
number_orc_column
->
numElements
=
number_column
.
size
();
number_orc_column
.
numElements
=
number_column
.
size
();
}
template
<
typename
Decimal
,
typename
DecimalVectorBatch
,
typename
ConvertFunc
>
void
ORCBlockOutputFormat
::
writeDecimals
(
orc
::
ColumnVectorBatch
*
orc_column
,
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
ConvertFunc
convert
)
{
DecimalVectorBatch
*
decimal_orc_column
=
dynamic_cast
<
DecimalVectorBatch
*
>
(
orc_column
);
DecimalVectorBatch
&
decimal_orc_column
=
dynamic_cast
<
DecimalVectorBatch
&
>
(
orc_column
);
const
auto
&
decimal_column
=
assert_cast
<
const
ColumnDecimal
<
Decimal
>
&>
(
column
);
const
auto
*
decimal_type
=
typeid_cast
<
const
DataTypeDecimal
<
Decimal
>
*>
(
type
.
get
());
decimal_orc_column
->
precision
=
decimal_type
->
getPrecision
();
decimal_orc_column
->
scale
=
decimal_type
->
getScale
();
decimal_orc_column
->
resize
(
decimal_column
.
size
());
decimal_orc_column
.
precision
=
decimal_type
->
getPrecision
();
decimal_orc_column
.
scale
=
decimal_type
->
getScale
();
decimal_orc_column
.
resize
(
decimal_column
.
size
());
for
(
size_t
i
=
0
;
i
!=
decimal_column
.
size
();
++
i
)
{
if
(
null_bytemap
&&
(
*
null_bytemap
)[
i
])
{
decimal_orc_column
->
notNull
[
i
]
=
0
;
decimal_orc_column
.
notNull
[
i
]
=
0
;
continue
;
}
decimal_orc_column
->
values
[
i
]
=
convert
(
decimal_column
.
getElement
(
i
).
value
);
decimal_orc_column
.
values
[
i
]
=
convert
(
decimal_column
.
getElement
(
i
).
value
);
}
decimal_orc_column
->
numElements
=
decimal_column
.
size
();
decimal_orc_column
.
numElements
=
decimal_column
.
size
();
}
template
<
typename
ColumnType
>
void
ORCBlockOutputFormat
::
writeStrings
(
orc
::
ColumnVectorBatch
*
orc_column
,
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
)
{
orc
::
StringVectorBatch
*
string_orc_column
=
dynamic_cast
<
orc
::
StringVectorBatch
*
>
(
orc_column
);
orc
::
StringVectorBatch
&
string_orc_column
=
dynamic_cast
<
orc
::
StringVectorBatch
&
>
(
orc_column
);
const
auto
&
string_column
=
assert_cast
<
const
ColumnType
&>
(
column
);
string_orc_column
->
resize
(
string_column
.
size
());
string_orc_column
.
resize
(
string_column
.
size
());
for
(
size_t
i
=
0
;
i
!=
string_column
.
size
();
++
i
)
{
if
(
null_bytemap
&&
(
*
null_bytemap
)[
i
])
{
string_orc_column
->
notNull
[
i
]
=
0
;
string_orc_column
.
notNull
[
i
]
=
0
;
continue
;
}
const
StringRef
&
string
=
string_column
.
getDataAt
(
i
);
string_orc_column
->
data
[
i
]
=
const_cast
<
char
*>
(
string
.
data
);
string_orc_column
->
length
[
i
]
=
string
.
size
;
string_orc_column
.
data
[
i
]
=
const_cast
<
char
*>
(
string
.
data
);
string_orc_column
.
length
[
i
]
=
string
.
size
;
}
string_orc_column
->
numElements
=
string_column
.
size
();
string_orc_column
.
numElements
=
string_column
.
size
();
}
template
<
typename
ColumnType
,
typename
GetSecondsFunc
,
typename
GetNanosecondsFunc
>
void
ORCBlockOutputFormat
::
writeDateTimes
(
orc
::
ColumnVectorBatch
*
orc_column
,
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
GetSecondsFunc
get_seconds
,
GetNanosecondsFunc
get_nanoseconds
)
{
orc
::
TimestampVectorBatch
*
timestamp_orc_column
=
dynamic_cast
<
orc
::
TimestampVectorBatch
*
>
(
orc_column
);
orc
::
TimestampVectorBatch
&
timestamp_orc_column
=
dynamic_cast
<
orc
::
TimestampVectorBatch
&
>
(
orc_column
);
const
auto
&
timestamp_column
=
assert_cast
<
const
ColumnType
&>
(
column
);
timestamp_orc_column
->
resize
(
timestamp_column
.
size
());
timestamp_orc_column
.
resize
(
timestamp_column
.
size
());
for
(
size_t
i
=
0
;
i
!=
timestamp_column
.
size
();
++
i
)
{
if
(
null_bytemap
&&
(
*
null_bytemap
)[
i
])
{
timestamp_orc_column
->
notNull
[
i
]
=
0
;
timestamp_orc_column
.
notNull
[
i
]
=
0
;
continue
;
}
timestamp_orc_column
->
data
[
i
]
=
get_seconds
(
timestamp_column
.
getElement
(
i
));
timestamp_orc_column
->
nanoseconds
[
i
]
=
get_nanoseconds
(
timestamp_column
.
getElement
(
i
));
timestamp_orc_column
.
data
[
i
]
=
get_seconds
(
timestamp_column
.
getElement
(
i
));
timestamp_orc_column
.
nanoseconds
[
i
]
=
get_nanoseconds
(
timestamp_column
.
getElement
(
i
));
}
timestamp_orc_column
->
numElements
=
timestamp_column
.
size
();
timestamp_orc_column
.
numElements
=
timestamp_column
.
size
();
}
void
ORCBlockOutputFormat
::
writeColumn
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
)
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
)
{
if
(
null_bytemap
)
{
orc_column
->
hasNulls
=
true
;
orc_column
->
notNull
.
resize
(
column
.
size
());
orc_column
.
hasNulls
=
true
;
orc_column
.
notNull
.
resize
(
column
.
size
());
}
switch
(
type
->
getTypeId
())
{
...
...
@@ -364,20 +364,20 @@ void ORCBlockOutputFormat::writeColumn(
}
case
TypeIndex
::
Array
:
{
orc
::
ListVectorBatch
*
list_orc_column
=
dynamic_cast
<
orc
::
ListVectorBatch
*
>
(
orc_column
);
orc
::
ListVectorBatch
&
list_orc_column
=
dynamic_cast
<
orc
::
ListVectorBatch
&
>
(
orc_column
);
const
auto
&
list_column
=
assert_cast
<
const
ColumnArray
&>
(
column
);
auto
nested_type
=
assert_cast
<
const
DataTypeArray
&>
(
*
type
).
getNestedType
();
const
ColumnArray
::
Offsets
&
offsets
=
list_column
.
getOffsets
();
list_orc_column
->
resize
(
list_column
.
size
());
list_orc_column
.
resize
(
list_column
.
size
());
/// The length of list i in ListVectorBatch is offsets[i+1] - offsets[i].
list_orc_column
->
offsets
[
0
]
=
0
;
list_orc_column
.
offsets
[
0
]
=
0
;
for
(
size_t
i
=
0
;
i
!=
list_column
.
size
();
++
i
)
{
list_orc_column
->
offsets
[
i
+
1
]
=
offsets
[
i
];
list_orc_column
.
offsets
[
i
+
1
]
=
offsets
[
i
];
}
orc
::
ColumnVectorBatch
*
nested_orc_column
=
list_orc_column
->
elements
.
get
()
;
orc
::
ColumnVectorBatch
&
nested_orc_column
=
*
list_orc_column
.
elements
;
writeColumn
(
nested_orc_column
,
list_column
.
getData
(),
nested_type
,
null_bytemap
);
list_orc_column
->
numElements
=
list_column
.
size
();
list_orc_column
.
numElements
=
list_column
.
size
();
break
;
}
default:
...
...
@@ -414,12 +414,12 @@ void ORCBlockOutputFormat::consume(Chunk chunk)
/// getMaxColumnSize is needed to write arrays.
/// The size of the batch must be no less than total amount of array elements.
ORC_UNIQUE_PTR
<
orc
::
ColumnVectorBatch
>
batch
=
writer
->
createRowBatch
(
getMaxColumnSize
(
chunk
));
orc
::
StructVectorBatch
*
root
=
dynamic_cast
<
orc
::
StructVectorBatch
*>
(
batch
.
get
()
);
orc
::
StructVectorBatch
&
root
=
dynamic_cast
<
orc
::
StructVectorBatch
&>
(
*
batch
);
for
(
size_t
i
=
0
;
i
!=
columns_num
;
++
i
)
{
writeColumn
(
root
->
fields
[
i
],
*
chunk
.
getColumns
()[
i
],
data_types
[
i
],
nullptr
);
writeColumn
(
*
root
.
fields
[
i
],
*
chunk
.
getColumns
()[
i
],
data_types
[
i
],
nullptr
);
}
root
->
numElements
=
rows_num
;
root
.
numElements
=
rows_num
;
writer
->
add
(
*
batch
);
}
...
...
src/Processors/Formats/Impl/ORCBlockOutputFormat.h
浏览文件 @
4cbd0ed2
...
...
@@ -48,23 +48,23 @@ private:
/// ConvertFunc is needed for type UInt8, because firstly UInt8 (char8_t) must be
/// converted to unsigned char (bugprone-signed-char-misuse in clang).
template
<
typename
NumberType
,
typename
NumberVectorBatch
,
typename
ConvertFunc
>
void
writeNumbers
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
ConvertFunc
convert
);
void
writeNumbers
(
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
ConvertFunc
convert
);
/// ConvertFunc is needed to convert ClickHouse Int128 to ORC Int128.
template
<
typename
Decimal
,
typename
DecimalVectorBatch
,
typename
ConvertFunc
>
void
writeDecimals
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
void
writeDecimals
(
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
ConvertFunc
convert
);
template
<
typename
ColumnType
>
void
writeStrings
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
);
void
writeStrings
(
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
);
/// ORC column TimestampVectorBatch stores only seconds and nanoseconds,
/// GetSecondsFunc and GetNanosecondsFunc are needed to extract them from DataTime type.
template
<
typename
ColumnType
,
typename
GetSecondsFunc
,
typename
GetNanosecondsFunc
>
void
writeDateTimes
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
void
writeDateTimes
(
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
,
GetSecondsFunc
get_seconds
,
GetNanosecondsFunc
get_nanoseconds
);
void
writeColumn
(
orc
::
ColumnVectorBatch
*
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
);
void
writeColumn
(
orc
::
ColumnVectorBatch
&
orc_column
,
const
IColumn
&
column
,
DataTypePtr
&
type
,
const
PaddedPODArray
<
UInt8
>
*
null_bytemap
);
/// These two functions are needed to know maximum nested size of arrays to
/// create an ORC Batch with the appropriate size
...
...
src/Storages/MergeTree/MergeTreeIndexFullText.cpp
浏览文件 @
4cbd0ed2
...
...
@@ -357,7 +357,7 @@ bool MergeTreeConditionFullText::atomFromAST(
return
false
;
}
if
(
key_arg_pos
==
1
&&
(
func_name
!=
"equals"
||
func_name
!=
"notEquals"
))
if
(
key_arg_pos
==
1
&&
(
func_name
!=
"equals"
&&
func_name
!=
"notEquals"
))
return
false
;
else
if
(
!
token_extractor
->
supportLike
()
&&
(
func_name
==
"like"
||
func_name
==
"notLike"
))
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录