/** * Constructs a new {@link PagedChannelRandomAccessSource} based on the specified FileChannel, with a specific buffer size * @param channel the channel to use as the backing store * @param totalBufferSize total buffer size * @param maxOpenBuffers open buffers * @throws java.io.IOException if the channel cannot be opened or mapped */ public PagedChannelRandomAccessSource(FileChannel channel, int totalBufferSize, int maxOpenBuffers) throws java.io.IOException { super(buildSources(channel, totalBufferSize/maxOpenBuffers)); this.channel = channel; this.bufferSize = totalBufferSize/maxOpenBuffers; this.mru = new MRU<IRandomAccessSource>(maxOpenBuffers); }
/** * {@inheritDoc} * For now, close the source that is no longer being used. In the future, we may implement an MRU that allows multiple pages to be opened at a time */ @Override protected void sourceReleased(IRandomAccessSource source) throws java.io.IOException { IRandomAccessSource old = mru.enqueue(source); if (old != null) old.close(); }
/** * Constructs a new {@link PagedChannelRandomAccessSource} based on the specified FileChannel, with a specific buffer size * @param channel the channel to use as the backing store * @param totalBufferSize total buffer size * @param maxOpenBuffers open buffers * @throws java.io.IOException if the channel cannot be opened or mapped */ public PagedChannelRandomAccessSource(FileChannel channel, int totalBufferSize, int maxOpenBuffers) throws java.io.IOException { super(buildSources(channel, totalBufferSize/maxOpenBuffers)); this.channel = channel; this.bufferSize = totalBufferSize/maxOpenBuffers; this.mru = new MRU<IRandomAccessSource>(maxOpenBuffers); }
/** * {@inheritDoc} * For now, close the source that is no longer being used. In the future, we may implement an MRU that allows multiple pages to be opened at a time */ @Override protected void sourceReleased(IRandomAccessSource source) throws java.io.IOException { IRandomAccessSource old = mru.enqueue(source); if (old != null) old.close(); }