public LocalMemoryContext newLocalMemoryContext() { return new LocalMemoryContext(this); } }
@Override public void updateSystemMemoryUsage(long deltaMemoryInBytes) { checkArgument(bytes + deltaMemoryInBytes >= 0, "tried to free more memory than is reserved"); bytes += deltaMemoryInBytes; memoryContext.setBytes(bytes); } }
@Override public void finish() { finished = true; blocked.set(null); if (source != null) { try { source.close(); } catch (IOException e) { throw Throwables.propagate(e); } systemMemoryContext.setBytes(source.getSystemMemoryUsage()); } }
@Override public boolean isFinished() { if (!finished) { createSourceIfNecessary(); finished = (source != null) && source.isFinished(); if (source != null) { systemMemoryContext.setBytes(source.getSystemMemoryUsage()); } } return finished; }
@Override public Page getOutput() { createSourceIfNecessary(); if (source == null) { return null; } Page page = source.getNextPage(); if (page != null) { // assure the page is in memory before handing to another operator page.assureLoaded(); // update operator stats long endCompletedBytes = source.getCompletedBytes(); long endReadTimeNanos = source.getReadTimeNanos(); operatorContext.recordGeneratedInput(endCompletedBytes - completedBytes, page.getPositionCount(), endReadTimeNanos - readTimeNanos); completedBytes = endCompletedBytes; readTimeNanos = endReadTimeNanos; } // updating system memory usage should happen after page is loaded. systemMemoryContext.setBytes(source.getSystemMemoryUsage()); return page; }
int rowsProcessed = cursorProcessor.process(operatorContext.getSession().toConnectorSession(), cursor, ROWS_PER_PAGE, pageBuilder); pageSourceMemoryContext.setBytes(cursor.getSystemMemoryUsage()); pageSourceMemoryContext.setBytes(pageSource.getSystemMemoryUsage()); pageBuilderMemoryContext.setBytes(pageBuilder.getRetainedSizeInBytes()); return null; pageBuilder.reset(); pageBuilderMemoryContext.setBytes(pageBuilder.getRetainedSizeInBytes()); return page;