Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ensembl.driver
Class FeatureIterator

    java.lang.Object
      org.ensembl.driver.FeatureIterator

All Implemented Interfaces:
  java.util.Iterator

public class FeatureIterator
extends java.lang.Object
implements java.util.Iterator

Provides an iterator over features from a FeatureAdaptor.

The features are retrieved in batches and buffered. This allows for a compromise between runtime speed and memory usage efficiency. Increasing the buffer size potentially reduces the number of database calls required and potentially increases the memory requirement.

Example usage: Retrieve all genes in the specified location using batches of upto 1mb.

`Iterator iter = new FeatureIterator(geneAdaptor,1000000,loc);`

This class acts as a proxy for InternalIDFeatureIterator and LocationFeatureIterator and is maintained for backwards compatibility. TODO chunk location into smaller regions TODO return results, ignoring duplicates

Author:
  Craig Melsopp

Constructor Summary
`FeatureIterator(FeatureAdaptor adaptor, int featureBufferSize, boolean loadChildren)` Create an iterator over all features in the adaptor.
`FeatureIterator(FeatureAdaptor adaptor, int chunkSize, boolean loadChildren, Location location, LocationConverter locationConverter)` Create an iterator over features in the adaptor that overlap the specified location.
`FeatureIterator(FeatureAdaptor adaptor, int featureBufferSize, boolean loadChildren, long[] internalIDs)` Create an iterator over features with the specified internalIDs.

Method Summary
`boolean` | `hasNext()` Returns whether there is another item to be returned via next().
`java.lang.Object` | `next()` Returns the next element in the iteration.
`void` | `remove()` Not supported.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FeatureIterator

    public FeatureIterator(FeatureAdaptor adaptor,
                           int featureBufferSize,
                           boolean loadChildren)
                    throws AdaptorException

  Create an iterator over all features in the adaptor. The order is unspecified.

Parameters:
  `adaptor` - adaptor to retrieve features from.
  `featureBufferSize` - number of items loaded into buffer.
  `loadChildren` - whether to preload child data.
Throws:
  `AdaptorException`

### FeatureIterator

    public FeatureIterator(FeatureAdaptor adaptor,
                           int featureBufferSize,
                           boolean loadChildren,
                           long[] internalIDs)
                    throws AdaptorException

  Create an iterator over features with the specified internalIDs. The order is unspecified.

Parameters:
  `adaptor` - adaptor to retrieve features from.
  `featureBufferSize` - number of items loaded into buffer.
  `loadChildren` - whether to preload child data.
  `internalIDs` - internal IDs of the features to retrieve
Throws:
  `AdaptorException`

### FeatureIterator

    public FeatureIterator(FeatureAdaptor adaptor,
                           int chunkSize,
                           boolean loadChildren,
                           Location location,
                           LocationConverter locationConverter)
                    throws AdaptorException

  Create an iterator over features in the adaptor that overlap the specified location. The order of returned items is the same as from adaptor.fetch(Location). Location is broken down in "chunks" of the specified size and then features are retrieved via adaptor.fetch(locationChunk).

Parameters:
  `adaptor` - adaptor to retrieve features from.
  `chunkSize` - size of the sub-location chunks.
  `loadChildren` - whether to preload child data.
  `location` - location filter.
Throws:
  `AdaptorException`

Method Detail

### remove

    public void remove()
                throws java.lang.UnsupportedOperationException

  Not supported.

  Specified by:
    `remove` in interface `java.util.Iterator`
  Throws:
    `java.lang.UnsupportedOperationException` - this method is not supported

### hasNext

    public boolean hasNext()

  Returns whether there is another item to be returned via next().

  Specified by:
    `hasNext` in interface `java.util.Iterator`
  Returns:
    true if the iterator has another feature.

### next

    public java.lang.Object next()

  Returns the next element in the iteration.

  Specified by:
    `next` in interface `java.util.Iterator`
  Returns:
    the next Feature in the iteration.
  Throws:
    `java.util.NoSuchElementException` - iteration has no more elements.
    `java.lang.RuntimeException` - problem occured reading the data from the database.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD