Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
46b8a85e
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,发现更多精彩内容 >>
提交
46b8a85e
编写于
3月 25, 2012
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dbms: development [#CONV-2944].
上级
5a3649b1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
18 deletion
+44
-18
dbms/include/DB/IO/ChunkedReadBuffer.h
dbms/include/DB/IO/ChunkedReadBuffer.h
+4
-0
dbms/include/DB/IO/ChunkedWriteBuffer.h
dbms/include/DB/IO/ChunkedWriteBuffer.h
+8
-0
dbms/include/DB/IO/ReadBuffer.h
dbms/include/DB/IO/ReadBuffer.h
+1
-1
dbms/src/Client/Client.cpp
dbms/src/Client/Client.cpp
+27
-17
dbms/src/Server/TCPHandler.cpp
dbms/src/Server/TCPHandler.cpp
+4
-0
未找到文件。
dbms/include/DB/IO/ChunkedReadBuffer.h
浏览文件 @
46b8a85e
...
...
@@ -44,6 +44,7 @@ protected:
UInt64
query_id
=
0
;
readIntBinary
(
query_id
,
in
);
if
(
query_id
!=
assert_query_id
)
throw
Exception
(
"Received data for wrong query id"
,
ErrorCodes
::
RECEIVED_DATA_FOR_WRONG_QUERY_ID
);
...
...
@@ -55,6 +56,9 @@ protected:
read_in_chunk
=
std
::
min
(
chunk_size
,
in
.
buffer
().
size
()
-
in
.
offset
());
working_buffer
=
Buffer
(
in
.
position
(),
in
.
position
()
+
read_in_chunk
);
in
.
position
()
+=
read_in_chunk
;
if
(
all_read
)
return
false
;
}
return
true
;
...
...
dbms/include/DB/IO/ChunkedWriteBuffer.h
浏览文件 @
46b8a85e
...
...
@@ -3,6 +3,8 @@
#include <DB/IO/WriteBuffer.h>
#include <DB/IO/WriteHelpers.h>
#include <iostream>
namespace
DB
{
...
...
@@ -28,12 +30,18 @@ protected:
void
nextImpl
()
{
std
::
cerr
<<
out
.
offset
()
<<
std
::
endl
;
std
::
cerr
<<
query_id
<<
std
::
endl
;
std
::
cerr
<<
offset
()
<<
std
::
endl
;
checkBufferSize
();
writeIntBinary
(
query_id
,
out
);
writeIntBinary
(
false
,
out
);
writeIntBinary
(
offset
(),
out
);
std
::
cerr
<<
out
.
offset
()
<<
std
::
endl
;
out
.
position
()
=
position
();
out
.
next
();
working_buffer
=
Buffer
(
out
.
buffer
().
begin
()
+
headerSize
(),
out
.
buffer
().
end
());
...
...
dbms/include/DB/IO/ReadBuffer.h
浏览文件 @
46b8a85e
...
...
@@ -92,7 +92,7 @@ public:
{
size_t
bytes_copied
=
0
;
while
(
!
eof
()
&&
bytes_copied
<
n
)
while
(
bytes_copied
<
n
&&
!
eof
()
)
{
size_t
bytes_to_copy
=
std
::
min
(
static_cast
<
size_t
>
(
working_buffer
.
end
()
-
pos
),
n
-
bytes_copied
);
std
::
memcpy
(
to
+
bytes_copied
,
pos
,
bytes_to_copy
);
...
...
dbms/src/Client/Client.cpp
浏览文件 @
46b8a85e
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <iostream>
...
...
@@ -25,11 +26,11 @@
#include <DB/IO/CompressedWriteBuffer.h>
#include <DB/IO/ChunkedReadBuffer.h>
#include <DB/IO/ChunkedWriteBuffer.h>
#include <DB/IO/WriteBufferFromFileDescriptor.h>
#include <DB/IO/ReadHelpers.h>
#include <DB/IO/WriteHelpers.h>
#include <DB/Interpreters/Context.h>
#include <DB/Interpreters/executeQuery.h>
/** Клиент командной строки СУБД ClickHouse.
...
...
@@ -39,14 +40,15 @@
namespace
DB
{
using
Poco
::
SharedPtr
;
class
Client
:
public
Poco
::
Util
::
Application
{
public:
Client
()
:
socket
(),
in
(
socket
),
out
(
socket
),
query_id
(
0
),
compression
(
Protocol
::
Compression
::
Enable
),
format_max_block_size
(
0
),
std_out
(
STDOUT_FILENO
)
{}
private:
using
Poco
::
SharedPtr
;
typedef
std
::
tr1
::
unordered_set
<
String
>
StringSet
;
StringSet
exit_strings
;
...
...
@@ -63,6 +65,7 @@ private:
size_t
format_max_block_size
;
/// Максимальный размер блока при выводе в консоль.
Context
context
;
Block
empty_block
;
/// Откуда читать результат выполнения запроса.
SharedPtr
<
ReadBuffer
>
chunked_in
;
...
...
@@ -75,7 +78,7 @@ private:
BlockOutputStreamPtr
block_out
;
/// Вывод в консоль
WriteBuffer
std_out
;
WriteBuffer
FromFileDescriptor
std_out
;
BlockOutputStreamPtr
block_std_out
;
...
...
@@ -87,7 +90,8 @@ private:
(
"exit"
)(
"quit"
)(
"logout"
)
(
"учше"
)(
"йгше"
)(
"дщпщге"
)
(
"exit;"
)(
"quit;"
)(
"logout;"
)
(
"учше;"
)(
"йгше;"
)(
"дщпщге;"
);
(
"учше;"
)(
"йгше;"
)(
"дщпщге;"
)
(
"q"
)(
"й"
);
if
(
config
().
has
(
"config-file"
))
loadConfiguration
(
config
().
getString
(
"config-file"
));
...
...
@@ -102,7 +106,10 @@ private:
int
main
(
const
std
::
vector
<
std
::
string
>
&
args
)
{
std
::
cout
<<
"ClickHouse client. Revision: "
<<
Revision
::
get
()
<<
"."
<<
std
::
endl
;
std
::
cout
<<
"ClickHouse client version "
<<
DBMS_VERSION_MAJOR
<<
"."
<<
DBMS_VERSION_MINOR
<<
"."
<<
Revision
::
get
()
<<
"."
<<
std
::
endl
;
compression
=
config
().
getBool
(
"compression"
,
true
)
?
Protocol
::
Compression
::
Enable
:
Protocol
::
Compression
::
Disable
;
in_format
=
config
().
getString
(
"in_format"
,
"Native"
);
...
...
@@ -137,7 +144,7 @@ private:
<<
" server version "
<<
server_version_major
<<
"."
<<
server_version_minor
<<
"."
<<
server_revision
<<
std
::
endl
;
<<
"."
<<
std
::
endl
;
context
.
format_factory
=
new
FormatFactory
();
context
.
data_type_factory
=
new
DataTypeFactory
();
...
...
@@ -158,6 +165,7 @@ private:
free
(
line_
);
if
(
!
process
(
line
))
break
;
add_history
(
line
.
c_str
());
}
}
...
...
@@ -174,6 +182,10 @@ private:
sendQuery
();
receiveResult
();
block_in
=
NULL
;
maybe_compressed_in
=
NULL
;
chunked_in
=
NULL
;
return
true
;
}
...
...
@@ -181,9 +193,6 @@ private:
void
sendQuery
()
{
UInt64
stage
=
Protocol
::
QueryProcessingStage
::
Complete
;
UInt64
compression
=
Protocol
::
Compression
::
Enable
;
String
in_format
=
"Native"
;
String
out_format
=
"Native"
;
writeVarInt
(
Protocol
::
Client
::
Query
,
out
);
writeIntBinary
(
query_id
,
out
);
...
...
@@ -201,6 +210,8 @@ private:
{
while
(
receivePacket
())
;
block_std_out
=
NULL
;
}
...
...
@@ -230,24 +241,23 @@ private:
?
new
CompressedReadBuffer
(
*
chunked_in
)
:
chunked_in
;
/// Проанализируем запрос
BlockIO
analyze_result
=
executeQuery
(
query
,
context
);
block_in
=
context
.
format_factory
->
getInput
(
out_format
,
*
maybe_compressed_in
,
analyze_result
.
out_sample
,
empty_block
,
format_max_block_size
,
*
context
.
data_type_factory
);
block_std_out
=
context
.
format_factory
->
getOutput
(
format
,
std_out
,
analyze_result
.
out_sample
);
}
/// Прочитать из сети один блок и
засунуть его в state.io.out (данные для INSERT-а)
/// Прочитать из сети один блок и
вывести его в консоль
Block
block
=
block_in
->
read
();
if
(
block
)
{
if
(
!
block_std_out
)
block_std_out
=
context
.
format_factory
->
getOutput
(
format
,
std_out
,
block
);
block_std_out
->
write
(
block
);
std_out
.
next
();
return
true
;
}
else
...
...
dbms/src/Server/TCPHandler.cpp
浏览文件 @
46b8a85e
...
...
@@ -172,11 +172,15 @@ bool TCPHandler::sendData(WriteBuffer & out, WriteBuffer & out_for_chunks)
if
(
block
)
{
state
.
block_out
->
write
(
block
);
state
.
maybe_compressed_out
->
next
();
state
.
chunked_out
->
next
();
out_for_chunks
.
next
();
return
true
;
}
else
{
dynamic_cast
<
ChunkedWriteBuffer
&>
(
*
state
.
chunked_out
).
finish
();
out_for_chunks
.
next
();
return
false
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录