@Override public void close() throws IOException { if (stream != null) { //stream.close(); stream = null; buffer = null; } super.close(); }
@Override public void setByteOrder(ByteOrder byteOrder) { super.setByteOrder(byteOrder); integralCache.order(byteOrder); }
@Override protected void finalize() throws Throwable { super.finalize(); }
@Override public void seek(long pos) throws IOException { is.seek(pos); super.seek(pos); }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
public long length() { long len; if(mapper instanceof StreamSegmentMapperImpl) { len = ((StreamSegmentMapperImpl)mapper).length(); } else if(mapper instanceof SectorStreamSegmentMapper) { len = ((SectorStreamSegmentMapper)mapper).length(); } else if(mapper != null) { long pos = len = 0L; StreamSegment seg = mapper.getStreamSegment(pos, Integer.MAX_VALUE); while((len = seg.getSegmentLength()) > 0) { pos += len; seg.setSegmentLength(0); mapper.getStreamSegment(pos, Integer.MAX_VALUE, seg); } len = pos; } else { len = super.length(); } return len; } }
/** * Invokes the superclass method and sets the position within the * memory mapped buffer. A new region is mapped if necessary. The * position of the source <code>FileChannel</code> is not changed, i.e., * {@link java.nio.channels.FileChannel#position(long)} is not invoked. */ public void seek(long pos) throws IOException { super.seek(pos); if(pos >= mappedPos && pos < mappedUpperBound) { // Seeking to location within mapped buffer: set buffer position. mappedBuffer.position((int)(pos - mappedPos)); } else { // Seeking to location outside mapped buffer: get a new mapped // buffer at current position with maximal size. int len = (int)Math.min(channel.size() - pos, Integer.MAX_VALUE); mappedBuffer = getMappedBuffer(len); } }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
public long length() { long len; if(mapper instanceof StreamSegmentMapperImpl) { len = ((StreamSegmentMapperImpl)mapper).length(); } else if(mapper instanceof SectorStreamSegmentMapper) { len = ((SectorStreamSegmentMapper)mapper).length(); } else if(mapper != null) { long pos = len = 0L; StreamSegment seg = mapper.getStreamSegment(pos, Integer.MAX_VALUE); while((len = seg.getSegmentLength()) > 0) { pos += len; seg.setSegmentLength(0); mapper.getStreamSegment(pos, Integer.MAX_VALUE, seg); } len = pos; } else { len = super.length(); } return len; } }
/** * Invokes the superclass method and sets the internal reference * to the source <code>FileChannel</code> to <code>null</code>. * The source <code>FileChannel</code> is not closed. * * @exception IOException if an error occurs. */ public void close() throws IOException { super.close(); channel = null; }
/** * Invokes the superclass method and sets the position within the * memory mapped buffer. A new region is mapped if necessary. The * position of the source <code>FileChannel</code> is not changed, i.e., * {@link java.nio.channels.FileChannel#position(long)} is not invoked. */ public void seek(long pos) throws IOException { super.seek(pos); if(pos >= mappedPos && pos < mappedUpperBound) { // Seeking to location within mapped buffer: set buffer position. mappedBuffer.position((int)(pos - mappedPos)); } else { // Seeking to location outside mapped buffer: get a new mapped // buffer at current position with maximal size. int len = (int)Math.min(channel.size() - pos, Integer.MAX_VALUE); mappedBuffer = getMappedBuffer(len); } }
public void setByteOrder(ByteOrder networkByteOrder) { super.setByteOrder(networkByteOrder); mappedBuffer.order(networkByteOrder); } }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if (streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
@Override protected void finalize() throws Throwable { super.finalize(); is = null; } }
public long length() { long len; if(mapper instanceof StreamSegmentMapperImpl) { len = ((StreamSegmentMapperImpl)mapper).length(); } else if(mapper instanceof SectorStreamSegmentMapper) { len = ((SectorStreamSegmentMapper)mapper).length(); } else if(mapper != null) { long pos = len = 0L; StreamSegment seg = mapper.getStreamSegment(pos, Integer.MAX_VALUE); while((len = seg.getSegmentLength()) > 0) { pos += len; seg.setSegmentLength(0); mapper.getStreamSegment(pos, Integer.MAX_VALUE, seg); } len = pos; } else { len = super.length(); } return len; } }
@Override public void close() throws IOException { if (stream != null) { //stream.close(); stream = null; buffer = null; } super.close(); }
/** * Invokes the superclass method and sets the position within the * memory mapped buffer. A new region is mapped if necessary. The * position of the source <code>FileChannel</code> is not changed, i.e., * {@link java.nio.channels.FileChannel#position(long)} is not invoked. */ public void seek(long pos) throws IOException { super.seek(pos); if(pos >= mappedPos && pos < mappedUpperBound) { // Seeking to location within mapped buffer: set buffer position. mappedBuffer.position((int)(pos - mappedPos)); } else { // Seeking to location outside mapped buffer: get a new mapped // buffer at current position with maximal size. int len = (int)Math.min(channel.size() - pos, Integer.MAX_VALUE); mappedBuffer = getMappedBuffer(len); } }
@Override public void setByteOrder(ByteOrder networkByteOrder) { super.setByteOrder(networkByteOrder); mappedBuffer.order(networkByteOrder); }
/** * Returns a <code>MappedByteBuffer</code> which memory maps * at least from the channel position corresponding to the * current stream position to <code>len</code> bytes beyond. * A new buffer is created only if necessary. * * @param len The number of bytes required beyond the current stream * position. */ private MappedByteBuffer getMappedBuffer(int len) throws IOException { // If request is outside mapped region, map a new region. if(streamPos < mappedPos || streamPos + len >= mappedUpperBound) { // Set the map position. mappedPos = streamPos; // Determine the map size. long mappedSize = Math.min(channel.size() - mappedPos, Integer.MAX_VALUE); // Set the mapped upper bound. mappedUpperBound = mappedPos + mappedSize; // Map the file. mappedBuffer = channel.map(FileChannel.MapMode.READ_ONLY, mappedPos, mappedSize); mappedBuffer.order(super.getByteOrder()); } return mappedBuffer; }
@Override protected void finalize() throws Throwable { super.finalize(); }