Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
c310f4c7
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,发现更多精彩内容 >>
提交
c310f4c7
编写于
7月 21, 2013
作者:
S
StephanEwen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added bulk copy methods to memory segment.
上级
7efa33c2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
31 deletion
+76
-31
nephele/nephele-common/src/main/java/eu/stratosphere/nephele/services/memorymanager/MemorySegment.java
...osphere/nephele/services/memorymanager/MemorySegment.java
+76
-31
未找到文件。
nephele/nephele-common/src/main/java/eu/stratosphere/nephele/services/memorymanager/MemorySegment.java
浏览文件 @
c310f4c7
...
...
@@ -18,6 +18,7 @@ package eu.stratosphere.nephele.services.memorymanager;
import
java.io.DataInput
;
import
java.io.DataOutput
;
import
java.io.IOException
;
import
java.nio.BufferOverflowException
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteOrder
;
...
...
@@ -260,6 +261,7 @@ public class MemorySegment {
* segment's end.
*/
public
final
void
get
(
int
index
,
byte
[]
dst
,
int
offset
,
int
length
)
{
// system arraycopy does the boundary checks anyways, no need to check extra
System
.
arraycopy
(
this
.
memory
,
index
,
dst
,
offset
,
length
);
}
...
...
@@ -279,40 +281,10 @@ public class MemorySegment {
* segment's end.
*/
public
final
void
put
(
int
index
,
byte
[]
src
,
int
offset
,
int
length
)
{
// system arraycopy does the boundary checks anyways, no need to check extra
System
.
arraycopy
(
src
,
offset
,
this
.
memory
,
index
,
length
);
}
/**
* Bulk get method. Copies length memory from the specified offset to the
* provided <tt>DataOutput</tt>.
*
* @param out The data output object to copy the data to.
* @param offset The first byte to by copied.
* @param length The number of bytes to copy.
* @return This view itself.
*
* @throws IOException Thrown, if the DataOutput encountered a problem upon writing.
*/
public
final
void
get
(
DataOutput
out
,
int
offset
,
int
length
)
throws
IOException
{
out
.
write
(
this
.
memory
,
offset
,
length
);
}
/**
* Bulk put method. Copies length memory from the given DataInput to the
* memory starting at position offset.
*
* @param in The DataInput to get the data from.
* @param offset The position in the memory segment to copy the chunk to.
* @param length The number of bytes to get.
* @return This random access view itself.
*
* @throws IOException Thrown, if the DataInput encountered a problem upon reading,
* such as an End-Of-File.
*/
public
final
void
put
(
DataInput
in
,
int
offset
,
int
length
)
throws
IOException
{
in
.
readFully
(
this
.
memory
,
offset
,
length
);
}
/**
* Reads one byte at the given position and returns its boolean
* representation.
...
...
@@ -905,6 +877,78 @@ public class MemorySegment {
putLongBigEndian
(
index
,
Double
.
doubleToRawLongBits
(
value
));
}
// -------------------------------------------------------------------------
// Bulk Read and Write Methods
// -------------------------------------------------------------------------
/**
* Bulk get method. Copies length memory from the specified offset to the
* provided <tt>DataOutput</tt>.
*
* @param out The data output object to copy the data to.
* @param offset The first byte to by copied.
* @param length The number of bytes to copy.
*
* @throws IOException Thrown, if the DataOutput encountered a problem upon writing.
*/
public
final
void
get
(
DataOutput
out
,
int
offset
,
int
length
)
throws
IOException
{
out
.
write
(
this
.
memory
,
offset
,
length
);
}
/**
* Bulk put method. Copies length memory from the given DataInput to the
* memory starting at position offset.
*
* @param in The DataInput to get the data from.
* @param offset The position in the memory segment to copy the chunk to.
* @param length The number of bytes to get.
*
* @throws IOException Thrown, if the DataInput encountered a problem upon reading,
* such as an End-Of-File.
*/
public
final
void
put
(
DataInput
in
,
int
offset
,
int
length
)
throws
IOException
{
in
.
readFully
(
this
.
memory
,
offset
,
length
);
}
/**
* Bulk copy method. Copies {@code numBytes} bytes from this memory segment, starting at position
* {@code offset} to the target memory segment. The bytes will be put into the target segment
* starting at position {@code targetOffset}.
*
* @param offset The position where the bytes are started to be read from in this memory segment.
* @param target The memory segment to copy the bytes to.
* @param targetOffset The position in the target memory segment to copy the chunk to.
* @param numBytes The number of bytes to copy.
*
* @throws IndexOutOfBoundsException If either of the offsets is invalid, or the source segment does not
* contain the given number of bytes (starting from offset), or the target segment does
* not have enough space for the bytes (counting from targetOffset).
*/
public
final
void
copyTo
(
int
offset
,
MemorySegment
target
,
int
targetOffset
,
int
numBytes
)
{
// system arraycopy does the boundary checks anyways, no need to check extra
System
.
arraycopy
(
this
.
memory
,
offset
,
target
.
memory
,
targetOffset
,
numBytes
);
}
/**
* Bulk copy method. Copies {@code numBytes} bytes from this memory segment, starting at position
* {@code offset} to the target {@code ByteBuffer}. The bytes will be put into the target buffer
* starting at the buffer's current position. If this method attempts to write more bytes than
* the target byte buffer has remaining (with respect to {@link ByteBuffer#remaining()}),
* this method will cause a {@link BufferOverflowException}.
*
* @param offset The position where the bytes are started to be read from in this memory segment.
* @param target The ByteBuffer to copy the bytes to.
* @param numBytes The number of bytes to copy.
*
* @throws IndexOutOfBoundsException If either of the offsets is invalid, or the source segment does not
* contain the given number of bytes (starting from offset), or the target segment does
* not have enough space for the bytes (counting from targetOffset).
*/
public
final
void
copyTo
(
int
offset
,
ByteBuffer
target
,
int
numBytes
)
{
// ByteBuffer performs the boundy checks
target
.
put
(
this
.
memory
,
offset
,
numBytes
);
}
// -------------------------------------------------------------------------
// Comparisons & Swapping
// -------------------------------------------------------------------------
...
...
@@ -920,6 +964,7 @@ public class MemorySegment {
}
public
static
final
void
swapBytes
(
MemorySegment
seg1
,
MemorySegment
seg2
,
byte
[]
tempBuffer
,
int
offset1
,
int
offset2
,
int
len
)
{
// system arraycopy does the boundary checks anyways, no need to check extra
System
.
arraycopy
(
seg1
.
memory
,
offset1
,
tempBuffer
,
0
,
len
);
System
.
arraycopy
(
seg2
.
memory
,
offset2
,
seg1
.
memory
,
offset1
,
len
);
System
.
arraycopy
(
tempBuffer
,
0
,
seg2
.
memory
,
offset2
,
len
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录