Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
154bb3bb
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
154bb3bb
编写于
4月 20, 2017
作者:
Z
zentol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[hotfix] [py] Code cleanup - SerializationUtils
上级
36950629
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
28 deletion
+40
-28
flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/plan/PythonPlanSender.java
...che/flink/python/api/streaming/plan/PythonPlanSender.java
+0
-1
flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/util/SerializationUtils.java
...e/flink/python/api/streaming/util/SerializationUtils.java
+40
-27
未找到文件。
flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/plan/PythonPlanSender.java
浏览文件 @
154bb3bb
...
...
@@ -28,7 +28,6 @@ public class PythonPlanSender {
this
.
output
=
new
DataOutputStream
(
output
);
}
@SuppressWarnings
(
"unchecked"
)
public
void
sendRecord
(
Object
record
)
throws
IOException
{
byte
[]
data
=
SerializationUtils
.
getSerializer
(
record
).
serialize
(
record
);
output
.
write
(
data
);
...
...
flink-libraries/flink-python/src/main/java/org/apache/flink/python/api/streaming/util/SerializationUtils.java
浏览文件 @
154bb3bb
...
...
@@ -20,21 +20,22 @@ import java.nio.ByteBuffer;
import
java.util.ArrayList
;
public
class
SerializationUtils
{
public
static
final
byte
TYPE_BOOLEAN
=
(
byte
)
34
;
public
static
final
byte
TYPE_BYTE
=
(
byte
)
33
;
public
static
final
byte
TYPE_INTEGER
=
(
byte
)
32
;
public
static
final
byte
TYPE_LONG
=
(
byte
)
31
;
public
static
final
byte
TYPE_DOUBLE
=
(
byte
)
30
;
public
static
final
byte
TYPE_FLOAT
=
(
byte
)
29
;
public
static
final
byte
TYPE_STRING
=
(
byte
)
28
;
public
static
final
byte
TYPE_BYTES
=
(
byte
)
27
;
public
static
final
byte
TYPE_NULL
=
(
byte
)
26
;
public
static
final
byte
TYPE_BOOLEAN
=
34
;
public
static
final
byte
TYPE_BYTE
=
33
;
public
static
final
byte
TYPE_INTEGER
=
32
;
public
static
final
byte
TYPE_LONG
=
31
;
public
static
final
byte
TYPE_DOUBLE
=
30
;
public
static
final
byte
TYPE_FLOAT
=
29
;
public
static
final
byte
TYPE_STRING
=
28
;
public
static
final
byte
TYPE_BYTES
=
27
;
public
static
final
byte
TYPE_NULL
=
26
;
private
enum
SupportedTypes
{
TUPLE
,
BOOLEAN
,
BYTE
,
BYTES
,
INTEGER
,
LONG
,
FLOAT
,
DOUBLE
,
STRING
,
NULL
,
CUSTOMTYPEWRAPPER
}
public
static
Serializer
getSerializer
(
Object
value
)
{
@SuppressWarnings
(
"unchecked"
)
public
static
<
IN
>
Serializer
<
IN
>
getSerializer
(
IN
value
)
{
String
className
=
value
.
getClass
().
getSimpleName
().
toUpperCase
();
if
(
className
.
startsWith
(
"TUPLE"
))
{
className
=
"TUPLE"
;
...
...
@@ -43,35 +44,48 @@ public class SerializationUtils {
className
=
"BYTES"
;
}
SupportedTypes
type
=
SupportedTypes
.
valueOf
(
className
);
Serializer
<?>
serializer
;
switch
(
type
)
{
case
TUPLE:
return
new
TupleSerializer
((
Tuple
)
value
);
serializer
=
new
TupleSerializer
((
Tuple
)
value
);
break
;
case
BOOLEAN:
return
new
BooleanSerializer
();
serializer
=
new
BooleanSerializer
();
break
;
case
BYTE:
return
new
ByteSerializer
();
serializer
=
new
ByteSerializer
();
break
;
case
BYTES:
return
new
BytesSerializer
();
serializer
=
new
BytesSerializer
();
break
;
case
INTEGER:
return
new
IntSerializer
();
serializer
=
new
IntSerializer
();
break
;
case
LONG:
return
new
LongSerializer
();
serializer
=
new
LongSerializer
();
break
;
case
STRING:
return
new
StringSerializer
();
serializer
=
new
StringSerializer
();
break
;
case
FLOAT:
return
new
FloatSerializer
();
serializer
=
new
FloatSerializer
();
break
;
case
DOUBLE:
return
new
DoubleSerializer
();
serializer
=
new
DoubleSerializer
();
break
;
case
NULL:
return
new
NullSerializer
();
serializer
=
new
NullSerializer
();
break
;
case
CUSTOMTYPEWRAPPER:
return
new
CustomTypeWrapperSerializer
((
CustomTypeWrapper
)
value
);
serializer
=
new
CustomTypeWrapperSerializer
((
CustomTypeWrapper
)
value
);
break
;
default
:
throw
new
IllegalArgumentException
(
"Unsupported Type encountered: "
+
type
);
}
return
(
Serializer
<
IN
>)
serializer
;
}
public
static
abstract
class
Serializer
<
IN
>
{
public
abstract
static
class
Serializer
<
IN
>
{
private
byte
[]
typeInfo
=
null
;
public
byte
[]
serialize
(
IN
value
)
{
...
...
@@ -130,7 +144,7 @@ public class SerializationUtils {
public
static
class
BooleanSerializer
extends
Serializer
<
Boolean
>
{
@Override
public
byte
[]
serializeWithoutTypeInfo
(
Boolean
value
)
{
return
new
byte
[]{
value
?
(
byte
)
1
:
(
byte
)
0
};
return
new
byte
[]{
(
byte
)
(
value
?
1
:
0
)
};
}
@Override
...
...
@@ -237,7 +251,7 @@ public class SerializationUtils {
}
public
static
class
TupleSerializer
extends
Serializer
<
Tuple
>
{
private
final
Serializer
[]
serializer
;
private
final
Serializer
<
Object
>
[]
serializer
;
public
TupleSerializer
(
Tuple
value
)
{
serializer
=
new
Serializer
[
value
.
getArity
()];
...
...
@@ -246,7 +260,6 @@ public class SerializationUtils {
}
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
byte
[]
serializeWithoutTypeInfo
(
Tuple
value
)
{
ArrayList
<
byte
[]>
bits
=
new
ArrayList
<>();
...
...
@@ -269,7 +282,7 @@ public class SerializationUtils {
@Override
public
void
putTypeInfo
(
ByteBuffer
buffer
)
{
buffer
.
put
((
byte
)
serializer
.
length
);
for
(
Serializer
s
:
serializer
)
{
for
(
Serializer
<
Object
>
s
:
serializer
)
{
s
.
putTypeInfo
(
buffer
);
}
}
...
...
@@ -277,7 +290,7 @@ public class SerializationUtils {
@Override
public
int
getTypeInfoSize
()
{
int
size
=
1
;
for
(
Serializer
s
:
serializer
)
{
for
(
Serializer
<
Object
>
s
:
serializer
)
{
size
+=
s
.
getTypeInfoSize
();
}
return
size
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录