Skip to content

Commit

Permalink
HSEARCH-3998 Clarify the purpose of the "load"/"index" methods in Ide…
Browse files Browse the repository at this point in the history
…ntifierConsumerDocumentProducer
  • Loading branch information
yrodiere committed Sep 23, 2020
1 parent 4441796 commit 773f51b
Showing 1 changed file with 6 additions and 15 deletions.
Expand Up @@ -98,7 +98,7 @@ public void run() {
session.setHibernateFlushMode( FlushMode.MANUAL );
session.setCacheMode( cacheMode );
session.setDefaultReadOnly( true );
loadAllFromQueue( session );
loadAndIndexAllFromQueue( session );
}
catch (Exception exception) {
notifier.notifyRunnableFailure(
Expand All @@ -109,7 +109,7 @@ public void run() {
log.trace( "finished" );
}

private void loadAllFromQueue(SessionImplementor session) throws SystemException, NotSupportedException {
private void loadAndIndexAllFromQueue(SessionImplementor session) throws SystemException, NotSupportedException {
// The search session will be closed automatically with the ORM session
PojoIndexer indexer = mappingContext.createIndexer( session );
try {
Expand All @@ -118,7 +118,7 @@ private void loadAllFromQueue(SessionImplementor session) throws SystemException
idList = source.take();
if ( idList != null ) {
log.tracef( "received list of ids %s", idList );
loadList( idList, session, indexer );
loadAndIndexList( idList, session, indexer );
}
}
while ( idList != null );
Expand All @@ -129,16 +129,7 @@ private void loadAllFromQueue(SessionImplementor session) throws SystemException
}
}

/**
* Loads a list of entities of defined type using their identifiers.
* entities are then transformed into Lucene Documents
* and forwarded to the indexing backend.
*
* @param listIds the list of entity identifiers (of type
* @param session the session to be used
* @param indexer the indexer to be used
*/
private void loadList(List<I> listIds, SessionImplementor session, PojoIndexer indexer)
private void loadAndIndexList(List<I> listIds, SessionImplementor session, PojoIndexer indexer)
throws InterruptedException, NotSupportedException, SystemException {
try {
beginTransaction( session );
Expand All @@ -156,7 +147,7 @@ private void loadList(List<I> listIds, SessionImplementor session, PojoIndexer i
.setHibernateFlushMode( FlushMode.MANUAL )
.setFetchSize( listIds.size() );

indexAllQueue( session, indexer, query.getResultList() );
indexList( session, indexer, query.getResultList() );
session.clear();
}
finally {
Expand Down Expand Up @@ -192,7 +183,7 @@ private void rollbackTransaction(SessionImplementor session) {
}
}

private void indexAllQueue(Session session, PojoIndexer indexer, List<E> entities) throws InterruptedException {
private void indexList(Session session, PojoIndexer indexer, List<E> entities) throws InterruptedException {
if ( entities == null || entities.isEmpty() ) {
return;
}
Expand Down

0 comments on commit 773f51b

Please sign in to comment.