Class BufferOverInputStream.ByteArrayChannel
- java.lang.Object
-
- org.aksw.commons.io.hadoop.binseach.bz2.ReadableByteChannelBase
-
- org.aksw.commons.io.hadoop.binseach.bz2.BufferOverInputStream.ByteArrayChannel
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,SeekableByteChannel,WritableByteChannel,org.aksw.commons.io.seekable.api.Seekable
- Enclosing class:
- BufferOverInputStream
public class BufferOverInputStream.ByteArrayChannel extends ReadableByteChannelBase implements SeekableByteChannel, org.aksw.commons.io.seekable.api.Seekable
-
-
Field Summary
Fields Modifier and Type Field Description protected BufferOverInputStream.BucketPointerpointerprotected longpos-
Fields inherited from class org.aksw.commons.io.hadoop.binseach.bz2.ReadableByteChannelBase
isOpen, maxReadSize
-
-
Constructor Summary
Constructors Constructor Description ByteArrayChannel(long pos, BufferOverInputStream.BucketPointer pointer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcheckNext(int len, boolean changePos)intcheckPrev(int len, boolean changePos)The method assumes that the current position is in the valid rangeorg.aksw.commons.io.seekable.api.Seekableclone()byteget()longgetPos()booleanisPosAfterEnd()booleanisPosBeforeStart()longloadAll()Loads all data into the buffer and returns the total sizelongposition()BufferOverInputStream.ByteArrayChannelposition(long pos)Setting a position outside of the size of the entity is valid will will cause a read to immediately return an EOF SeeReadableByteChannelvoidposToEnd()Set the position to the end of the stream immediately loads all data.voidposToStart()intreadActual(ByteBuffer dst)StringreadString(int len)voidsetPos(long pos)longsize()First checks whether there is at least one more byte available and afterwards returns the currently known sizeSeekableByteChanneltruncate(long size)intwrite(ByteBuffer src)-
Methods inherited from class org.aksw.commons.io.hadoop.binseach.bz2.ReadableByteChannelBase
close, isOpen, isUnderlyingEntityKnownToBeClosed, read
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.aksw.commons.io.seekable.api.Seekable
binarySearch, cloneObject, close, compareToPrefix, deltaPos, get, nextPos, peekNextBytes, posToNext, posToNext, posToPrev, prevPos, read
-
Methods inherited from interface java.nio.channels.SeekableByteChannel
read
-
-
-
-
Field Detail
-
pos
protected long pos
-
pointer
protected BufferOverInputStream.BucketPointer pointer
-
-
Constructor Detail
-
ByteArrayChannel
public ByteArrayChannel(long pos, BufferOverInputStream.BucketPointer pointer)
-
-
Method Detail
-
position
public BufferOverInputStream.ByteArrayChannel position(long pos)
Setting a position outside of the size of the entity is valid will will cause a read to immediately return an EOF SeeReadableByteChannel- Specified by:
positionin interfaceSeekableByteChannel- Parameters:
pos-- Returns:
-
position
public long position()
- Specified by:
positionin interfaceSeekableByteChannel
-
readActual
public int readActual(ByteBuffer dst) throws IOException
- Specified by:
readActualin classReadableByteChannelBase- Throws:
IOException
-
write
public int write(ByteBuffer src) throws IOException
- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
size
public long size() throws IOExceptionFirst checks whether there is at least one more byte available and afterwards returns the currently known size- Specified by:
sizein interfaceorg.aksw.commons.io.seekable.api.Seekable- Specified by:
sizein interfaceSeekableByteChannel- Throws:
IOException
-
loadAll
public long loadAll() throws IOExceptionLoads all data into the buffer and returns the total size- Throws:
IOException
-
truncate
public SeekableByteChannel truncate(long size) throws IOException
- Specified by:
truncatein interfaceSeekableByteChannel- Throws:
IOException
-
clone
public org.aksw.commons.io.seekable.api.Seekable clone()
-
getPos
public long getPos() throws IOException- Specified by:
getPosin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
setPos
public void setPos(long pos) throws IOException- Specified by:
setPosin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
posToStart
public void posToStart() throws IOException- Specified by:
posToStartin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
posToEnd
public void posToEnd() throws IOExceptionSet the position to the end of the stream immediately loads all data.- Specified by:
posToEndin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
isPosBeforeStart
public boolean isPosBeforeStart() throws IOException- Specified by:
isPosBeforeStartin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
isPosAfterEnd
public boolean isPosAfterEnd() throws IOException- Specified by:
isPosAfterEndin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
readString
public String readString(int len) throws IOException
- Specified by:
readStringin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
checkNext
public int checkNext(int len, boolean changePos) throws IOException- Specified by:
checkNextin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
get
public byte get() throws IOException- Specified by:
getin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
checkPrev
public int checkPrev(int len, boolean changePos) throws IOExceptionThe method assumes that the current position is in the valid range- Specified by:
checkPrevin interfaceorg.aksw.commons.io.seekable.api.Seekable- Throws:
IOException
-
-