當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。