org.apache.flink.runtime.io.disk.SpillingBuffer Java Examples

The following examples show how to use org.apache.flink.runtime.io.disk.SpillingBuffer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpillingResettableIterator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.instance = serializer.createInstance();
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #2
Source File: TempBarrier.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
	final MutableObjectIterator<T> input = this.input;
	final TypeSerializer<T> serializer = this.serializer;
	final SpillingBuffer buffer = this.buffer;
	
	try {
		T record = serializer.createInstance();
		
		while (this.running && ((record = input.next(record)) != null)) {
			serializer.serialize(record, buffer);
		}
		
		TempBarrier.this.writingDone();
	}
	catch (Throwable t) {
		TempBarrier.this.setException(t);
	}
}
 
Example #3
Source File: SpillingResettableIterator.java    From flink with Apache License 2.0 6 votes vote down vote up
private SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.instance = serializer.createInstance();
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #4
Source File: SpillingResettableMutableObjectIterator.java    From flink with Apache License 2.0 6 votes vote down vote up
private SpillingResettableMutableObjectIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #5
Source File: TempBarrier.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
	final MutableObjectIterator<T> input = this.input;
	final TypeSerializer<T> serializer = this.serializer;
	final SpillingBuffer buffer = this.buffer;
	
	try {
		T record = serializer.createInstance();
		
		while (this.running && ((record = input.next(record)) != null)) {
			serializer.serialize(record, buffer);
		}
		
		TempBarrier.this.writingDone();
	}
	catch (Throwable t) {
		TempBarrier.this.setException(t);
	}
}
 
Example #6
Source File: SpillingResettableIterator.java    From flink with Apache License 2.0 6 votes vote down vote up
private SpillingResettableIterator(Iterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.instance = serializer.createInstance();
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #7
Source File: SpillingResettableMutableObjectIterator.java    From flink with Apache License 2.0 6 votes vote down vote up
private SpillingResettableMutableObjectIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #8
Source File: TempBarrier.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
	final MutableObjectIterator<T> input = this.input;
	final TypeSerializer<T> serializer = this.serializer;
	final SpillingBuffer buffer = this.buffer;
	
	try {
		T record = serializer.createInstance();
		
		while (this.running && ((record = input.next(record)) != null)) {
			serializer.serialize(record, buffer);
		}
		
		TempBarrier.this.writingDone();
	}
	catch (Throwable t) {
		TempBarrier.this.setException(t);
	}
}
 
Example #9
Source File: SpillingResettableMutableObjectIterator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private SpillingResettableMutableObjectIterator(MutableObjectIterator<T> input, TypeSerializer<T> serializer,
		MemoryManager memoryManager, IOManager ioManager,
		List<MemorySegment> memory, boolean releaseMemOnClose)
{
	this.memoryManager = memoryManager;
	this.input = input;
	this.serializer = serializer;
	this.memorySegments = memory;
	this.releaseMemoryOnClose = releaseMemOnClose;
	
	if (LOG.isDebugEnabled()) {
		LOG.debug("Creating spilling resettable iterator with " + memory.size() + " pages of memory.");
	}
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(memory), memoryManager.getPageSize());
}
 
Example #10
Source File: TempBarrier.java    From flink with Apache License 2.0 5 votes vote down vote up
public TempBarrier(AbstractInvokable owner, MutableObjectIterator<T> input, TypeSerializerFactory<T> serializerFactory,
		MemoryManager memManager, IOManager ioManager, int numPages) throws MemoryAllocationException
{
	this.serializer = serializerFactory.getSerializer();
	this.memManager = memManager;
	
	this.memory = new ArrayList<MemorySegment>(numPages);
	memManager.allocatePages(owner, this.memory, numPages);
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(this.memory), memManager.getPageSize());
	this.tempWriter = new TempWritingThread(input, serializerFactory.getSerializer(), this.buffer);
}
 
Example #11
Source File: TempBarrier.java    From flink with Apache License 2.0 5 votes vote down vote up
private TempWritingThread(MutableObjectIterator<T> input, TypeSerializer<T> serializer, SpillingBuffer buffer) {
	super("Temp writer");
	setDaemon(true);
	
	this.input = input;
	this.serializer = serializer;
	this.buffer = buffer;
}
 
Example #12
Source File: KeyGroupStream.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
KeyGroupStream(
    TypeSerializer<T> serializer, IOManager ioManager, MemorySegmentPool memorySegmentPool) {
  this.serializer = Objects.requireNonNull(serializer);
  this.memoryPool = Objects.requireNonNull(memorySegmentPool);

  // SpillingBuffer requires at least 1 memory segment to be present at construction, otherwise it
  // fails
  // so we
  memorySegmentPool.ensureAtLeastOneSegmentPresent();
  this.target =
      new SpillingBuffer(ioManager, memorySegmentPool, memorySegmentPool.getSegmentSize());
}
 
Example #13
Source File: KeyGroupStream.java    From flink-statefun with Apache License 2.0 5 votes vote down vote up
KeyGroupStream(
    TypeSerializer<T> serializer, IOManager ioManager, MemorySegmentPool memorySegmentPool) {
  this.serializer = Objects.requireNonNull(serializer);
  this.memoryPool = Objects.requireNonNull(memorySegmentPool);

  // SpillingBuffer requires at least 1 memory segment to be present at construction, otherwise it
  // fails
  // so we
  memorySegmentPool.ensureAtLeastOneSegmentPresent();
  this.target =
      new SpillingBuffer(ioManager, memorySegmentPool, memorySegmentPool.getSegmentSize());
}
 
Example #14
Source File: TempBarrier.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private TempWritingThread(MutableObjectIterator<T> input, TypeSerializer<T> serializer, SpillingBuffer buffer) {
	super("Temp writer");
	setDaemon(true);
	
	this.input = input;
	this.serializer = serializer;
	this.buffer = buffer;
}
 
Example #15
Source File: TempBarrier.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public TempBarrier(AbstractInvokable owner, MutableObjectIterator<T> input, TypeSerializerFactory<T> serializerFactory,
		MemoryManager memManager, IOManager ioManager, int numPages) throws MemoryAllocationException
{
	this.serializer = serializerFactory.getSerializer();
	this.memManager = memManager;
	
	this.memory = new ArrayList<MemorySegment>(numPages);
	memManager.allocatePages(owner, this.memory, numPages);
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(this.memory), memManager.getPageSize());
	this.tempWriter = new TempWritingThread(input, serializerFactory.getSerializer(), this.buffer);
}
 
Example #16
Source File: TempBarrier.java    From flink with Apache License 2.0 5 votes vote down vote up
public TempBarrier(AbstractInvokable owner, MutableObjectIterator<T> input, TypeSerializerFactory<T> serializerFactory,
		MemoryManager memManager, IOManager ioManager, int numPages) throws MemoryAllocationException
{
	this.serializer = serializerFactory.getSerializer();
	this.memManager = memManager;
	
	this.memory = new ArrayList<MemorySegment>(numPages);
	memManager.allocatePages(owner, this.memory, numPages);
	
	this.buffer = new SpillingBuffer(ioManager, new ListMemorySegmentSource(this.memory), memManager.getPageSize());
	this.tempWriter = new TempWritingThread(input, serializerFactory.getSerializer(), this.buffer);
}
 
Example #17
Source File: TempBarrier.java    From flink with Apache License 2.0 5 votes vote down vote up
private TempWritingThread(MutableObjectIterator<T> input, TypeSerializer<T> serializer, SpillingBuffer buffer) {
	super("Temp writer");
	setDaemon(true);
	
	this.input = input;
	this.serializer = serializer;
	this.buffer = buffer;
}