private void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }
@Override public List<MemorySegment> getFullSegments() { synchronized (this.closeLock) { if (!this.isClosed() || this.requestsNotReturned.get() > 0) { throw new IllegalStateException("Full segments can only be obtained after the reader was properly closed."); } } return this.returnBuffers; }
private AsynchronousBulkBlockReader(FileIOChannel.ID channelID, RequestQueue<ReadRequest> requestQueue, List<MemorySegment> sourceSegments, int numBlocks, ArrayList<MemorySegment> target) throws IOException { super(channelID, requestQueue, new CollectingCallback(target), false); this.returnBuffers = target; // sanity check if (sourceSegments.size() < numBlocks) { throw new IllegalArgumentException("The list of source memory segments must contain at least" + " as many segments as the number of blocks to read."); } // send read requests for all blocks for (int i = 0; i < numBlocks; i++) { readBlock(sourceSegments.remove(sourceSegments.size() - 1)); } }
/** * Creates a block channel reader that reads all blocks from the given channel directly in one bulk. * The reader draws segments to read the blocks into from a supplied list, which must contain as many * segments as the channel has blocks. After the reader is done, the list with the full segments can be * obtained from the reader. * <p> * If a channel is not to be read in one bulk, but in multiple smaller batches, a * {@link BlockChannelReader} should be used. * * @param channelID The descriptor for the channel to write to. * @param targetSegments The list to take the segments from into which to read the data. * @param numBlocks The number of blocks in the channel to read. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BulkBlockChannelReader createBulkBlockChannelReader(FileIOChannel.ID channelID, List<MemorySegment> targetSegments, int numBlocks) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBulkBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, targetSegments, numBlocks, bufferedReadSize); }
private AsynchronousBulkBlockReader(FileIOChannel.ID channelID, RequestQueue<ReadRequest> requestQueue, List<MemorySegment> sourceSegments, int numBlocks, ArrayList<MemorySegment> target) throws IOException { super(channelID, requestQueue, new CollectingCallback(target), false); this.returnBuffers = target; // sanity check if (sourceSegments.size() < numBlocks) { throw new IllegalArgumentException("The list of source memory segments must contain at least" + " as many segments as the number of blocks to read."); } // send read requests for all blocks for (int i = 0; i < numBlocks; i++) { readBlock(sourceSegments.remove(sourceSegments.size() - 1)); } }
/** * Creates a block channel reader that reads all blocks from the given channel directly in one bulk. * The reader draws segments to read the blocks into from a supplied list, which must contain as many * segments as the channel has blocks. After the reader is done, the list with the full segments can be * obtained from the reader. * <p> * If a channel is not to be read in one bulk, but in multiple smaller batches, a * {@link BlockChannelReader} should be used. * * @param channelID The descriptor for the channel to write to. * @param targetSegments The list to take the segments from into which to read the data. * @param numBlocks The number of blocks in the channel to read. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BulkBlockChannelReader createBulkBlockChannelReader(FileIOChannel.ID channelID, List<MemorySegment> targetSegments, int numBlocks) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBulkBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, targetSegments, numBlocks); }
@Override public List<MemorySegment> getFullSegments() { synchronized (this.closeLock) { if (!this.isClosed() || this.requestsNotReturned.get() > 0) { throw new IllegalStateException("Full segments can only be obtained after the reader was properly closed."); } } return this.returnBuffers; }
private void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment, bufferSize)); }
private AsynchronousBulkBlockReader(FileIOChannel.ID channelID, RequestQueue<ReadRequest> requestQueue, List<MemorySegment> sourceSegments, int numBlocks, ArrayList<MemorySegment> target) throws IOException { super(channelID, requestQueue, new CollectingCallback(target), false); this.returnBuffers = target; // sanity check if (sourceSegments.size() < numBlocks) { throw new IllegalArgumentException("The list of source memory segments must contain at least" + " as many segments as the number of blocks to read."); } // send read requests for all blocks for (int i = 0; i < numBlocks; i++) { readBlock(sourceSegments.remove(sourceSegments.size() - 1)); } }
/** * Creates a block channel reader that reads all blocks from the given channel directly in one bulk. * The reader draws segments to read the blocks into from a supplied list, which must contain as many * segments as the channel has blocks. After the reader is done, the list with the full segments can be * obtained from the reader. * <p> * If a channel is not to be read in one bulk, but in multiple smaller batches, a * {@link BlockChannelReader} should be used. * * @param channelID The descriptor for the channel to write to. * @param targetSegments The list to take the segments from into which to read the data. * @param numBlocks The number of blocks in the channel to read. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BulkBlockChannelReader createBulkBlockChannelReader(FileIOChannel.ID channelID, List<MemorySegment> targetSegments, int numBlocks) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBulkBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, targetSegments, numBlocks); }
@Override public List<MemorySegment> getFullSegments() { synchronized (this.closeLock) { if (!this.isClosed() || this.requestsNotReturned.get() > 0) { throw new IllegalStateException("Full segments can only be obtained after the reader was properly closed."); } } return this.returnBuffers; }
private void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }
private AsynchronousBulkBlockReader(FileIOChannel.ID channelID, RequestQueue<ReadRequest> requestQueue, List<MemorySegment> sourceSegments, int numBlocks, ArrayList<MemorySegment> target, int bufferSize) throws IOException { super(channelID, requestQueue, new CollectingCallback(target), false); this.returnBuffers = target; this.bufferSize = bufferSize; // sanity check if (sourceSegments.size() < numBlocks) { throw new IllegalArgumentException("The list of source memory segments must contain at least" + " as many segments as the number of blocks to read."); } // send read requests for all blocks for (int i = 0; i < numBlocks; i++) { readBlock(sourceSegments.remove(sourceSegments.size() - 1)); } }
/** * Creates a block channel reader that reads all blocks from the given channel directly in one bulk. * The reader draws segments to read the blocks into from a supplied list, which must contain as many * segments as the channel has blocks. After the reader is done, the list with the full segments can be * obtained from the reader. * <p> * If a channel is not to be read in one bulk, but in multiple smaller batches, a * {@link BlockChannelReader} should be used. * * @param channelID The descriptor for the channel to write to. * @param targetSegments The list to take the segments from into which to read the data. * @param numBlocks The number of blocks in the channel to read. * @return A block channel reader that reads from the given channel. * @throws IOException Thrown, if the channel for the reader could not be opened. */ @Override public BulkBlockChannelReader createBulkBlockChannelReader(FileIOChannel.ID channelID, List<MemorySegment> targetSegments, int numBlocks) throws IOException { checkState(!isShutdown.get(), "I/O-Manger is shut down."); return new AsynchronousBulkBlockReader(channelID, this.readers[channelID.getThreadNum()].requestQueue, targetSegments, numBlocks); }
@Override public List<MemorySegment> getFullSegments() { synchronized (this.closeLock) { if (!this.isClosed() || this.requestsNotReturned.get() > 0) { throw new IllegalStateException("Full segments can only be obtained after the reader was properly closed."); } } return this.returnBuffers; }
private void readBlock(MemorySegment segment) throws IOException { addRequest(new SegmentReadRequest(this, segment)); }