本文整理汇总了Java中org.apache.flink.core.memory.DataOutputView类的典型用法代码示例。如果您正苦于以下问题:Java DataOutputView类的具体用法?Java DataOutputView怎么用?Java DataOutputView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataOutputView类属于org.apache.flink.core.memory包,在下文中一共展示了DataOutputView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReadWriteMissingKeyGroups
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Test
public void testReadWriteMissingKeyGroups() throws Exception {
final KeyGroupRange keyRange = new KeyGroupRange(0, 2);
KeyedStateCheckpointOutputStream stream = createStream(keyRange);
DataOutputView dov = new DataOutputViewStreamWrapper(stream);
stream.startNewKeyGroup(1);
dov.writeInt(1);
KeyGroupsStateHandle fullHandle = stream.closeAndGetHandle();
int count = 0;
try (FSDataInputStream in = fullHandle.openInputStream()) {
DataInputView div = new DataInputViewStreamWrapper(in);
for (int kg : fullHandle.getKeyGroupRange()) {
long off = fullHandle.getOffsetForKeyGroup(kg);
if (off >= 0) {
in.seek(off);
Assert.assertEquals(1, div.readInt());
++count;
}
}
}
Assert.assertEquals(1, count);
}
示例2: serialize
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void serialize(HashMap<K, V> map, DataOutputView target) throws IOException {
final int size = map.size();
target.writeInt(size);
for (Map.Entry<K, V> entry : map.entrySet()) {
keySerializer.serialize(entry.getKey(), target);
if (entry.getValue() == null) {
target.writeBoolean(true);
} else {
target.writeBoolean(false);
valueSerializer.serialize(entry.getValue(), target);
}
}
}
示例3: writeBigInteger
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
public static void writeBigInteger(BigInteger record, DataOutputView target) throws IOException {
// null value support
if (record == null) {
target.writeInt(0);
return;
}
// fast paths for 0, 1, 10
// only reference equality is checked because equals would be too expensive
else if (record == BigInteger.ZERO) {
target.writeInt(1);
return;
}
else if (record == BigInteger.ONE) {
target.writeInt(2);
return;
}
else if (record == BigInteger.TEN) {
target.writeInt(3);
return;
}
// default
final byte[] bytes = record.toByteArray();
// the length we write is offset by four, because null and short-paths for ZERO, ONE, and TEN
target.writeInt(bytes.length + 4);
target.write(bytes);
}
示例4: copy
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
target.writeInt(source.readInt());
int len = source.readInt();
target.writeInt(len);
for (int i = 0; i < len; i++) {
target.writeInt(source.readInt());
}
}
示例5: serialize
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void serialize(byte[] record, DataOutputView target) throws IOException {
if (record == null) {
throw new IllegalArgumentException("The record must not be null.");
}
final int len = record.length;
target.writeInt(len);
target.write(record);
}
示例6: copy
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void copy(
DataInputView source, DataOutputView target) throws IOException {
boolean hasTransactionalId = source.readBoolean();
target.writeBoolean(hasTransactionalId);
if (hasTransactionalId) {
target.writeUTF(source.readUTF());
}
target.writeLong(source.readLong());
target.writeShort(source.readShort());
}
示例7: write
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeInt(position);
for (int i = 0; i < position; i++) {
out.writeChar(data[i]);
}
}
示例8: copy
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
int tag = source.readByte();
target.write(tag);
if (tag == TAG_REC_WITH_TIMESTAMP) {
// move timestamp
target.writeLong(source.readLong());
typeSerializer.copy(source, target);
}
else if (tag == TAG_REC_WITHOUT_TIMESTAMP) {
typeSerializer.copy(source, target);
}
else if (tag == TAG_WATERMARK) {
target.writeLong(source.readLong());
}
else if (tag == TAG_STREAM_STATUS) {
target.writeInt(source.readInt());
}
else if (tag == TAG_LATENCY_MARKER) {
target.writeLong(source.readLong());
target.writeInt(source.readInt());
target.writeInt(source.readInt());
} else {
throw new IOException("Corrupt stream, found tag: " + tag);
}
}
示例9: serialize
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void serialize(int[] record, DataOutputView target) throws IOException {
if (record == null) {
throw new IllegalArgumentException("The record must not be null.");
}
final int len = record.length;
target.writeInt(len);
for (int i = 0; i < len; i++) {
target.writeInt(record[i]);
}
}
示例10: copyInternal
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
protected static void copyInternal(DataInputView source, DataOutputView target) throws IOException {
int count = source.readInt();
target.writeInt(count);
int bytes = ELEMENT_LENGTH_IN_BYTES * count;
target.write(source, bytes);
}
示例11: copy
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
int len = source.readUnsignedByte();
target.writeByte(len);
if (len >= HIGH_BIT) {
int shift = 7;
int curr;
len = len & 0x7f;
while ((curr = source.readUnsignedByte()) >= HIGH_BIT) {
target.writeByte(curr);
len |= (curr & 0x7f) << shift;
shift += 7;
}
target.writeByte(curr);
len |= curr << shift;
}
for (int i = 0; i < len; i++) {
int c = source.readUnsignedByte();
target.writeByte(c);
while (c >= HIGH_BIT) {
c = source.readUnsignedByte();
target.writeByte(c);
}
}
}
示例12: write
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
out.writeDouble(diff);
out.writeDouble(rank);
out.writeDouble(danglingRank);
out.writeLong(numDanglingVertices);
out.writeLong(numVertices);
out.writeLong(edges);
}
示例13: copy
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
@Override
public void copy(DataInputView source, DataOutputView target) throws IOException {
final int len = source.readInt();
target.writeInt(len);
for (int i = 0; i < len; i++) {
StringValue.copyString(source, target);
}
}
示例14: WorksetUpdateOutputCollector
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
public WorksetUpdateOutputCollector(DataOutputView outputView, TypeSerializer<T> serializer, Collector<T> delegate) {
this.outputView = outputView;
this.serializer = serializer;
this.delegate = delegate;
this.elementsCollected = 0;
}
示例15: writeLengthFrom
import org.apache.flink.core.memory.DataOutputView; //导入依赖的package包/类
private static void writeLengthFrom(
int fromPosition,
ByteArrayOutputStreamWithPos keySerializationStream,
DataOutputView keySerializationDateDataOutputView) throws IOException {
int length = keySerializationStream.getPosition() - fromPosition;
writeVariableIntBytes(length, keySerializationDateDataOutputView);
}