Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
7ed31799
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,发现更多精彩内容 >>
提交
7ed31799
编写于
7月 14, 2014
作者:
G
gyfora
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] streamrecord tupleBasicTypesFromLong update
上级
edd89686
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
73 addition
and
57 deletion
+73
-57
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamrecord/StreamRecord.java
...stratosphere/streaming/api/streamrecord/StreamRecord.java
+72
-57
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/streamrecord/StreamRecordTest.java
...tosphere/streaming/api/streamrecord/StreamRecordTest.java
+1
-0
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamrecord/StreamRecord.java
浏览文件 @
7ed31799
...
...
@@ -74,9 +74,10 @@ public class StreamRecord implements IOReadableWritable, Serializable {
private
int
numOfFields
;
private
int
numOfTuples
;
private
static
final
Class
<?>[]
CLASSES
=
new
Class
<?>[]
{
Tuple1
.
class
,
Tuple2
.
class
,
Tuple3
.
class
,
Tuple4
.
class
,
Tuple5
.
class
,
Tuple6
.
class
,
Tuple7
.
class
,
Tuple8
.
class
,
Tuple9
.
class
,
Tuple10
.
class
,
Tuple11
.
class
,
Tuple12
.
class
,
Tuple13
.
class
,
Tuple14
.
class
,
Tuple15
.
class
,
Tuple16
.
class
,
Tuple17
.
class
,
Tuple18
.
class
,
private
static
final
Class
<?>[]
CLASSES
=
new
Class
<?>[]
{
Tuple1
.
class
,
Tuple2
.
class
,
Tuple3
.
class
,
Tuple4
.
class
,
Tuple5
.
class
,
Tuple6
.
class
,
Tuple7
.
class
,
Tuple8
.
class
,
Tuple9
.
class
,
Tuple10
.
class
,
Tuple11
.
class
,
Tuple12
.
class
,
Tuple13
.
class
,
Tuple14
.
class
,
Tuple15
.
class
,
Tuple16
.
class
,
Tuple17
.
class
,
Tuple18
.
class
,
Tuple19
.
class
,
Tuple20
.
class
,
Tuple21
.
class
,
Tuple22
.
class
};
// TODO implement equals, clone
...
...
@@ -189,7 +190,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Object
getField
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Object
getField
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
Tuple
tuple
;
try
{
tuple
=
tupleBatch
.
get
(
tupleNumber
);
...
...
@@ -203,7 +205,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
}
}
public
Object
getFieldFast
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Object
getFieldFast
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
Tuple
tuple
;
try
{
tuple
=
tupleBatch
.
get
(
tupleNumber
);
...
...
@@ -242,7 +245,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* , NoSuchFieldException
*/
// TODO: add exception for cast for all getters
public
Boolean
getBoolean
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Boolean
getBoolean
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Boolean
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -270,7 +274,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Byte
getByte
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Byte
getByte
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Byte
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -283,7 +288,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Character
getCharacter
(
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Character
getCharacter
(
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
getCharacter
(
0
,
fieldNumber
);
}
...
...
@@ -298,7 +304,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Character
getCharacter
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Character
getCharacter
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Character
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -326,7 +333,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Double
getDouble
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Double
getDouble
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Double
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -354,7 +362,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Float
getFloat
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Float
getFloat
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Float
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -382,7 +391,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Integer
getInteger
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Integer
getInteger
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Integer
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -410,7 +420,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Long
getLong
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Long
getLong
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Long
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -438,7 +449,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , NoSuchFieldException
*/
public
Short
getShort
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
Short
getShort
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
Short
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -464,7 +476,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* Position of the field in the tuple
* @return value of the field as String
*/
public
String
getString
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
public
String
getString
(
int
tupleNumber
,
int
fieldNumber
)
throws
NoSuchTupleException
,
NoSuchFieldException
{
return
(
String
)
getField
(
tupleNumber
,
fieldNumber
);
}
...
...
@@ -585,7 +598,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* New value
* @throws NoSuchFieldException
*/
public
void
setCharacter
(
int
tupleNumber
,
int
fieldNumber
,
Character
c
)
throws
NoSuchFieldException
{
public
void
setCharacter
(
int
tupleNumber
,
int
fieldNumber
,
Character
c
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
c
);
}
...
...
@@ -808,7 +822,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , TupleSizeMismatchException
*/
public
void
getTupleInto
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
public
void
getTupleInto
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
if
(
tuple
.
getArity
()
==
numOfFields
)
{
try
{
...
...
@@ -847,7 +862,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* @throws NoSuchTupleException
* , TupleSizeMismatchException
*/
public
void
setTuple
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
public
void
setTuple
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
if
(
tuple
.
getArity
()
==
numOfFields
)
{
try
{
tupleBatch
.
set
(
tupleNumber
,
copyTuple
(
tuple
));
...
...
@@ -1025,43 +1041,39 @@ public class StreamRecord implements IOReadableWritable, Serializable {
@SuppressWarnings
(
"rawtypes"
)
Class
[]
basicTypes
=
new
Class
[
typeNums
.
length
];
try
{
for
(
int
i
=
0
;
i
<
basicTypes
.
length
;
i
++)
{
switch
(
typeNums
[
i
])
{
case
0
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Boolean"
);
break
;
case
1
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Byte"
);
break
;
case
2
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Character"
);
break
;
case
3
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Double"
);
break
;
case
4
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Float"
);
break
;
case
5
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Integer"
);
break
;
case
6
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Long"
);
break
;
case
7
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.Short"
);
break
;
case
8
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.String"
);
break
;
default
:
basicTypes
[
i
]
=
Class
.
forName
(
"java.lang.String"
);
break
;
}
for
(
int
i
=
0
;
i
<
basicTypes
.
length
;
i
++)
{
switch
(
typeNums
[
i
])
{
case
0
:
basicTypes
[
i
]
=
java
.
lang
.
Boolean
.
class
;
break
;
case
1
:
basicTypes
[
i
]
=
java
.
lang
.
Byte
.
class
;
break
;
case
2
:
basicTypes
[
i
]
=
java
.
lang
.
Character
.
class
;
break
;
case
3
:
basicTypes
[
i
]
=
java
.
lang
.
Double
.
class
;
break
;
case
4
:
basicTypes
[
i
]
=
java
.
lang
.
Float
.
class
;
break
;
case
5
:
basicTypes
[
i
]
=
java
.
lang
.
Integer
.
class
;
break
;
case
6
:
basicTypes
[
i
]
=
java
.
lang
.
Long
.
class
;
break
;
case
7
:
basicTypes
[
i
]
=
java
.
lang
.
Short
.
class
;
break
;
case
8
:
basicTypes
[
i
]
=
java
.
lang
.
String
.
class
;
break
;
default
:
basicTypes
[
i
]
=
java
.
lang
.
String
.
class
;
break
;
}
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
basicTypes
;
}
...
...
@@ -1090,8 +1102,10 @@ public class StreamRecord implements IOReadableWritable, Serializable {
StringValue
typeVal
=
new
StringValue
(
basicTypeNames
.
toString
());
@SuppressWarnings
(
"unchecked"
)
TupleSerializer
<
Tuple
>
tupleSerializer
=
(
TupleSerializer
<
Tuple
>)
typeInfo
.
createSerializer
();
SerializationDelegate
<
Tuple
>
serializationDelegate
=
new
SerializationDelegate
<
Tuple
>(
tupleSerializer
);
TupleSerializer
<
Tuple
>
tupleSerializer
=
(
TupleSerializer
<
Tuple
>)
typeInfo
.
createSerializer
();
SerializationDelegate
<
Tuple
>
serializationDelegate
=
new
SerializationDelegate
<
Tuple
>(
tupleSerializer
);
serializationDelegate
.
setInstance
(
tuple
);
try
{
typeVal
.
write
(
out
);
...
...
@@ -1129,7 +1143,8 @@ public class StreamRecord implements IOReadableWritable, Serializable {
TypeInformation
<?
extends
Tuple
>
typeInfo
=
TupleTypeInfo
.
getBasicTupleTypeInfo
(
basicTypes
);
@SuppressWarnings
(
"unchecked"
)
TupleSerializer
<
Tuple
>
tupleSerializer
=
(
TupleSerializer
<
Tuple
>)
typeInfo
.
createSerializer
();
TupleSerializer
<
Tuple
>
tupleSerializer
=
(
TupleSerializer
<
Tuple
>)
typeInfo
.
createSerializer
();
DeserializationDelegate
<
Tuple
>
dd
=
new
DeserializationDelegate
<
Tuple
>(
tupleSerializer
);
dd
.
setInstance
(
tupleSerializer
.
createInstance
());
...
...
flink-addons/flink-streaming/src/test/java/eu/stratosphere/streaming/api/streamrecord/StreamRecordTest.java
浏览文件 @
7ed31799
...
...
@@ -111,6 +111,7 @@ public class StreamRecordTest {
assertEquals
((
Character
)
'\0'
,
record
.
getCharacter
(
0
,
6
));
assertEquals
((
Float
)
0
.
f
,
record
.
getFloat
(
0
,
7
));
assertEquals
((
Short
)
(
short
)
0
,
record
.
getShort
(
0
,
8
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录