com.bigdata.btree
Class BigdataSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by com.bigdata.btree.BigdataSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, SortedSet<E>

public class BigdataSet<E>
extends AbstractSet<E>
implements SortedSet<E>

A SortedSet backed by a B+Tree.

Note: The BigdataMap has the same concurrency constraints as the BTree - it is single-threaded for writes and allows concurrent readers.

Note: The BigdataSet is actually flyweight wrapper around a BigdataMap whose keys and values are both formed from the values stored in this SortedSet.

Note: Both Set.equals(Object) and Set.hashCode() are VERY expensive, but that is how they are defined.

Version:
$Id: BigdataSet.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static String ERR_TOO_MANY
          Text of the error message used when there are more than Integer.MAX_VALUE entries.
 
Constructor Summary
BigdataSet(IIndex ndx)
           
 
Method Summary
 boolean add(E key)
           
 boolean addAll(Collection<? extends E> c)
           
 void clear()
           
 Comparator<? super E> comparator()
          There is no means available to specify a Comparator for the SortedSet.
 boolean contains(Object key)
           
 boolean containsAll(Collection<?> c)
           
 E first()
          Note: This is written using an ITupleIterator in order to decode the entry.
 SortedSet<E> headSet(E toKey)
           
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 E last()
          Note: This is written using an ITupleIterator in order to decode the entry.
 long rangeCount(boolean exactCount)
          The #of non-deleted entries in the map.
 boolean remove(Object key)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
          The #of index entries.
 SortedSet<E> subSet(E fromKey, E toKey)
           
 SortedSet<E> tailSet(E fromKey)
           
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode, toArray, toArray
 

Field Detail

ERR_TOO_MANY

protected static final transient String ERR_TOO_MANY
Text of the error message used when there are more than Integer.MAX_VALUE entries.

See Also:
Constant Field Values
Constructor Detail

BigdataSet

public BigdataSet(IIndex ndx)
Method Detail

add

public boolean add(E key)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class AbstractCollection<E>

remove

public boolean remove(Object key)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Set<E>
Overrides:
remove in class AbstractCollection<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface Set<E>
Overrides:
clear in class AbstractCollection<E>

contains

public boolean contains(Object key)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface Set<E>
Overrides:
contains in class AbstractCollection<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface Set<E>
Overrides:
isEmpty in class AbstractCollection<E>

size

public int size()
The #of index entries. When there are more than Integer.MAX_VALUE entries then this method will report Integer.MAX_VALUE entries. If the backing index supports delete markers then an index scan will be performed in order to count the #of non-deleted index entries.

Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<E>

rangeCount

public long rangeCount(boolean exactCount)
The #of non-deleted entries in the map.

Parameters:
exactCount - When true the result will be an exact count, which will require a full key-range scan if delete markers are enabled for the index.
Returns:
The #of entries in the map. When exactCount is false and delete markers are being used, then this will be an upper bound.
See Also:
IRangeQuery.rangeCount(byte[], byte[])

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Set<E>
Specified by:
iterator in class AbstractCollection<E>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>
Overrides:
addAll in class AbstractCollection<E>
TODO:
override with implementation using chunked ordered writes.

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>
Specified by:
containsAll in interface Set<E>
Overrides:
containsAll in class AbstractCollection<E>
TODO:
override with implementation using chunked ordered reads.

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface Set<E>
Overrides:
removeAll in class AbstractSet<E>
TODO:
override with implementation using chunked ordered writes.

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface Set<E>
Overrides:
retainAll in class AbstractCollection<E>
TODO:
override with implementation using chunked ordered writes.

comparator

public final Comparator<? super E> comparator()
There is no means available to specify a Comparator for the SortedSet. Application keys are first converted into unsigned byte[] keys using the configured ITupleSerializer for the backing B+Tree. The index order is directly determined by those keys.

Specified by:
comparator in interface SortedSet<E>
Returns:
Always returns null.

first

public E first()
Note: This is written using an ITupleIterator in order to decode the entry.

Specified by:
first in interface SortedSet<E>

last

public E last()
Note: This is written using an ITupleIterator in order to decode the entry.

Specified by:
last in interface SortedSet<E>

headSet

public SortedSet<E> headSet(E toKey)
Specified by:
headSet in interface SortedSet<E>

subSet

public SortedSet<E> subSet(E fromKey,
                           E toKey)
Specified by:
subSet in interface SortedSet<E>

tailSet

public SortedSet<E> tailSet(E fromKey)
Specified by:
tailSet in interface SortedSet<E>


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.