Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
65d997db
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,发现更多精彩内容 >>
提交
65d997db
编写于
2月 22, 2019
作者:
V
Vitaly Baranov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify excluding ProtobufWriter from compilation when USE_PROTOBUF=0.
上级
ba2efbae
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
75 addition
and
60 deletion
+75
-60
dbms/src/Formats/ProtobufWriter.cpp
dbms/src/Formats/ProtobufWriter.cpp
+5
-5
dbms/src/Formats/ProtobufWriter.h
dbms/src/Formats/ProtobufWriter.h
+70
-55
未找到文件。
dbms/src/Formats/ProtobufWriter.cpp
浏览文件 @
65d997db
#include
"ProtobufWriter.h"
#include
<Common/config.h>
#if USE_PROTOBUF
#include <cassert>
#include <optional>
#include <math.h>
#include <optional>
#include <AggregateFunctions/IAggregateFunction.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <boost/numeric/conversion/cast.hpp>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include "ProtobufWriter.h"
namespace
DB
...
...
@@ -797,5 +798,4 @@ void ProtobufWriter::writeAggregateFunction(const AggregateFunctionPtr & functio
}
}
#endif
dbms/src/Formats/ProtobufWriter.h
浏览文件 @
65d997db
#pragma once
#include <common/DayNum.h>
#include <Common/UInt128.h>
#include <Core/UUID.h>
#include <Common/config.h>
#if USE_PROTOBUF
#include <Formats/ProtobufSimpleWriter.h>
#include <boost/noncopyable.hpp>
#include <Common/PODArray.h>
#include <Common/UInt128.h>
#include <common/DayNum.h>
#include <Common/config.h>
namespace
google
...
...
@@ -18,20 +20,6 @@ namespace protobuf
}
}
#if USE_PROTOBUF
# define EMPTY_DEF
# define EMPTY_DEF_RET(a)
#else
# define EMPTY_DEF {}
# define EMPTY_DEF_RET(a) {return a;}
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
# if defined(__clang__)
# pragma GCC diagnostic ignored "-Wextra-semi"
# endif
#endif
namespace
DB
{
class
IAggregateFunction
;
...
...
@@ -44,57 +32,53 @@ using ConstAggregateDataPtr = const char *;
class
ProtobufWriter
:
private
boost
::
noncopyable
{
public:
ProtobufWriter
(
WriteBuffer
&
out
,
const
google
::
protobuf
::
Descriptor
*
message_type
)
EMPTY_DEF
;
~
ProtobufWriter
()
EMPTY_DEF
;
ProtobufWriter
(
WriteBuffer
&
out
,
const
google
::
protobuf
::
Descriptor
*
message_type
);
~
ProtobufWriter
();
/// Returns fields of the protobuf schema sorted by their numbers.
const
std
::
vector
<
const
google
::
protobuf
::
FieldDescriptor
*>
&
fieldsInWriteOrder
()
const
;
/// Should be called when we start writing a new message.
void
newMessage
()
EMPTY_DEF
;
void
newMessage
();
/// Should be called when we start writing a new field.
/// Returns false if there is no more fields in the message type.
bool
nextField
()
EMPTY_DEF_RET
(
false
)
;
bool
nextField
();
/// Returns the current field of the message type.
/// The value returned by this function changes after calling nextField() or newMessage().
#if USE_PROTOBUF
const
google
::
protobuf
::
FieldDescriptor
*
currentField
()
const
{
return
current_field
;
}
#endif
void
writeNumber
(
Int8
value
)
EMPTY_DEF
;
void
writeNumber
(
UInt8
value
)
EMPTY_DEF
;
void
writeNumber
(
Int16
value
)
EMPTY_DEF
;
void
writeNumber
(
UInt16
value
)
EMPTY_DEF
;
void
writeNumber
(
Int32
value
)
EMPTY_DEF
;
void
writeNumber
(
UInt32
value
)
EMPTY_DEF
;
void
writeNumber
(
Int64
value
)
EMPTY_DEF
;
void
writeNumber
(
UInt64
value
)
EMPTY_DEF
;
void
writeNumber
(
UInt128
value
)
EMPTY_DEF
;
void
writeNumber
(
Float32
value
)
EMPTY_DEF
;
void
writeNumber
(
Float64
value
)
EMPTY_DEF
;
void
writeNumber
(
Int8
value
);
void
writeNumber
(
UInt8
value
);
void
writeNumber
(
Int16
value
);
void
writeNumber
(
UInt16
value
);
void
writeNumber
(
Int32
value
);
void
writeNumber
(
UInt32
value
);
void
writeNumber
(
Int64
value
);
void
writeNumber
(
UInt64
value
);
void
writeNumber
(
UInt128
value
);
void
writeNumber
(
Float32
value
);
void
writeNumber
(
Float64
value
);
void
writeString
(
const
StringRef
&
value
)
EMPTY_DEF
;
void
writeString
(
const
StringRef
&
value
);
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int8
>>
&
name_value_pairs
)
EMPTY_DEF
;
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int16
>>
&
name_value_pairs
)
EMPTY_DEF
;
void
writeEnum
(
Int8
value
)
EMPTY_DEF
;
void
writeEnum
(
Int16
value
)
EMPTY_DEF
;
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int8
>>
&
name_value_pairs
);
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int16
>>
&
name_value_pairs
);
void
writeEnum
(
Int8
value
);
void
writeEnum
(
Int16
value
);
void
writeUUID
(
const
UUID
&
value
)
EMPTY_DEF
;
void
writeDate
(
DayNum
date
)
EMPTY_DEF
;
void
writeDateTime
(
time_t
tm
)
EMPTY_DEF
;
void
writeUUID
(
const
UUID
&
value
);
void
writeDate
(
DayNum
date
);
void
writeDateTime
(
time_t
tm
);
void
writeDecimal
(
Decimal32
decimal
,
UInt32
scale
)
EMPTY_DEF
;
void
writeDecimal
(
Decimal64
decimal
,
UInt32
scale
)
EMPTY_DEF
;
void
writeDecimal
(
const
Decimal128
&
decimal
,
UInt32
scale
)
EMPTY_DEF
;
void
writeDecimal
(
Decimal32
decimal
,
UInt32
scale
);
void
writeDecimal
(
Decimal64
decimal
,
UInt32
scale
);
void
writeDecimal
(
const
Decimal128
&
decimal
,
UInt32
scale
);
void
writeAggregateFunction
(
const
AggregateFunctionPtr
&
function
,
ConstAggregateDataPtr
place
)
EMPTY_DEF
;
void
writeAggregateFunction
(
const
AggregateFunctionPtr
&
function
,
ConstAggregateDataPtr
place
);
private:
#if USE_PROTOBUF
void
enumerateFieldsInWriteOrder
(
const
google
::
protobuf
::
Descriptor
*
message_type
);
void
createConverters
();
...
...
@@ -115,14 +99,45 @@ private:
std
::
vector
<
std
::
unique_ptr
<
Converter
>>
converters
;
Converter
*
current_converter
=
nullptr
;
#endif
};
}
#if !USE_PROTOBUF
# undef EMPTY_DEF
# undef EMPTY_DEF_RET
# pragma GCC diagnostic pop
#else
namespace
DB
{
class
IAggregateFunction
;
using
AggregateFunctionPtr
=
std
::
shared_ptr
<
IAggregateFunction
>
;
using
ConstAggregateDataPtr
=
const
char
*
;
class
ProtobufWriter
{
public:
void
writeNumber
(
Int8
value
)
{}
void
writeNumber
(
UInt8
value
)
{}
void
writeNumber
(
Int16
value
)
{}
void
writeNumber
(
UInt16
value
)
{}
void
writeNumber
(
Int32
value
)
{}
void
writeNumber
(
UInt32
value
)
{}
void
writeNumber
(
Int64
value
)
{}
void
writeNumber
(
UInt64
value
)
{}
void
writeNumber
(
UInt128
value
)
{}
void
writeNumber
(
Float32
value
)
{}
void
writeNumber
(
Float64
value
)
{}
void
writeString
(
const
StringRef
&
value
)
{}
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int8
>>
&
name_value_pairs
)
{}
void
prepareEnumMapping
(
const
std
::
vector
<
std
::
pair
<
std
::
string
,
Int16
>>
&
name_value_pairs
)
{}
void
writeEnum
(
Int8
value
)
{}
void
writeEnum
(
Int16
value
)
{}
void
writeUUID
(
const
UUID
&
value
)
{}
void
writeDate
(
DayNum
date
)
{}
void
writeDateTime
(
time_t
tm
)
{}
void
writeDecimal
(
Decimal32
decimal
,
UInt32
scale
)
{}
void
writeDecimal
(
Decimal64
decimal
,
UInt32
scale
)
{}
void
writeDecimal
(
const
Decimal128
&
decimal
,
UInt32
scale
)
{}
void
writeAggregateFunction
(
const
AggregateFunctionPtr
&
function
,
ConstAggregateDataPtr
place
)
{}
};
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录