private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } } }
/** * Sends a new read requests, if further requests remain. Otherwise, this method adds the segment * directly to the readers return queue. * * @param seg The segment to use for the read request. * @throws IOException Thrown, if the reader is in error. */ protected void sendReadRequest(MemorySegment seg) throws IOException { if (this.numRequestsRemaining != 0) { this.reader.readBlock(seg); if (this.numRequestsRemaining != -1) { this.numRequestsRemaining--; } } else { // directly add it to the end of the return queue this.freeMem.add(seg); } } }
/** * Sends a new read requests, if further requests remain. Otherwise, this method adds the segment * directly to the readers return queue. * * @param seg The segment to use for the read request. * @throws IOException Thrown, if the reader is in error. */ protected void sendReadRequest(MemorySegment seg) throws IOException { if (this.numRequestsRemaining != 0) { this.reader.readBlock(seg); if (this.numRequestsRemaining != -1) { this.numRequestsRemaining--; } } else { // directly add it to the end of the return queue this.freeMem.add(seg); } } }
/** * Sends a new read requests, if further requests remain. Otherwise, this method adds the segment * directly to the readers return queue. * * @param seg The segment to use for the read request. * @throws IOException Thrown, if the reader is in error. */ protected void sendReadRequest(MemorySegment seg) throws IOException { if (this.numRequestsRemaining != 0) { this.reader.readBlock(seg); if (this.numRequestsRemaining != -1) { this.numRequestsRemaining--; } } else { // directly add it to the end of the return queue this.freeMem.add(seg); } }
/** * Sends a new read requests, if further requests remain. Otherwise, this method adds the segment * directly to the readers return queue. * * @param seg The segment to use for the read request. * @throws IOException Thrown, if the reader is in error. */ protected void sendReadRequest(MemorySegment seg) throws IOException { if (this.numRequestsRemaining != 0) { this.reader.readBlock(seg); if (this.numRequestsRemaining != -1) { this.numRequestsRemaining--; } } else { // directly add it to the end of the return queue this.freeMem.add(seg); } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } else { memManager.release(seg); } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } else { memManager.release(seg); } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } else { memManager.release(seg); } } }
private void sendReadRequest(MemorySegment seg) throws IOException { if (numRequestsRemaining > 0) { reader.readBlock(seg); numRequestsRemaining--; } else { memManager.release(seg); } } }
private ReadEnd(MemorySegment firstMemSegment, LinkedBlockingQueue<MemorySegment> emptyBufferTarget, Deque<MemorySegment> fullBufferSource, BlockChannelReader<MemorySegment> spilledBufferSource, List<MemorySegment> emptyBuffers, int numBuffersSpilled) throws IOException { super(firstMemSegment, firstMemSegment.getInt(0), HEADER_LENGTH); this.emptyBufferTarget = emptyBufferTarget; this.fullBufferSource = fullBufferSource; this.spilledBufferSource = spilledBufferSource; requestsRemaining = numBuffersSpilled; this.spilledBuffersRemaining = numBuffersSpilled; // send the first requests while (requestsRemaining > 0 && emptyBuffers.size() > 0) { this.spilledBufferSource.readBlock(emptyBuffers.remove(emptyBuffers.size() - 1)); requestsRemaining--; } }
private ReadEnd(MemorySegment firstMemSegment, LinkedBlockingQueue<MemorySegment> emptyBufferTarget, Deque<MemorySegment> fullBufferSource, BlockChannelReader<MemorySegment> spilledBufferSource, List<MemorySegment> emptyBuffers, int numBuffersSpilled) throws IOException { super(firstMemSegment, firstMemSegment.getInt(0), HEADER_LENGTH); this.emptyBufferTarget = emptyBufferTarget; this.fullBufferSource = fullBufferSource; this.spilledBufferSource = spilledBufferSource; requestsRemaining = numBuffersSpilled; this.spilledBuffersRemaining = numBuffersSpilled; // send the first requests while (requestsRemaining > 0 && emptyBuffers.size() > 0) { this.spilledBufferSource.readBlock(emptyBuffers.remove(emptyBuffers.size() - 1)); requestsRemaining--; } }
private ReadEnd(MemorySegment firstMemSegment, LinkedBlockingQueue<MemorySegment> emptyBufferTarget, Deque<MemorySegment> fullBufferSource, BlockChannelReader<MemorySegment> spilledBufferSource, List<MemorySegment> emptyBuffers, int numBuffersSpilled) throws IOException { super(firstMemSegment, firstMemSegment.getInt(0), HEADER_LENGTH); this.emptyBufferTarget = emptyBufferTarget; this.fullBufferSource = fullBufferSource; this.spilledBufferSource = spilledBufferSource; requestsRemaining = numBuffersSpilled; this.spilledBuffersRemaining = numBuffersSpilled; // send the first requests while (requestsRemaining > 0 && emptyBuffers.size() > 0) { this.spilledBufferSource.readBlock(emptyBuffers.remove(emptyBuffers.size() - 1)); requestsRemaining--; } }
private ReadEnd(MemorySegment firstMemSegment, LinkedBlockingQueue<MemorySegment> emptyBufferTarget, Deque<MemorySegment> fullBufferSource, BlockChannelReader<MemorySegment> spilledBufferSource, List<MemorySegment> emptyBuffers, int numBuffersSpilled) throws IOException { super(firstMemSegment, firstMemSegment.getInt(0), HEADER_LENGTH); this.emptyBufferTarget = emptyBufferTarget; this.fullBufferSource = fullBufferSource; this.spilledBufferSource = spilledBufferSource; requestsRemaining = numBuffersSpilled; this.spilledBuffersRemaining = numBuffersSpilled; // send the first requests while (requestsRemaining > 0 && emptyBuffers.size() > 0) { this.spilledBufferSource.readBlock(emptyBuffers.remove(emptyBuffers.size() - 1)); requestsRemaining--; } }
protected List<MemorySegment> readAllBuffers(FileIOChannel.ID id, int blockCount) throws IOException { // we are guaranteed to stay in memory ensureNumBuffersReturned(blockCount); LinkedBlockingQueue<MemorySegment> retSegments = new LinkedBlockingQueue<>(); BlockChannelReader<MemorySegment> reader = FileChannelUtil.createBlockChannelReader( ioManager, id, retSegments, compressionEnable, compressionCodecFactory, compressionBlockSize, segmentSize); for (int i = 0; i < blockCount; i++) { reader.readBlock(availableMemory.remove(availableMemory.size() - 1)); } reader.closeAndDelete(); final List<MemorySegment> buffers = new ArrayList<>(); retSegments.drainTo(buffers); return buffers; }
@Override protected MemorySegment nextSegment(MemorySegment current) throws IOException { // use the buffer to send the next request if (requestsRemaining > 0) { requestsRemaining--; spilledBufferSource.readBlock(current); } else { emptyBufferTarget.add(current); } // get the next buffer either from the return queue, or the full buffer source if (spilledBuffersRemaining > 0) { spilledBuffersRemaining--; try { return spilledBufferSource.getReturnQueue().take(); } catch (InterruptedException e) { throw new RuntimeException("Read End was interrupted while waiting for spilled buffer.", e); } } else if (fullBufferSource.size() > 0) { return fullBufferSource.removeFirst(); } else { clear(); // delete the channel, if we had one if (spilledBufferSource != null) { spilledBufferSource.closeAndDelete(); } throw new EOFException(); } }
@Override protected MemorySegment nextSegment(MemorySegment current) throws IOException { // use the buffer to send the next request if (requestsRemaining > 0) { requestsRemaining--; spilledBufferSource.readBlock(current); } else { emptyBufferTarget.add(current); } // get the next buffer either from the return queue, or the full buffer source if (spilledBuffersRemaining > 0) { spilledBuffersRemaining--; try { return spilledBufferSource.getReturnQueue().take(); } catch (InterruptedException e) { throw new RuntimeException("Read End was interrupted while waiting for spilled buffer.", e); } } else if (fullBufferSource.size() > 0) { return fullBufferSource.removeFirst(); } else { clear(); // delete the channel, if we had one if (spilledBufferSource != null) { spilledBufferSource.closeAndDelete(); } throw new EOFException(); } }
@Override protected MemorySegment nextSegment(MemorySegment current) throws IOException { // use the buffer to send the next request if (requestsRemaining > 0) { requestsRemaining--; spilledBufferSource.readBlock(current); } else { emptyBufferTarget.add(current); } // get the next buffer either from the return queue, or the full buffer source if (spilledBuffersRemaining > 0) { spilledBuffersRemaining--; try { return spilledBufferSource.getReturnQueue().take(); } catch (InterruptedException e) { throw new RuntimeException("Read End was interrupted while waiting for spilled buffer.", e); } } else if (fullBufferSource.size() > 0) { return fullBufferSource.removeFirst(); } else { clear(); // delete the channel, if we had one if (spilledBufferSource != null) { spilledBufferSource.closeAndDelete(); } throw new EOFException(); } }