Package org.deckfour.xes.nikefs2
Class NikeFS2LazyRandomAccessStorageImpl
- java.lang.Object
-
- org.deckfour.xes.nikefs2.NikeFS2RandomAccessStorageImpl
-
- org.deckfour.xes.nikefs2.NikeFS2LazyRandomAccessStorageImpl
-
- All Implemented Interfaces:
java.io.DataInput,java.io.DataOutput,NikeFS2RandomAccessStorage
public class NikeFS2LazyRandomAccessStorageImpl extends NikeFS2RandomAccessStorageImpl
Lazy implementation of the random access storage in NikeFS2: Blocks are copied as late as possible (soft copies), while retaining soft links otherwise.- Author:
- Christian W. Guenther (christian@deckfour.org)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.deckfour.xes.nikefs2.NikeFS2RandomAccessStorageImpl
NikeFS2RandomAccessStorageImpl.FS2BlockInputStream, NikeFS2RandomAccessStorageImpl.FS2BlockOutputStream, NikeFS2RandomAccessStorageImpl.FS2DataInputStream, NikeFS2RandomAccessStorageImpl.FS2DataOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanisSoftCopyWhether this instance is still a soft copy (i.e., actually empty).protected NikeFS2LazyRandomAccessStorageImplparentParent storage, containing the original data.protected java.util.ArrayList<NikeFS2LazyRandomAccessStorageImpl>softCopiesChild storages, which are soft copies of this instance.-
Fields inherited from class org.deckfour.xes.nikefs2.NikeFS2RandomAccessStorageImpl
blocks, dataInputStream, dataOutputStream, pointer, size, vfs
-
-
Constructor Summary
Constructors Constructor Description NikeFS2LazyRandomAccessStorageImpl(NikeFS2LazyRandomAccessStorageImpl template)Creates a new instance.NikeFS2LazyRandomAccessStorageImpl(NikeFS2VirtualFileSystem virtualFileSystem)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalertSoftCopies()This method alerts all child soft copies of this storage to consolidate; called prior to modification of this instance.voidclose()Closes the data storage container.voidconsolidateSoftCopy()Consolidates this soft copy prior to modification.NikeFS2RandomAccessStoragecopy()Creates a clone, or copy, of this storage, having the exact same contents and the file pointer reset to zero.voidderegisterSoftCopy(NikeFS2LazyRandomAccessStorageImpl copycat)This method is used by child copies to deregister with their parent.protected voidfinalize()voidregisterSoftCopy(NikeFS2LazyRandomAccessStorageImpl copycat)This method is used by child copies to register with their parent.voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwriteBoolean(boolean v)voidwriteByte(int b)voidwriteBytes(java.lang.String str)voidwriteChar(int c)voidwriteChars(java.lang.String str)voidwriteDouble(double d)voidwriteFloat(float f)voidwriteInt(int i)voidwriteLong(long l)voidwriteShort(int s)voidwriteUTF(java.lang.String str)-
Methods inherited from class org.deckfour.xes.nikefs2.NikeFS2RandomAccessStorageImpl
adjustSize, getFilePointer, length, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, skipBytes, translateToBlockNumber, translateToBlockOffset
-
-
-
-
Field Detail
-
parent
protected NikeFS2LazyRandomAccessStorageImpl parent
Parent storage, containing the original data.
-
isSoftCopy
protected boolean isSoftCopy
Whether this instance is still a soft copy (i.e., actually empty).
-
softCopies
protected java.util.ArrayList<NikeFS2LazyRandomAccessStorageImpl> softCopies
Child storages, which are soft copies of this instance.
-
-
Constructor Detail
-
NikeFS2LazyRandomAccessStorageImpl
public NikeFS2LazyRandomAccessStorageImpl(NikeFS2VirtualFileSystem virtualFileSystem)
Creates a new instance.- Parameters:
virtualFileSystem- Virtual file system to store data to.
-
NikeFS2LazyRandomAccessStorageImpl
public NikeFS2LazyRandomAccessStorageImpl(NikeFS2LazyRandomAccessStorageImpl template)
Creates a new instance.- Parameters:
template- Storage of which this instance is a soft copy.
-
-
Method Detail
-
registerSoftCopy
public void registerSoftCopy(NikeFS2LazyRandomAccessStorageImpl copycat)
This method is used by child copies to register with their parent.- Parameters:
copycat- The child soft copy to register.
-
deregisterSoftCopy
public void deregisterSoftCopy(NikeFS2LazyRandomAccessStorageImpl copycat)
This method is used by child copies to deregister with their parent.- Parameters:
copycat- The child soft copy to deregister.
-
alertSoftCopies
public void alertSoftCopies() throws java.io.IOExceptionThis method alerts all child soft copies of this storage to consolidate; called prior to modification of this instance. The child soft copies so alerted will detach from this instance consequently.- Throws:
java.io.IOException
-
consolidateSoftCopy
public void consolidateSoftCopy() throws java.io.IOExceptionConsolidates this soft copy prior to modification. This will detach this instance from its parent, creating a true copy of its current data.- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:NikeFS2RandomAccessStorageCloses the data storage container. After this method has been invoked, no further access to the represented instance is allowed.- Specified by:
closein interfaceNikeFS2RandomAccessStorage- Overrides:
closein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
copy
public NikeFS2RandomAccessStorage copy() throws java.io.IOException
Description copied from interface:NikeFS2RandomAccessStorageCreates a clone, or copy, of this storage, having the exact same contents and the file pointer reset to zero.- Specified by:
copyin interfaceNikeFS2RandomAccessStorage- Overrides:
copyin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean v) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Overrides:
writeBooleanin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeByte
public void writeByte(int b) throws java.io.IOException- Specified by:
writeBytein interfacejava.io.DataOutput- Overrides:
writeBytein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String str) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Overrides:
writeBytesin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeChar
public void writeChar(int c) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Overrides:
writeCharin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String str) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Overrides:
writeCharsin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double d) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Overrides:
writeDoublein classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float f) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Overrides:
writeFloatin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeInt
public void writeInt(int i) throws java.io.IOException- Specified by:
writeIntin interfacejava.io.DataOutput- Overrides:
writeIntin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeLong
public void writeLong(long l) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Overrides:
writeLongin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeShort
public void writeShort(int s) throws java.io.IOException- Specified by:
writeShortin interfacejava.io.DataOutput- Overrides:
writeShortin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String str) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Overrides:
writeUTFin classNikeFS2RandomAccessStorageImpl- Throws:
java.io.IOException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-