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


Java DataOutputViewStreamWrapper.close方法代码示例

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


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

示例1: testSerialization

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
public static void testSerialization(String[] values) throws IOException {
	ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
	DataOutputViewStreamWrapper serializer = new DataOutputViewStreamWrapper(baos);
	
	for (String value : values) {
		StringValue sv = new StringValue(value);
		sv.write(serializer);
	}
	
	serializer.close();
	baos.close();
	
	ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
	DataInputViewStreamWrapper deserializer = new DataInputViewStreamWrapper(bais);
	
	int num = 0;
	while (bais.available() > 0) {
		StringValue deser = new StringValue();
		deser.read(deserializer);
		
		assertEquals("DeserializedString differs from original string.", values[num], deser.getValue());
		num++;
	}
	
	assertEquals("Wrong number of deserialized values", values.length, num);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:StringValueSerializationTest.java

示例2: 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

示例3: checkpointRecordQueueState

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
private void checkpointRecordQueueState() throws Exception {
	final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
	final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream);
	try {
		snapshotQueueState(this.priorityQueue, dataOutputView);
		this.queuedRecordsState.clear();
		this.queuedRecordsState.add(byteArrayOutputStream.toByteArray());
	} finally {
		dataOutputView.close();
		byteArrayOutputStream.close();
	}
}
 
开发者ID:haoch,项目名称:flink-siddhi,代码行数:13,代码来源:AbstractSiddhiOperator.java

示例4: checkpointRecordQueueState

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
private void checkpointRecordQueueState() throws Exception {
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    final DataOutputViewStreamWrapper dataOutputView = new DataOutputViewStreamWrapper(byteArrayOutputStream);
    try {
        snapshotQueueState(this.priorityQueue, dataOutputView);
        this.queuedRecordsState.clear();
        this.queuedRecordsState.add(byteArrayOutputStream.toByteArray());
    } finally {
        dataOutputView.close();
        byteArrayOutputStream.close();
    }
}
 
开发者ID:apache,项目名称:bahir-flink,代码行数:13,代码来源:AbstractSiddhiOperator.java

示例5: close

import org.apache.flink.core.memory.DataOutputViewStreamWrapper; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
	try {
		DataOutputViewStreamWrapper o = this.outView;
		if (o != null) {
			o.close();
		}
	}
	finally {
		super.close();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:BinaryOutputFormat.java


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