public class AsyncCastorPersistenceQueryResults extends CastorPersistenceQueryResults
CastorPersistenceQueryResults.
This implementation utilizes a Producer-Consumer pattern to decouple database fetching from OQL filtering and delivery from the main application thread. By pre-filling a bounded cache in the background, it effectively masks I/O latency and ORM mapping overhead (hydration etc.).
Throughput Optimizations:
ArrayBlockingQueue to prevent uncontrolled heap growth if the
consumer processing lags behind the database producer.
slim() calls for any filtered-out object to the background thread, flattening
the main thread's CPU profile.
Thread Safety Warning: The underlying Castor QueryResults (rs) is
not thread-safe. This class assumes exclusive ownership of the result set by the background
producer thread once started.
| Constructor and Description |
|---|
AsyncCastorPersistenceQueryResults(CastorPersistenceHandler ph,
java.lang.String query,
java.lang.Object[] parms,
short mode,
java.lang.String[] prefetchPaths)
Initializes the asynchronous result set and prepares the background executor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying result set and the query implementation.
|
boolean |
hasNext()
Determines if a subsequent record is available, respecting any
CastorPersistenceQueryResults.filterPredicate applied during OQL compilation. |
java.lang.Object |
next()
Throughput Optimization:
Memory Management:
For read-only transactions, the previous BO is aggressively slimmed before fetching
the next to prevent Heap bloat.
|
cancel, currentTag, isClosed, removepublic AsyncCastorPersistenceQueryResults(CastorPersistenceHandler ph, java.lang.String query, java.lang.Object[] parms, short mode, java.lang.String[] prefetchPaths)
public boolean hasNext()
Determines if a subsequent record is available, respecting any
CastorPersistenceQueryResults.filterPredicate applied during OQL compilation.
Optimization Logic:
nextFittingBO.
hasNext in interface java.util.IteratorhasNext in class CastorPersistenceQueryResultstrue if a subsequent call to CastorPersistenceQueryResults.next() is guaranteed to return a BO.public java.lang.Object next()
CastorPersistenceQueryResultsThroughput Optimization:
hasNext().
next in interface java.util.Iteratornext in class CastorPersistenceQueryResultspublic void close()
Closes the underlying result set and the query implementation.
In addition to resource cleanup, this method "slims" any currently held
Business Objects to aid memory reclamation and notifies the handler of
query performance metrics via ph.complainSlowQuery.
close in interface de.ipcon.db.core.QueryResultsIclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class CastorPersistenceQueryResultsCopyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.