com.faunos.skwish.sys.filters
Class DeleteSet

java.lang.Object
  extended by com.faunos.skwish.sys.filters.DeleteSet
Direct Known Subclasses:
FileBackedDeleteSet

public class DeleteSet
extends Object

A set of deleted IDs that are used to mask entries in external segments as deleted. The base implementation maintains the set in memory with no backing storage.

On IOExceptions and method signatures

Had to drop these in because a subclass will need'em in its signature, if it's to write to storage.

Author:
Babak Farhang

Field Summary
protected  Set<Long> deletedIds
           
protected static Validator<DeleteSetException> validator
           
 
Constructor Summary
DeleteSet(DeleteSet copy)
          Copy constructor.
DeleteSet(long minId, long maxId)
          Creates an instance with the specified ID range.
 
Method Summary
static DeleteSet combine(DeleteSet a, DeleteSet b)
          Creates and returns a new combined version of the two given instances.
 boolean delete(long id)
          Adds the given id to the delete-set.
 int getCount()
          Returns the number of (unique) entry IDs that are marked as deleted by this instance.
 Set<Long> getDeletedIds()
          Returns a read-only view of the set of deleted IDs this instance manages.
 long getMaxId()
          Returns the maximum ID (exclusive) that can be marked as deleted by this instance.
 long getMinId()
          Returns the minimum ID that can be marked as deleted by this instance.
 boolean include(DeleteSet other)
          Adds the set of deleted IDs of the other instance to this instance's set.
protected  Set<Long> initSet(Set<Long> initValues)
           
 boolean inRange(long id)
          Determines whether the specified id is within the range of this instance.
 boolean isDeleted(long id)
          Determines whether the given id is in this delete-set.
 boolean isIncludeSupported()
          Determines whether the instance supports the include method.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

validator

protected static final Validator<DeleteSetException> validator

deletedIds

protected final Set<Long> deletedIds
Constructor Detail

DeleteSet

public DeleteSet(long minId,
                 long maxId)
Creates an instance with the specified ID range.

See Also:
getMinId(), getMaxId()

DeleteSet

public DeleteSet(DeleteSet copy)
Copy constructor. The new instance's state is evolves independently of that of the copy.

Parameters:
copy - the instance to be copied
Method Detail

initSet

protected Set<Long> initSet(Set<Long> initValues)

delete

public boolean delete(long id)
               throws IOException
Adds the given id to the delete-set.

Parameters:
id - the ID to be deleted, which lie in this delete-set's range
Returns:
true, if the specified id wasn't already deleted; false, o.w.
Throws:
IOException

isDeleted

public boolean isDeleted(long id)
                  throws IOException
Determines whether the given id is in this delete-set. There is no invalid argument for this method.

Returns:
true, if deleted; false, o.w.
Throws:
IOException

getCount

public int getCount()
Returns the number of (unique) entry IDs that are marked as deleted by this instance.


getDeletedIds

public Set<Long> getDeletedIds()
                        throws IOException
Returns a read-only view of the set of deleted IDs this instance manages.

Throws:
IOException

getMinId

public final long getMinId()
Returns the minimum ID that can be marked as deleted by this instance. Immutable property.


getMaxId

public final long getMaxId()
Returns the maximum ID (exclusive) that can be marked as deleted by this instance. Immutable property.


inRange

public final boolean inRange(long id)
Determines whether the specified id is within the range of this instance. (An ID is in range if it's ≥ minId and < maxId.)


include

public boolean include(DeleteSet other)
                throws IOException,
                       UnsupportedOperationException
Adds the set of deleted IDs of the other instance to this instance's set. The range of the other instance must be contained within the range of this instance.

Throws:
UnsupportedOperationException - if this subclass does not support it
IOException

isIncludeSupported

public boolean isIncludeSupported()
Determines whether the instance supports the include method.

Returns:
the base implementation returns true

combine

public static DeleteSet combine(DeleteSet a,
                                DeleteSet b)
                         throws IOException
Creates and returns a new combined version of the two given instances. The combined instance is a union of the two instances's deleted IDs and ranges.

The input instances are not modified.

Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object


SourceForge.net Logo