Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
b22a9e92
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,发现更多精彩内容 >>
提交
b22a9e92
编写于
7月 14, 2014
作者:
M
Márton Balassi
提交者:
Stephan Ewen
8月 18, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[streaming] StreamRecord setters refactor
上级
15254108
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
107 addition
and
109 deletion
+107
-109
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamrecord/StreamRecord.java
...stratosphere/streaming/api/streamrecord/StreamRecord.java
+107
-109
未找到文件。
flink-addons/flink-streaming/src/main/java/eu/stratosphere/streaming/api/streamrecord/StreamRecord.java
浏览文件 @
b22a9e92
...
...
@@ -348,6 +348,19 @@ public class StreamRecord implements IOReadableWritable, Serializable {
return
(
String
)
getField
(
tupleNumber
,
fieldNumber
);
}
/**
* Sets a field in the given position of the first record in the batch
*
* @param fieldNumber
* Position of the field in the record
* @param o
* New value
* @throws NoSuchFieldException
*/
public
void
setField
(
int
fieldNumber
,
Object
o
)
throws
NoSuchFieldException
{
setField
(
0
,
fieldNumber
,
o
);
}
/**
* Sets a field in the given position of a specific tuple in the batch
*
...
...
@@ -357,8 +370,11 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* Position of field in tuple
* @param o
* New value
* @throws NoSuchFieldException
*/
public
void
setField
(
int
tupleNumber
,
int
fieldNumber
,
Object
o
)
{
// TODO: consider no such tuple exception and interaction with batch size
public
void
setField
(
int
tupleNumber
,
int
fieldNumber
,
Object
o
)
throws
NoSuchFieldException
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
o
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
...
...
@@ -367,59 +383,49 @@ public class StreamRecord implements IOReadableWritable, Serializable {
}
/**
* Sets a
String field in the given position of a specific
tuple in the
* Sets a
Boolean field in the given position of the first
tuple in the
* batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
str
* @param
b
* New value
* @throws NoSuchFieldException
*/
public
void
setString
(
int
tupleNumber
,
int
fieldNumber
,
String
str
)
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
str
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setBoolean
(
int
fieldNumber
,
Boolean
b
)
throws
NoSuchFieldException
{
setBoolean
(
0
,
fieldNumber
,
b
);
}
/**
* Sets a
n Integer
field in the given position of a specific tuple in the
* Sets a
Boolean
field in the given position of a specific tuple in the
* batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
i
* @param
b
* New value
* @throws NoSuchFieldException
*/
public
void
setInteger
(
int
tupleNumber
,
int
fieldNumber
,
Integer
i
)
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
i
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setBoolean
(
int
tupleNumber
,
int
fieldNumber
,
Boolean
b
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
b
);
}
/**
* Sets a
Long field in the given position of a specific
tuple in the batch
* Sets a
Double field in the given position of the first
tuple in the batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
l
* @param
d
* New value
* @throws NoSuchFieldException
*/
public
void
setLong
(
int
tupleNumber
,
int
fieldNumber
,
Long
l
)
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
l
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setDouble
(
int
fieldNumber
,
Double
d
)
throws
NoSuchFieldException
{
setDouble
(
0
,
fieldNumber
,
d
);
}
/**
...
...
@@ -432,138 +438,120 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* Position of field in tuple
* @param d
* New value
* @throws NoSuchFieldException
*/
public
void
setDouble
(
int
tupleNumber
,
int
fieldNumber
,
Double
d
)
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
d
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setDouble
(
int
tupleNumber
,
int
fieldNumber
,
Double
d
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
d
);
}
/**
* Sets a
Boolean field in the given position of a specific
tuple in the
* Sets a
n Integer field in the given position of the first
tuple in the
* batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
b
* @param
i
* New value
* @throws NoSuchFieldException
*/
public
void
setBoolean
(
int
tupleNumber
,
int
fieldNumber
,
Boolean
b
)
{
try
{
tupleBatch
.
get
(
tupleNumber
).
setField
(
b
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setInteger
(
int
fieldNumber
,
Integer
i
)
throws
NoSuchFieldException
{
setInteger
(
0
,
i
);
}
/**
* Sets a String field in the given position of the first tuple in the batch
* Sets an Integer field in the given position of a specific tuple in the
* batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
str
* @param
i
* New value
* @throws NoSuchFieldException
*/
public
void
setString
(
int
fieldNumber
,
String
str
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
str
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setInteger
(
int
tupleNumber
,
int
fieldNumber
,
Integer
i
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
i
);
}
/**
* Sets an Integer field in the given position of the first tuple in the
* batch
* Sets a Long field in the given position of the first tuple in the batch
*
* @param fieldNumber
* Position of field in tuple
* @param
i
* @param
l
* New value
* @throws NoSuchFieldException
*/
public
void
setInteger
(
int
fieldNumber
,
Integer
i
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
i
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setLong
(
int
fieldNumber
,
Long
l
)
throws
NoSuchFieldException
{
setLong
(
0
,
fieldNumber
,
l
);
}
/**
* Sets a Long field in the given position of
the first
tuple in the batch
* Sets a Long field in the given position of
a specific
tuple in the batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param l
* New value
* @throws NoSuchFieldException
*/
public
void
setLong
(
int
fieldNumber
,
Long
l
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
l
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setLong
(
int
tupleNumber
,
int
fieldNumber
,
Long
l
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
l
);
}
/**
* Sets a
Double
field in the given position of the first tuple in the batch
* Sets a
String
field in the given position of the first tuple in the batch
*
* @param fieldNumber
* Position of field in tuple
* @param
d
* @param
str
* New value
* @throws NoSuchFieldException
*/
public
void
setDouble
(
int
fieldNumber
,
Double
d
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
d
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setString
(
int
fieldNumber
,
String
str
)
throws
NoSuchFieldException
{
setField
(
0
,
fieldNumber
,
str
);
}
/**
* Sets a
Boolean field in the given position of the first
tuple in the
* Sets a
String field in the given position of a specific
tuple in the
* batch
*
* @param tupleNumber
* Position of tuple in batch
* @param fieldNumber
* Position of field in tuple
* @param
b
* @param
str
* New value
* @throws NoSuchFieldException
*/
public
void
setBoolean
(
int
fieldNumber
,
Boolean
b
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
b
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchTupleException
());
}
public
void
setString
(
int
tupleNumber
,
int
fieldNumber
,
String
str
)
throws
NoSuchFieldException
{
setField
(
tupleNumber
,
fieldNumber
,
str
);
}
/**
* Sets a field in the given position of the first record in the batch
*
* @param fieldNumber
* Position of the field in the record
* @param o
* New value
* @return First tuple of the batch
* @throws NoSuchTupleException
*/
public
void
setField
(
int
fieldNumber
,
Object
o
)
{
try
{
tupleBatch
.
get
(
0
).
setField
(
o
,
fieldNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
(
new
NoSuchFieldException
());
}
public
Tuple
getTuple
()
throws
NoSuchTupleException
{
return
getTuple
(
0
);
}
/**
* @param tupleNumber
* Position of the record in the batch
* @return Chosen tuple
* @throws NoSuchTupleException
*/
public
Tuple
getTuple
(
int
tupleNumber
)
{
public
Tuple
getTuple
(
int
tupleNumber
)
throws
NoSuchTupleException
{
try
{
return
tupleBatch
.
get
(
tupleNumber
);
}
catch
(
IndexOutOfBoundsException
e
)
{
...
...
@@ -571,20 +559,16 @@ public class StreamRecord implements IOReadableWritable, Serializable {
}
}
/**
* @return First tuple of the batch
*/
public
Tuple
getTuple
()
{
return
getTuple
(
0
);
}
/**
* Gets the fields of the first tuple of the batch into the parameter tuple
*
* @param tuple
* Target tuple
* @throws NoSuchTupleException
* , TupleSizeMismatchException
*/
public
void
getTupleInto
(
Tuple
tuple
)
{
public
void
getTupleInto
(
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
getTupleInto
(
0
,
tuple
);
}
...
...
@@ -597,8 +581,11 @@ public class StreamRecord implements IOReadableWritable, Serializable {
*
* @param tuple
* Target tuple
* @throws NoSuchTupleException
* , TupleSizeMismatchException
*/
public
void
getTupleInto
(
int
tupleNumber
,
Tuple
tuple
)
{
public
void
getTupleInto
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
if
(
tuple
.
getArity
()
==
numOfFields
)
{
try
{
...
...
@@ -620,9 +607,10 @@ public class StreamRecord implements IOReadableWritable, Serializable {
*
* @param tuple
* Tuple to set
* @throws TupleSizeMismatchException
*/
// TODO: refactor this functionality - why new list?
public
void
setTuple
(
Tuple
tuple
)
{
public
void
setTuple
(
Tuple
tuple
)
throws
TupleSizeMismatchException
{
if
(
tuple
.
getArity
()
==
numOfFields
)
{
if
(
numOfTuples
!=
1
)
{
tupleBatch
=
new
ArrayList
<
Tuple
>(
1
);
...
...
@@ -642,8 +630,11 @@ public class StreamRecord implements IOReadableWritable, Serializable {
* Position of tuple in the batch
* @param tuple
* Value to set
* @throws NoSuchTupleException
* , TupleSizeMismatchException
*/
public
void
setTuple
(
int
tupleNumber
,
Tuple
tuple
)
{
public
void
setTuple
(
int
tupleNumber
,
Tuple
tuple
)
throws
NoSuchTupleException
,
TupleSizeMismatchException
{
if
(
tuple
.
getArity
()
==
numOfFields
)
{
try
{
tupleBatch
.
set
(
tupleNumber
,
tuple
);
...
...
@@ -694,6 +685,13 @@ public class StreamRecord implements IOReadableWritable, Serializable {
return
newRecord
;
}
/**
* Creates deep copy of Tuple
*
* @param tuple
* Tuple to copy
* @return Copy of the tuple
*/
public
static
Tuple
copyTuple
(
Tuple
tuple
)
{
int
numofFields
=
tuple
.
getArity
();
Tuple
newTuple
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录