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


Java DataOutputViewStreamWrapper.flush方法代码示例

本文整理汇总了Java中org.apache.flink.core.memory.DataOutputViewStreamWrapper.flush方法的典型用法代码示例。如果您正苦于以下问题:Java DataOutputViewStreamWrapper.flush方法的具体用法?Java DataOutputViewStreamWrapper.flush怎么用?Java DataOutputViewStreamWrapper.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.core.memory.DataOutputViewStreamWrapper的用法示例。


在下文中一共展示了DataOutputViewStreamWrapper.flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public void write(DataOutputView out) throws IOException {
	int num = this.aggNames.length;
	out.writeInt(num);

	ByteArrayOutputStream boas = new ByteArrayOutputStream();
	DataOutputViewStreamWrapper bufferStream = new DataOutputViewStreamWrapper(boas);

	for (int i = 0; i < num; i++) {
		// aggregator name and type
		out.writeUTF(this.aggNames[i]);
		out.writeUTF(this.aggregates[i].getClass().getName());

		// aggregator value indirect as a byte array
		this.aggregates[i].write(bufferStream);
		bufferStream.flush();
		byte[] bytes = boas.toByteArray();
		out.writeInt(bytes.length);
		out.write(bytes);
		boas.reset();
	}
	bufferStream.close();
	boas.close();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:25,代码来源:IterationEventWithAggregators.java

示例2: serializeInitValue

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
/**
 * Copied from HeapListState.getSerializedValue(Object, Object).
 */
private byte[] serializeInitValue(List<Long> toSerialize) throws IOException {
	TypeSerializer<Long> serializer = listStateDesc.getElementSerializer();

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(baos);

	// write the same as RocksDB writes lists, with one ',' separator
	for (int i = 0; i < toSerialize.size(); i++) {
		serializer.serialize(toSerialize.get(i), view);
		if (i < toSerialize.size() - 1) {
			view.writeByte(',');
		}
	}
	view.flush();

	return baos.toByteArray();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:ImmutableListStateTest.java

示例3: serializeInitValue

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
/**
 * Copied from {@link HeapListState#getSerializedValue(Object, Object)}.
 */
private byte[] serializeInitValue(List<Long> toSerialize) throws IOException {
	TypeSerializer<Long> serializer = listStateDesc.getElementSerializer();

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(baos);

	// write the same as RocksDB writes lists, with one ',' separator
	for (int i = 0; i < toSerialize.size(); i++) {
		serializer.serialize(toSerialize.get(i), view);
		if (i < toSerialize.size() - 1) {
			view.writeByte(',');
		}
	}
	view.flush();

	return baos.toByteArray();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:21,代码来源:ImmutableListStateTest.java

示例4: getSerializedValue

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public byte[] getSerializedValue(K key, N namespace) throws Exception {
	Preconditions.checkState(namespace != null, "No namespace given.");
	Preconditions.checkState(key != null, "No key given.");

	ArrayList<V> result = stateTable.get(key, namespace);

	if (result == null) {
		return null;
	}

	TypeSerializer<V> serializer = stateDesc.getElementSerializer();

	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(baos);

	// write the same as RocksDB writes lists, with one ',' separator
	for (int i = 0; i < result.size(); i++) {
		serializer.serialize(result.get(i), view);
		if (i < result.size() -1) {
			view.writeByte(',');
		}
	}
	view.flush();

	return baos.toByteArray();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:HeapListState.java

示例5: snapshotState

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public void snapshotState(FSDataOutputStream out, long checkpointId, long timestamp) throws Exception {
	super.snapshotState(out, checkpointId, timestamp);

	// we write the panes with the key/value maps into the stream, as well as when this state
	// should have triggered and slided

	DataOutputViewStreamWrapper outView = new DataOutputViewStreamWrapper(out);

	outView.writeLong(nextEvaluationTime);
	outView.writeLong(nextSlideTime);

	panes.writeToOutput(outView, keySerializer, stateTypeSerializer);

	outView.flush();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:AbstractAlignedProcessingTimeWindowOperator.java


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