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


Java SpillingResettableMutableObjectIterator.next方法代码示例

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


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

示例1: runStreamedOuterFirst

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
private void runStreamedOuterFirst() throws Exception {
	if (LOG.isDebugEnabled())  {
		LOG.debug(this.taskContext.formatLogString("Running Cross with Nested-Loops: " +
				"First input is outer side, second input is inner (spilling) side."));
	}
	
	final MutableObjectIterator<T1> in1 = this.taskContext.getInput(0);
	final MutableObjectIterator<T2> in2 = this.taskContext.getInput(1);
	
	final TypeSerializer<T1> serializer1 = this.taskContext.<T1>getInputSerializer(0).getSerializer();
	final TypeSerializer<T2> serializer2 = this.taskContext.<T2>getInputSerializer(1).getSerializer();
	
	final SpillingResettableMutableObjectIterator<T2> spillVals = new SpillingResettableMutableObjectIterator<T2>(
			in2, serializer2, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide,
			this.taskContext.getOwningNepheleTask());
	this.spillIter = spillVals;
	
	T1 val1;
	final T1 val1Reuse = serializer1.createInstance();
	T1 val1Copy = serializer1.createInstance();
	T2 val2;
	final T2 val2Reuse = serializer2.createInstance();

	final CrossFunction<T1, T2, OT> crosser = this.taskContext.getStub();
	final Collector<OT> collector = this.taskContext.getOutputCollector();
	
	// for all blocks
	while (this.running && ((val1 = in1.next(val1Reuse)) != null)) {
		// for all values from the spilling side
		while (this.running && ((val2 = spillVals.next(val2Reuse)) != null)) {
			val1Copy = serializer1.copy(val1, val1Copy);
			collector.collect(crosser.cross(val1Copy, val2));
			//crosser.cross(val1Copy, val2, collector);
		}
		spillVals.reset();
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:38,代码来源:CrossDriver.java

示例2: runStreamedOuterSecond

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
private void runStreamedOuterSecond() throws Exception {
	if (LOG.isDebugEnabled())  {
		LOG.debug(this.taskContext.formatLogString("Running Cross with Nested-Loops: " +
				"First input is inner (spilling) side, second input is outer side."));
	}
	final MutableObjectIterator<T1> in1 = this.taskContext.getInput(0);
	final MutableObjectIterator<T2> in2 = this.taskContext.getInput(1);
	
	final TypeSerializer<T1> serializer1 = this.taskContext.<T1>getInputSerializer(0).getSerializer();
	final TypeSerializer<T2> serializer2 = this.taskContext.<T2>getInputSerializer(1).getSerializer();
	
	final SpillingResettableMutableObjectIterator<T1> spillVals = new SpillingResettableMutableObjectIterator<T1>(
			in1, serializer1, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide,
			this.taskContext.getOwningNepheleTask());
	this.spillIter = spillVals;
	
	T1 val1;
	final T1 val1Reuse = serializer1.createInstance();
	T2 val2;
	final T2 val2Reuse = serializer2.createInstance();
	T2 val2Copy = serializer2.createInstance();
	
	final CrossFunction<T1, T2, OT> crosser = this.taskContext.getStub();
	final Collector<OT> collector = this.taskContext.getOutputCollector();
	
	// for all blocks
	while (this.running && (val2 = in2.next(val2Reuse)) != null) {
		// for all values from the spilling side
		while (this.running && (val1 = spillVals.next(val1Reuse)) != null) {
			val2Copy = serializer2.copy(val2, val2Copy);
			collector.collect(crosser.cross(val1, val2Copy));
			//crosser.cross(val1, val2Copy, collector);
		}
		spillVals.reset();
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:37,代码来源:CrossDriver.java

示例3: runBlockedOuterFirst

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
private void runBlockedOuterFirst() throws Exception {
	if (LOG.isDebugEnabled())  {
		LOG.debug(this.taskContext.formatLogString("Running Cross with Block-Nested-Loops: " +
				"First input is outer (blocking) side, second input is inner (spilling) side."));
	}
		
	final MutableObjectIterator<T1> in1 = this.taskContext.getInput(0);
	final MutableObjectIterator<T2> in2 = this.taskContext.getInput(1);
	
	final TypeSerializer<T1> serializer1 = this.taskContext.<T1>getInputSerializer(0).getSerializer();
	final TypeSerializer<T2> serializer2 = this.taskContext.<T2>getInputSerializer(1).getSerializer();
	
	final BlockResettableMutableObjectIterator<T1> blockVals = 
			new BlockResettableMutableObjectIterator<T1>(this.memManager, in1, serializer1, this.memPagesForBlockSide,
						this.taskContext.getOwningNepheleTask());
	this.blockIter = blockVals;
	
	final SpillingResettableMutableObjectIterator<T2> spillVals = new SpillingResettableMutableObjectIterator<T2>(
			in2, serializer2, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide,
			this.taskContext.getOwningNepheleTask());
	this.spillIter = spillVals;
	
	T1 val1;
	final T1 val1Reuse = serializer1.createInstance();
	T2 val2;
	final T2 val2Reuse = serializer2.createInstance();
	T2 val2Copy = serializer2.createInstance();
	
	final CrossFunction<T1, T2, OT> crosser = this.taskContext.getStub();
	final Collector<OT> collector = this.taskContext.getOutputCollector();
	
	// for all blocks
	do {
		// for all values from the spilling side
		while (this.running && ((val2 = spillVals.next(val2Reuse)) != null)) {
			// for all values in the block
			while ((val1 = blockVals.next(val1Reuse)) != null) {
				val2Copy = serializer2.copy(val2, val2Copy);
				collector.collect(crosser.cross(val1,val2Copy));
				//crosser.cross(val1, val2Copy, collector);
			}
			blockVals.reset();
		}
		spillVals.reset();
	}
	while (this.running && blockVals.nextBlock());
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:48,代码来源:CrossDriver.java

示例4: runBlockedOuterSecond

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
private void runBlockedOuterSecond() throws Exception {
	if (LOG.isDebugEnabled())  {
		LOG.debug(this.taskContext.formatLogString("Running Cross with Block-Nested-Loops: " +
				"First input is inner (spilling) side, second input is outer (blocking) side."));
	}
	
	final MutableObjectIterator<T1> in1 = this.taskContext.getInput(0);
	final MutableObjectIterator<T2> in2 = this.taskContext.getInput(1);
	
	final TypeSerializer<T1> serializer1 = this.taskContext.<T1>getInputSerializer(0).getSerializer();
	final TypeSerializer<T2> serializer2 = this.taskContext.<T2>getInputSerializer(1).getSerializer();
	
	final SpillingResettableMutableObjectIterator<T1> spillVals = new SpillingResettableMutableObjectIterator<T1>(
			in1, serializer1, this.memManager, this.taskContext.getIOManager(), this.memPagesForSpillingSide,
			this.taskContext.getOwningNepheleTask());
	this.spillIter = spillVals;
	
	final BlockResettableMutableObjectIterator<T2> blockVals = 
			new BlockResettableMutableObjectIterator<T2>(this.memManager, in2, serializer2, this.memPagesForBlockSide,
					this.taskContext.getOwningNepheleTask());
	this.blockIter = blockVals;
	
	T1 val1;
	final T1 val1Reuse = serializer1.createInstance();
	T1 val1Copy = serializer1.createInstance();
	T2 val2;
	final T2 val2Reuse = serializer2.createInstance();

	final CrossFunction<T1, T2, OT> crosser = this.taskContext.getStub();
	final Collector<OT> collector = this.taskContext.getOutputCollector();
	
	// for all blocks
	do {
		// for all values from the spilling side
		while (this.running && ((val1 = spillVals.next(val1Reuse)) != null)) {
			// for all values in the block
			while (this.running && ((val2 = blockVals.next(val2Reuse)) != null)) {
				val1Copy = serializer1.copy(val1, val1Copy);
				collector.collect(crosser.cross(val1Copy, val2));
				//crosser.cross(val1Copy, val2, collector);
			}
			blockVals.reset();
		}
		spillVals.reset();
	}
	while (this.running && blockVals.nextBlock());
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:48,代码来源:CrossDriver.java

示例5: testResettableIterator

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
/**
 * Tests the resettable iterator with too little memory, so that the data
 * has to be written to disk.
 */
@Test
public void testResettableIterator() {
	try {
		final AbstractInvokable memOwner = new DummyInvokable();

		// create the resettable Iterator
		SpillingResettableMutableObjectIterator<Record> iterator = new SpillingResettableMutableObjectIterator<Record>(
			this.reader, this.serializer, this.memman, this.ioman, 2, memOwner);

		// open the iterator
		iterator.open();
		
		// now test walking through the iterator
		int count = 0;
		Record target = new Record();
		while ((target = iterator.next(target)) != null) {
			Assert.assertEquals("In initial run, element " + count + " does not match expected value!", count++,
				target.getField(0, IntValue.class).getValue());
		}
		Assert.assertEquals("Too few elements were deserialzied in initial run!", NUM_TESTRECORDS, count);
		// test resetting the iterator a few times
		for (int j = 0; j < 10; ++j) {
			count = 0;
			iterator.reset();
			target = new Record();
			// now we should get the same results
			while ((target = iterator.next(target)) != null) {
				Assert.assertEquals("After reset nr. " + j + 1 + " element " + count
					+ " does not match expected value!", count++, target.getField(0, IntValue.class).getValue());
			}
			Assert.assertEquals("Too few elements were deserialzied after reset nr. " + j + 1 + "!", NUM_TESTRECORDS,
				count);
		}
		// close the iterator
		iterator.close();
	} catch (Exception ex)  {
		ex.printStackTrace();
		Assert.fail("Test encountered an exception.");
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:45,代码来源:SpillingResettableMutableObjectIteratorTest.java

示例6: testResettableIteratorInMemory

import org.apache.flink.runtime.operators.resettable.SpillingResettableMutableObjectIterator; //导入方法依赖的package包/类
/**
 * Tests the resettable iterator with enough memory so that all data is kept locally in memory.
 */
@Test
public void testResettableIteratorInMemory() {
	try {
		final AbstractInvokable memOwner = new DummyInvokable();

		// create the resettable Iterator
		SpillingResettableMutableObjectIterator<Record> iterator = new SpillingResettableMutableObjectIterator<Record>(
			this.reader, this.serializer, this.memman, this.ioman, 20, memOwner);
		
		// open the iterator
		iterator.open();

		// now test walking through the iterator
		int count = 0;
		Record target = new Record();
		while ((target = iterator.next(target)) != null) {
			Assert.assertEquals("In initial run, element " + count + " does not match expected value!", count++,
				target.getField(0, IntValue.class).getValue());
		}
		Assert.assertEquals("Too few elements were deserialzied in initial run!", NUM_TESTRECORDS, count);
		// test resetting the iterator a few times
		for (int j = 0; j < 10; ++j) {
			count = 0;
			iterator.reset();
			target = new Record();
			// now we should get the same results
			while ((target = iterator.next(target)) != null) {
				Assert.assertEquals("After reset nr. " + j + 1 + " element " + count
					+ " does not match expected value!", count++, target.getField(0, IntValue.class).getValue());
			}
			Assert.assertEquals("Too few elements were deserialzied after reset nr. " + j + 1 + "!", NUM_TESTRECORDS,
				count);
		}
		// close the iterator
		iterator.close();
	} catch (Exception ex)  {
		ex.printStackTrace();
		Assert.fail("Test encountered an exception.");
	}
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:44,代码来源:SpillingResettableMutableObjectIteratorTest.java


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