Package com.atlassian.jira.sharing
Class SharedEntityBatcherIterable<S extends SharedEntity>
java.lang.Object
com.atlassian.jira.sharing.SharedEntityBatcherIterable<S>
- All Implemented Interfaces:
EnclosedIterable<S>,Sized
public class SharedEntityBatcherIterable<S extends SharedEntity>
extends Object
implements EnclosedIterable<S>
An iterable that fetches shared entities in batches from the database. Each batch is loaded directly to the memory
and the DB is queried only when the current batch is exhausted. The DB connection isn't kept during batch processing.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.util.collect.EnclosedIterable
EnclosedIterable.Functions, EnclosedIterable.ListResolver<T> -
Constructor Summary
ConstructorsConstructorDescriptionSharedEntityBatcherIterable(OfBizDelegator delegator, String table, Function<org.ofbiz.core.entity.GenericValue, S> entityResolver, int batchSize) Creates a new instance of SharedEntityBatcherIterable.SharedEntityBatcherIterable(OfBizDelegator delegator, String table, org.ofbiz.core.entity.EntityCondition condition, Function<org.ofbiz.core.entity.GenericValue, S> entityResolver, int batchSize) Creates a new instance of SharedEntityBatcherIterable. -
Method Summary
-
Constructor Details
-
SharedEntityBatcherIterable
public SharedEntityBatcherIterable(OfBizDelegator delegator, String table, org.ofbiz.core.entity.EntityCondition condition, Function<org.ofbiz.core.entity.GenericValue, S> entityResolver, int batchSize) Creates a new instance of SharedEntityBatcherIterable.- Parameters:
delegator- the OfBizDelegator that will be used for querying the databasetable- the table name to fetch data fromcondition- optional condition to filter data. If null, no condition will be applied.entityResolver- the function to convert a GenericValue to an instance of SbatchSize- the size of the single batch used to iterate over the data. Must be positive value.
-
SharedEntityBatcherIterable
public SharedEntityBatcherIterable(OfBizDelegator delegator, String table, Function<org.ofbiz.core.entity.GenericValue, S> entityResolver, int batchSize) Creates a new instance of SharedEntityBatcherIterable.- Parameters:
delegator- the OfBizDelegator that will be used for querying the databasetable- the table name to fetch data fromentityResolver- the function to convert a GenericValue to an instance of SbatchSize- the size of the single batch used to iterate over the data. Must be positive value.
-
-
Method Details
-
foreach
Description copied from interface:EnclosedIterableApply the sink to all elements in the Collection.- Specified by:
foreachin interfaceEnclosedIterable<S extends SharedEntity>
-
size
public int size()- Specified by:
sizein interfaceEnclosedIterable<S extends SharedEntity>- Specified by:
sizein interfaceSized- Returns:
- the likely size of the objects passed into the sink in
EnclosedIterable.foreach(Consumer). Be careful depending on this size being exact, as in many cases its best efforts value or may be unstable due to concurrent changes.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceEnclosedIterable<S extends SharedEntity>- Specified by:
isEmptyin interfaceSized- Returns:
- true if the there is no data behind it.
-