当前位置: 首页>>代码示例>>Java>>正文


Java DataOutputView类代码示例

本文整理汇总了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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:KeyedStateCheckpointOutputStreamTest.java

示例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);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:HashMapSerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:BigIntSerializer.java

示例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());
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:IntListSerializer.java

示例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);
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:EncodedValueSerializer.java

示例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());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:FlinkKafkaProducer011.java

示例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]);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:9,代码来源:CharValueArray.java

示例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);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:StreamElementSerializer.java

示例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]);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:IntPrimitiveArraySerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:ShortValueArray.java

示例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);
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:StringValueSerializer.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:DanglingPageRankITCase.java

示例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);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:StringArraySerializer.java

示例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;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:WorksetUpdateOutputCollector.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:AbstractRocksDBState.java


注:本文中的org.apache.flink.core.memory.DataOutputView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。