org.rhq.enterprise.server.util
Class BatchIterator<T>

java.lang.Object
  extended by org.rhq.enterprise.server.util.BatchIterator<T>
All Implemented Interfaces:
Iterable<List<T>>

public class BatchIterator<T>
extends Object
implements Iterable<List<T>>

A convenience class for getting around the http://ora-01795.ora-code.com/ issue, which limits the size of the in-clause parameters to 1000. Can be used to take a large collection of ids, and iterate over them in batches. The default batch size using the single-argument constructor is 1000, but the constructor which takes two arguments allows overriding the batch size to any positive integer.

Author:
Joseph Marques, John Sanda

Field Summary
static int DEFAULT_BATCH_SIZE
           
 
Constructor Summary
BatchIterator(List<T> data)
           
BatchIterator(List<T> data, int batchSize)
           
 
Method Summary
 List<T> getNextBatch()
           
 boolean hasMoreBatches()
           
 Iterator<List<T>> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BATCH_SIZE

public static final int DEFAULT_BATCH_SIZE
See Also:
Constant Field Values
Constructor Detail

BatchIterator

public BatchIterator(List<T> data)

BatchIterator

public BatchIterator(List<T> data,
                     int batchSize)
Method Detail

iterator

public Iterator<List<T>> iterator()
Specified by:
iterator in interface Iterable<List<T>>

hasMoreBatches

public boolean hasMoreBatches()

getNextBatch

public List<T> getNextBatch()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.