public void pushExportBuffer( int partitionId, String signature, long uso, long bufferPtr, ByteBuffer buffer, boolean sync, boolean endOfStream) { // System.out.println("In generation " + m_timestamp + " partition " + partitionId + " // signature " + signature + (buffer == null ? " null buffer " : (" buffer length " + // buffer.remaining()))); // for (Integer i : m_dataSourcesByPartition.keySet()) { // System.out.println("Have partition " + i); // } assert (m_dataSourcesByPartition.containsKey(partitionId)); assert (m_dataSourcesByPartition.get(partitionId).containsKey(signature)); HashMap<String, ExportDataSource> sources = m_dataSourcesByPartition.get(partitionId); if (sources == null) { exportLog.error( "Could not find export data sources for partition " + partitionId + " generation " + m_timestamp + " the export data is being discarded"); DBBPool.deleteCharArrayMemory(bufferPtr); return; } ExportDataSource source = sources.get(signature); if (source == null) { exportLog.error( "Could not find export data source for partition " + partitionId + " signature " + signature + " generation " + m_timestamp + " the export data is being discarded"); DBBPool.deleteCharArrayMemory(bufferPtr); return; } source.pushExportBuffer(uso, bufferPtr, buffer, sync, endOfStream); }
public void pushExportBuffer( long uso, final long bufferPtr, ByteBuffer buffer, boolean sync, boolean endOfStream) { final java.util.concurrent.atomic.AtomicBoolean deleted = new java.util.concurrent.atomic.AtomicBoolean(false); synchronized (m_committedBuffers) { if (endOfStream) { assert (!m_endOfStream); assert (bufferPtr == 0); assert (buffer == null); assert (!sync); m_endOfStream = endOfStream; if (m_committedBuffers.sizeInBytes() == 0) { exportLog.info("Pushed EOS buffer with 0 bytes remaining"); try { m_onDrain.run(); } finally { m_onDrain = null; } } return; } assert (!m_endOfStream); if (buffer != null) { if (buffer.capacity() > 0) { try { m_committedBuffers.offer( new StreamBlock( new BBContainer(buffer, bufferPtr) { @Override public void discard() { DBBPool.deleteCharArrayMemory(address); deleted.set(true); } }, uso, false)); } catch (IOException e) { exportLog.error(e); if (!deleted.get()) { DBBPool.deleteCharArrayMemory(bufferPtr); } } } else { /* * TupleStreamWrapper::setBytesUsed propagates the USO by sending * over an empty stream block. The block will be deleted * on the native side when this method returns */ exportLog.info( "Syncing first unpolled USO to " + uso + " for table " + m_tableName + " partition " + m_partitionId); m_firstUnpolledUso = uso; } } if (sync) { try { // Don't do a real sync, just write the in memory buffers // to a file. @Quiesce or blocking snapshot will do the sync m_committedBuffers.sync(true); } catch (IOException e) { exportLog.error(e); } } } }