com.faunos.skwish.sys.filters
Class SubSegment

java.lang.Object
  extended by com.faunos.skwish.Segment
      extended by com.faunos.skwish.sys.filters.FilterSegment
          extended by com.faunos.skwish.sys.filters.AppendProtectedFilterSegment
              extended by com.faunos.skwish.sys.filters.SubSegment
All Implemented Interfaces:
Range
Direct Known Subclasses:
LiveSegManager.FixedSegment

public class SubSegment
extends AppendProtectedFilterSegment

A fixed-count view of an underlying segment. The entry count of this view remains frozen, even as entries are inserted in the underlying segment.

Author:
Babak Farhang

Field Summary
 
Fields inherited from class com.faunos.skwish.sys.filters.FilterSegment
inner
 
Fields inherited from class com.faunos.skwish.Segment
validator
 
Constructor Summary
SubSegment(Segment inner)
          Creates an instance whose entry count is frozen at the current value of the underlying instance.
SubSegment(Segment inner, long size)
           
 
Method Summary
 void getEntry(long id, ByteBuffer out, ByteBuffer workBuffer)
          Returns the contents of the entry with the specified id.
 FileChannel getEntryChannel(long id)
          Returns the contents of the entry with the given id as a FileChannel, or null, if deleted.
 long getEntryCount()
          Returns the number of entries in this instance.
 long getEntrySize(long id, ByteBuffer workBuffer)
          Returns the size of the entry with the specified id.
 long getNextId()
          Returns the ID the entry will get on the next insertion.
 
Methods inherited from class com.faunos.skwish.sys.filters.AppendProtectedFilterSegment
insertEntry, insertEntry, killNext
 
Methods inherited from class com.faunos.skwish.sys.filters.FilterSegment
delete, getBaseId, getEntryPart, isReadOnly
 
Methods inherited from class com.faunos.skwish.Segment
contains, delete, delete, getEntry, getEntrySize, getEntryStream, hi, isDeleted, isDeleted, killNext, lo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubSegment

public SubSegment(Segment inner)
Creates an instance whose entry count is frozen at the current value of the underlying instance.

Parameters:
inner - the underlying segment

SubSegment

public SubSegment(Segment inner,
                  long size)
Method Detail

getEntry

public final void getEntry(long id,
                           ByteBuffer out,
                           ByteBuffer workBuffer)
                    throws IOException
Description copied from class: Segment
Returns the contents of the entry with the specified id. If the entry is deleted, the method returns without modifying the out buffer.

Overrides:
getEntry in class FilterSegment
out - the buffer into which the contents are written. Its remaining bytes must be large enough; o.w., an exception is raised.
workBuffer - a work buffer used internally to read offsets. The minimum capacity of this work buffer must be 16
Throws:
IOException

getEntryChannel

public final FileChannel getEntryChannel(long id)
                                  throws IOException
Description copied from class: Segment
Returns the contents of the entry with the given id as a FileChannel, or null, if deleted. The returned channel is positioned at zero and is read-only.

Overrides:
getEntryChannel in class FilterSegment
Throws:
IOException

getEntryCount

public final long getEntryCount()
Description copied from class: Segment
Returns the number of entries in this instance.

Overrides:
getEntryCount in class FilterSegment

getEntrySize

public final long getEntrySize(long id,
                               ByteBuffer workBuffer)
                        throws IOException
Description copied from class: Segment
Returns the size of the entry with the specified id. A work buffer with a minimum size of 16 must be passed in.

Overrides:
getEntrySize in class FilterSegment
Returns:
the size of the entry if present; -1, if deleted.
Throws:
IOException

getNextId

public final long getNextId()
Description copied from class: Segment
Returns the ID the entry will get on the next insertion.

Overrides:
getNextId in class FilterSegment
See Also:
ID invariants


SourceForge.net Logo