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


Java BlockChannelReader.closeAndDelete方法代码示例

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


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

示例1: channelReadWriteOneSegment

import org.apache.flink.runtime.io.disk.iomanager.BlockChannelReader; //导入方法依赖的package包/类
@Test
public void channelReadWriteOneSegment()
{
	final int NUM_IOS = 1111;
	
	try {
		final Channel.ID channelID = this.ioManager.createChannel();
		final BlockChannelWriter writer = this.ioManager.createBlockChannelWriter(channelID);
		
		MemorySegment memSeg = this.memoryManager.allocatePages(new DummyInvokable(), 1).get(0);
		
		for (int i = 0; i < NUM_IOS; i++) {
			for (int pos = 0; pos < memSeg.size(); pos += 4) {
				memSeg.putInt(pos, i);
			}
			
			writer.writeBlock(memSeg);
			memSeg = writer.getNextReturnedSegment();
		}
		
		writer.close();
		
		final BlockChannelReader reader = this.ioManager.createBlockChannelReader(channelID);
		for (int i = 0; i < NUM_IOS; i++) {
			reader.readBlock(memSeg);
			memSeg = reader.getNextReturnedSegment();
			
			for (int pos = 0; pos < memSeg.size(); pos += 4) {
				if (memSeg.getInt(pos) != i) {
					Assert.fail("Read memory segment contains invalid data.");
				}
			}
		}
		
		reader.closeAndDelete();
		
		this.memoryManager.release(memSeg);
		
	} catch (Exception ex) {
		ex.printStackTrace();
		Assert.fail("TEst encountered an exception: " + ex.getMessage());
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:44,代码来源:IOManagerTest.java

示例2: testChannelWithSegments

import org.apache.flink.runtime.io.disk.iomanager.BlockChannelReader; //导入方法依赖的package包/类
private final void testChannelWithSegments(int numSegments) throws Exception
	{
		final List<MemorySegment> memory = this.memManager.allocatePages(memoryOwner, numSegments);
		final Channel.ID channel = this.ioManager.createChannel();
		
		BlockChannelWriter writer = null;
		BlockChannelReader reader = null;
		
		try {	
			writer = this.ioManager.createBlockChannelWriter(channel);
			final ChannelWriterOutputView out = new ChannelWriterOutputView(writer, memory, this.memManager.getPageSize());
			
			long writeStart = System.currentTimeMillis();
			
			int valsLeft = NUM_INTS_WRITTEN;
			while (valsLeft-- > 0) {
				out.writeInt(valsLeft);
			}
			
			out.close();
			final int numBlocks = out.getBlockCount();
			writer.close();
			writer = null;
			
			long writeElapsed = System.currentTimeMillis() - writeStart;
			
			// ----------------------------------------------------------------
			
			reader = ioManager.createBlockChannelReader(channel);
			final ChannelReaderInputView in = new ChannelReaderInputView(reader, memory, numBlocks, false);
			
			long readStart = System.currentTimeMillis();
			
			valsLeft = NUM_INTS_WRITTEN;
			while (valsLeft-- > 0) {
				in.readInt();
//				Assert.assertTrue(rec.getValue() == valsLeft);
			}
			
			in.close();
			reader.close();
			
			long readElapsed = System.currentTimeMillis() - readStart;
			
			reader.deleteChannel();
			reader = null;
			
			LOG.info("IOManager with " + numSegments + " mem segments: write " + writeElapsed + " msecs, read " + readElapsed + " msecs.");
			
			memManager.release(memory);
		}
		finally {
			if (reader != null) {
				reader.closeAndDelete();
			}
			if (writer != null) {
				writer.closeAndDelete();
			}
		}
	}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:61,代码来源:IOManagerPerformanceBenchmark.java


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