com.faunos.skwish.sys.filters
Class ReadOnlyFilterSegment

java.lang.Object
  extended by com.faunos.skwish.Segment
      extended by com.faunos.skwish.sys.filters.FilterSegment
          extended by com.faunos.skwish.sys.filters.ReadOnlyFilterSegment
All Implemented Interfaces:
Range

public class ReadOnlyFilterSegment
extends FilterSegment

A read-only view of an underlying segment.

Author:
Babak Farhang
See Also:
On the read-only property

Field Summary
 
Fields inherited from class com.faunos.skwish.sys.filters.FilterSegment
inner
 
Fields inherited from class com.faunos.skwish.Segment
validator
 
Constructor Summary
ReadOnlyFilterSegment(Segment inner)
          Creates and returns a read-only view of the given inner instance.
 
Method Summary
 void delete(long id)
          Deletes the entry with the specified id.
 void delete(long id, int count)
          Deletes count entries starting at the entry with the specified id.
 void delete(long id, int count, boolean purge)
          Deletes count entries starting at the entry with the specified id.
 long insertEntry(ByteBuffer buffer)
          Inserts the given entry and returns the entry's ID.
 long insertEntry(ReadableByteChannel entry)
          Inserts the entry represented by the given channel.
 boolean isReadOnly()
          Determines whether this instance is read-only (unmodifiable).
 long killNext()
          Kills the next entry ID.
 long killNext(int count)
          Kills the next count entry IDs.
 
Methods inherited from class com.faunos.skwish.sys.filters.FilterSegment
getBaseId, getEntry, getEntryChannel, getEntryCount, getEntryPart, getEntrySize, getNextId
 
Methods inherited from class com.faunos.skwish.Segment
contains, getEntry, getEntrySize, getEntryStream, hi, isDeleted, isDeleted, lo, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadOnlyFilterSegment

public ReadOnlyFilterSegment(Segment inner)
Creates and returns a read-only view of the given inner instance.

Method Detail

isReadOnly

public final boolean isReadOnly()
Description copied from class: Segment
Determines whether this instance is read-only (unmodifiable).

Overrides:
isReadOnly in class FilterSegment
Returns:
true
See Also:
Write operations

delete

public final void delete(long id)
                  throws UnsupportedOperationException,
                         IOException
Description copied from class: Segment
Deletes the entry with the specified id. The entry is marked as deleted; the deleted contents will be purged whenever the segment is compacted or merged with another segment.

Overrides:
delete in class Segment
Parameters:
id - the ID of the entry to be deleted. Must be a valid ID in this segment [baseId, baseId + entryCount)
Throws:
UnsupportedOperationException
IOException

delete

public final void delete(long id,
                         int count)
                  throws UnsupportedOperationException,
                         IOException
Description copied from class: Segment
Deletes count entries starting at the entry with the specified id. The entries are marked as deleted; the deleted contents will be purged whenever the segment is compacted or merged with another segment.

Overrides:
delete in class Segment
Parameters:
id - the ID of the first entry to be deleted. Must be a valid ID in this segment [baseId, baseId + entryCount)
count - the number of entries to be deleted. Specifies a range of IDs to be deleted: [id, id + count). The range of IDs must be valid entries within this segment; o.w. an exception is raised.
Throws:
UnsupportedOperationException
IOException

delete

public final void delete(long id,
                         int count,
                         boolean purge)
                  throws UnsupportedOperationException,
                         IOException
Description copied from class: Segment
Deletes count entries starting at the entry with the specified id. The contents of the deleted entries may optionally be requested to be purged (overwritten) immediately; o.w. the deleted contents will be purged whenever the segment is compacted or merged with another segment.

Note that purging is not part of any transaction semantic; whether or not a purge immediately takes place on its being signaled is implementation-dependent.

Overrides:
delete in class FilterSegment
Parameters:
id - the ID of the first entry to be deleted. Must be a valid ID in this segment [baseId, baseId + entryCount)
count - the number of entries to be deleted. Specifies a range of IDs to be deleted: [id, id + count). The range of IDs must be valid entries within this segment; o.w. an exception is raised.
purge - if true, the contents of the deleted entries are signaled to be purged (overwritten) immediately; o.w. the contents will be deleted on the next time the segment is compacted.
Throws:
UnsupportedOperationException
IOException

insertEntry

public final long insertEntry(ByteBuffer buffer)
                       throws UnsupportedOperationException,
                              IOException
Description copied from class: Segment
Inserts the given entry and returns the entry's ID. The contents of the entry is understood to be the remaining contents in the given buffer.

Overrides:
insertEntry in class FilterSegment
Parameters:
buffer - they contents of the entry
Returns:
the ID assigned to the entry
Throws:
UnsupportedOperationException
IOException

insertEntry

public final long insertEntry(ReadableByteChannel entry)
                       throws UnsupportedOperationException,
                              IOException
Description copied from class: Segment
Inserts the entry represented by the given channel. The contents are of the entry is understood to be the entire remaining contents in the specified channel.

This is the most efficient method for inserting a large-size entry (even one that doesn't fit in memory).

Overrides:
insertEntry in class FilterSegment
Throws:
UnsupportedOperationException
IOException

killNext

public final long killNext()
                    throws UnsupportedOperationException,
                           IOException
Description copied from class: Segment
Kills the next entry ID. A killed entry is an entry that begins (and ends) life in the deleted state.

Overrides:
killNext in class Segment
Returns:
the value that getNextId() returns after this method has completed
Throws:
UnsupportedOperationException
IOException

killNext

public final long killNext(int count)
                    throws UnsupportedOperationException,
                           IOException
Description copied from class: Segment
Kills the next count entry IDs. A killed entry is an entry that begins (and ends) life in the deleted state.

Overrides:
killNext in class FilterSegment
Parameters:
count - the number of entries to kill (must be greater than 1)
Returns:
the value that getNextId() returns after this method has completed
Throws:
UnsupportedOperationException
IOException


SourceForge.net Logo