org.planx.xmlstore.koala.storage
Class Segment

java.lang.Object
  extended by org.planx.xmlstore.koala.storage.Segment

public class Segment
extends Object

A Segment is a collection of nodes which is stored consecutively on disk. A segment object only exists while the segment is in memory. When a segment is in memory, all its data is cached in a MemoryFileSystem.

Author:
Thomas Ambus

Constructor Summary
Segment(SegmentManager segmentManager, StorageConfiguration config)
          Create an empty Segment.
 
Method Summary
 void addIndirection(Locator oldLoc, Locator newLoc)
           
 long dataSize()
           
 void delete()
          Marks this Segment as deleted.
 boolean equals(Object o)
          Returns true if the argument is also a Segment and it has the same SourceId as this Segment or the argument is a SourceId which is equal to this segment's SourceId.
 NodeFileSystem<LocalLocator> fileSystem()
          Returns the in-memory NodeFileSystem associated with this segment.
 SourceId forwardId()
           
static SizeStreamer<Segment> getStreamer(SegmentManager segmentManager, StorageConfiguration config)
          Returns a streamer capable of writing and reading a segment including its meta data.
 int hashCode()
          Returns the hash code of this Segments SourceId.
 SourceId id()
          Returns the SourceId of this segment.
 MultiMap<Locator,SourceId> incomingSet()
          Returns the incoming set of this segment.
 Map<Locator,Locator> indirections()
           
 boolean isDeleted()
           
 boolean isEmpty()
           
 boolean isModified()
           
 boolean isReadOnly()
           
 void setDataSize(long dataSize)
           
 void setForwardId(SourceId forwardId)
           
 void setModified(boolean isModified)
           
 void setReadOnly(boolean isReadOnly)
           
 void setStateId(SourceId stateId)
           
 SourceId stateId()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Segment

public Segment(SegmentManager segmentManager,
               StorageConfiguration config)
        throws IOException
Create an empty Segment. The SegmentManager is provided to be able to load children in foreign segments.

Throws:
IOException
Method Detail

id

public SourceId id()
Returns the SourceId of this segment.


stateId

public SourceId stateId()

setStateId

public void setStateId(SourceId stateId)

forwardId

public SourceId forwardId()

setForwardId

public void setForwardId(SourceId forwardId)

isModified

public boolean isModified()
                   throws IOException
Throws:
IOException

setModified

public void setModified(boolean isModified)
                 throws IOException
Throws:
IOException

isReadOnly

public boolean isReadOnly()
                   throws IOException
Throws:
IOException

setReadOnly

public void setReadOnly(boolean isReadOnly)
                 throws IOException
Throws:
IOException

dataSize

public long dataSize()

setDataSize

public void setDataSize(long dataSize)

isEmpty

public boolean isEmpty()
                throws IOException
Throws:
IOException

fileSystem

public NodeFileSystem<LocalLocator> fileSystem()
                                        throws IOException
Returns the in-memory NodeFileSystem associated with this segment.

Throws:
IOException

incomingSet

public MultiMap<Locator,SourceId> incomingSet()
Returns the incoming set of this segment.


indirections

public Map<Locator,Locator> indirections()

addIndirection

public void addIndirection(Locator oldLoc,
                           Locator newLoc)
                    throws IOException
Throws:
IOException

equals

public boolean equals(Object o)
Returns true if the argument is also a Segment and it has the same SourceId as this Segment or the argument is a SourceId which is equal to this segment's SourceId.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code of this Segments SourceId.

Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

delete

public void delete()
Marks this Segment as deleted. Any further method calls are invalid. Note, that this does not delete it from disk.


isDeleted

public boolean isDeleted()

getStreamer

public static SizeStreamer<Segment> getStreamer(SegmentManager segmentManager,
                                                StorageConfiguration config)
Returns a streamer capable of writing and reading a segment including its meta data.



Copyright © 2004-2005 Plan-X. All Rights Reserved.