workQueue.setSealedQueue( luceneQueue );
}
private void processWorkByLayer(List<Work> queue, int initialSize, List<LuceneWork> luceneQueue, Layer layer) {
for ( int i = 0 ; i < initialSize ; i++ ) {
Work work = queue.get( i );
if ( work != null) {
if ( layer.isRightLayer( work.getType() ) ) {
queue.set( i, null ); // help GC and avoid 2 loaded queues in memory
Class entityClass = work.getEntityClass() != null ?
work.getEntityClass() :
Hibernate.getClass( work.getEntity() );
DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( entityClass );
if ( builder == null ) continue; //or exception?
builder.addWorkToQueue(entityClass, work.getEntity(), work.getId(), work.getType(), luceneQueue, searchFactoryImplementor );
}
}
}
}