Skip to content

Commit

Permalink
HSEARCH-4203 Add a deadline parameter to SelectionEntityLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed May 7, 2021
1 parent 9372a67 commit 78048bc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Expand Up @@ -277,7 +277,7 @@ public void nullEntity() {
session.indexingPlan().delete( IndexedEntity.class, 3, null );
session.indexingPlan().delete( IndexedEntity.class, 4, null );

when( loaderMock.load( Arrays.asList( 1, 2 ) ) )
when( loaderMock.load( Arrays.asList( 1, 2 ), null ) )
.thenReturn( Arrays.asList( entity1, entity2 ) );

backendMock.expectWorks( IndexedEntity.INDEX )
Expand Down Expand Up @@ -393,12 +393,12 @@ public void nullEntity_state() {
loadedEntities.add( entity );
expectations.addOrUpdate( "10", b -> b.field( "value", "val10" ) );

when( loaderMock.load( idsToLoad ) ).thenReturn( loadedEntities );
when( loaderMock.load( idsToLoad, null ) ).thenReturn( loadedEntities );

expectations.createdThenExecuted();
}

verify( loaderMock ).load( any() );
verify( loaderMock ).load( any(), any() );
}

@Test
Expand Down
Expand Up @@ -143,7 +143,7 @@ protected final void expectLoading(Integer ... ids) {
}

protected final void expectLoading(List<Integer> ids, List<IndexedEntity> entities) {
when( loaderMock.load( ids ) ).thenReturn( entities );
when( loaderMock.load( ids, null ) ).thenReturn( entities );
}

protected final void expectOperation(CompletableFuture<?> futureFromBackend, int id, String providedRoutingKey, String value) {
Expand Down
Expand Up @@ -8,6 +8,8 @@

import java.util.List;

import org.hibernate.search.engine.common.timing.Deadline;

/**
* A loader for loading a small selection of entities, used in particular during search.
* <p>
Expand All @@ -28,9 +30,12 @@ public interface SelectionEntityLoader<E> {
* Loads the entities corresponding to the given identifiers, blocking the current thread while doing so.
*
* @param identifiers A list of identifiers for objects to load.
* @param deadline The deadline for loading the entities, or {@code null} if there is no deadline.
* Should be complied with on a best-effort basis: it's acceptable to ignore it,
* but it means some timeouts in Hibernate Search will not work properly.
* @return A list of entities, in the same order the identifiers were given.
* {@code null} is inserted when an object is not found or has the wrong concrete type.
*/
List<E> load(List<?> identifiers);
List<E> load(List<?> identifiers, Deadline deadline);

}
Expand Up @@ -22,7 +22,7 @@ public JavaBeanSelectionEntityLoader(SelectionEntityLoader<E> delegate) {

@Override
public List<?> loadBlocking(List<?> identifiers, Deadline deadline) {
return delegate.load( identifiers );
return delegate.load( identifiers, deadline );
}

}
Expand Up @@ -31,7 +31,9 @@ public interface PojoSelectionEntityLoader<E> {
* Loads the entities corresponding to the given identifiers, blocking the current thread while doing so.
*
* @param identifiers A list of identifiers for objects to load.
* @param deadline The deadline for loading the entities, or null if there is no deadline.
* @param deadline The deadline for loading the entities, or {@code null} if there is no deadline.
* Should be complied with on a best-effort basis: it's acceptable to ignore it,
* but it means some timeouts in Hibernate Search will not work properly.
* @return A list of entities, in the same order the references were given.
* {@code null} is inserted when an object is not found or has an excluded types
* (see {@link PojoSelectionLoadingStrategy#createLoader(Set)}).
Expand Down

0 comments on commit 78048bc

Please sign in to comment.