Package com.emc.mongoose.base.item
Class DataItemImpl
- java.lang.Object
-
- com.emc.mongoose.base.item.ItemImpl
-
- com.emc.mongoose.base.item.DataItemImpl
-
- All Implemented Interfaces:
DataItem,Item,java.io.Closeable,java.io.Externalizable,java.io.Serializable,java.lang.AutoCloseable,java.nio.channels.ByteChannel,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel,java.nio.channels.SeekableByteChannel,java.nio.channels.WritableByteChannel
public class DataItemImpl extends ItemImpl implements DataItem
Created by kurila on 09.05.14. A data item which may produce uniformly distributed non-compressible content. Uses UniformDataSource as a ring buffer. Not thread safe. Note: theReadableByteChannel.read(ByteBuffer)method implementation will not return 0 or -1 (endless)- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DataItemImpl()DataItemImpl(long offset, long size)DataItemImpl(long offset, long size, int layerNum)DataItemImpl(DataItemImpl baseDataItem, long internalOffset, long size, boolean nextLayer)DataItemImpl(java.lang.String value)DataItemImpl(java.lang.String name, long offset, long size)DataItemImpl(java.lang.String name, long offset, long size, int layerNum)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcommitUpdatedRanges(java.util.BitSet[] updatingRangesMaskPair)DataInputdataInput()voiddataInput(DataInput dataInput)booleanequals(java.lang.Object o)inthashCode()booleanisOpen()booleanisRangeUpdated(int rangeIdx)booleanisUpdated()intlayer()voidlayer(int layerNum)longoffset()voidoffset(long offset)longposition()DataItemImplposition(long position)longrangeSize(int i)intread(java.nio.ByteBuffer dst)voidreadExternal(java.io.ObjectInput in)voidreset()longsize()voidsize(long size)DataItemImplslice(long from, long partSize)java.lang.StringtoString()java.lang.StringtoString(java.lang.String itemPath)DataItemImpltruncate(long size)intupdatedRangesCount()voidverify(java.nio.ByteBuffer inBuff)intwrite(java.nio.ByteBuffer src)voidwriteExternal(java.io.ObjectOutput out)<A> voidwriteToAsyncChannel(AsyncChannel dstChan, long dstPos, long maxCount, A attach, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)Warning: the data item's position should be updated by the handlerlongwriteToFileChannel(java.nio.channels.FileChannel chanDst, long maxCount)longwriteToSocketChannel(java.nio.channels.WritableByteChannel chanDst, long maxCount)
-
-
-
Constructor Detail
-
DataItemImpl
public DataItemImpl()
-
DataItemImpl
public DataItemImpl(java.lang.String value) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
DataItemImpl
public DataItemImpl(long offset, long size)
-
DataItemImpl
public DataItemImpl(java.lang.String name, long offset, long size)
-
DataItemImpl
public DataItemImpl(long offset, long size, int layerNum)
-
DataItemImpl
public DataItemImpl(java.lang.String name, long offset, long size, int layerNum)
-
DataItemImpl
public DataItemImpl(DataItemImpl baseDataItem, long internalOffset, long size, boolean nextLayer)
-
-
Method Detail
-
toString
public java.lang.String toString(java.lang.String itemPath)
-
dataInput
public final void dataInput(DataInput dataInput)
-
reset
public void reset()
-
slice
public DataItemImpl slice(long from, long partSize)
-
position
public long position()
-
position
public final DataItemImpl position(long position)
-
size
public long size()
- Specified by:
sizein interfacejava.nio.channels.SeekableByteChannel
-
truncate
public DataItemImpl truncate(long size)
- Specified by:
truncatein interfacejava.nio.channels.SeekableByteChannel
-
commitUpdatedRanges
public final void commitUpdatedRanges(java.util.BitSet[] updatingRangesMaskPair)
- Specified by:
commitUpdatedRangesin interfaceDataItem
-
isRangeUpdated
public final boolean isRangeUpdated(int rangeIdx)
- Specified by:
isRangeUpdatedin interfaceDataItem
-
updatedRangesCount
public final int updatedRangesCount()
- Specified by:
updatedRangesCountin interfaceDataItem
-
close
public final void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable
-
isOpen
public final boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
read
public final int read(java.nio.ByteBuffer dst)
- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Specified by:
readin interfacejava.nio.channels.SeekableByteChannel
-
write
public final int write(java.nio.ByteBuffer src) throws DataCorruptionException, DataSizeException- Specified by:
writein interfacejava.nio.channels.SeekableByteChannel- Specified by:
writein interfacejava.nio.channels.WritableByteChannel- Throws:
DataCorruptionExceptionDataSizeException
-
writeToSocketChannel
public final long writeToSocketChannel(java.nio.channels.WritableByteChannel chanDst, long maxCount) throws java.io.IOException- Specified by:
writeToSocketChannelin interfaceDataItem- Returns:
- The number of bytes written, possibly zero
- Throws:
java.nio.channels.ClosedChannelException- If this channel is closedjava.nio.channels.AsynchronousCloseException- If another thread closes this channel while the write operation is in progressjava.nio.channels.ClosedByInterruptException- If another thread interrupts the current thread while the write operation is in progress, thereby closing the channel and setting the current thread's interrupt statusjava.io.IOException- If some other I/O error occurs
-
writeToFileChannel
public final long writeToFileChannel(java.nio.channels.FileChannel chanDst, long maxCount) throws java.io.IOException- Specified by:
writeToFileChannelin interfaceDataItem- Throws:
java.io.IOException
-
writeToAsyncChannel
public final <A> void writeToAsyncChannel(AsyncChannel dstChan, long dstPos, long maxCount, A attach, java.nio.channels.CompletionHandler<java.lang.Integer,? super A> handler)
Description copied from interface:DataItemWarning: the data item's position should be updated by the handler- Specified by:
writeToAsyncChannelin interfaceDataItemhandler- note that the handler should invoke {@link DataItem#position(long))} to set the new position for this
-
verify
public final void verify(java.nio.ByteBuffer inBuff) throws DataCorruptionException- Specified by:
verifyin interfaceDataItem- Throws:
DataCorruptionException
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classItemImpl- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classItemImpl- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-