Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-4203 Replace EntityIdentifierScroll/EntityLoader/LoadingInter…
…ceptor with MassIdentifierLoader/MassEntityLoader 1. This is simpler for users to implement, as they can manage the context setup/teardown directly in the class where that context is used. 2. This is still highly customizable, as BatchEntityLoadingOptions offers ways to pass context to the loaders.
- Loading branch information
Showing
86 changed files
with
1,806 additions
and
1,455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...javabean/src/main/java/org/hibernate/search/mapper/javabean/loading/MassEntityLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.javabean.loading; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A loader for mass loading of entities, used in particular during mass indexing. | ||
* <p> | ||
* Compared to {@link EntityLoader}, this loader: | ||
* <ul> | ||
* <li>Receives batches of identifiers from a {@link MassIdentifierLoader}</li> | ||
* <li>Is expected to load a very large number of entities in multiple small batches.</li> | ||
* <li>Pushes loaded entities to a sink.</li> | ||
* <li>Sets up its own context (session, transactions, ...), instead of potentially relying on a pre-existing context.</li> | ||
* <li>Is free to discard the entities after the sink is done processing them.</li> | ||
* </ul> | ||
* | ||
* @param <I> The type of entity identifiers. | ||
*/ | ||
public interface MassEntityLoader<I> extends AutoCloseable { | ||
|
||
/** | ||
* Closes this {@link MassEntityLoader}. | ||
*/ | ||
@Override | ||
void close(); | ||
|
||
/** | ||
* Loads the entities corresponding to the given identifiers and adds them to the given sink, | ||
* blocking the current thread while doing so. | ||
* <p> | ||
* Calls to the sink must be performed synchronously (before this method returns). | ||
* <p> | ||
* Entities must be passed to the sink using a single call to {@link MassEntitySink#accept(List)}. | ||
* <p> | ||
* Entities passed to the sink do not need to be the same order as {@code identifiers}. | ||
* | ||
* @param identifiers A list of identifiers of entities to load. | ||
*/ | ||
void load(List<I> identifiers); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...r/javabean/src/main/java/org/hibernate/search/mapper/javabean/loading/MassEntitySink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.mapper.javabean.loading; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A sink for use by a {@link MassIdentifierLoader}. | ||
* | ||
* @param <E> The type of loaded entities. | ||
*/ | ||
public interface MassEntitySink<E> { | ||
|
||
/** | ||
* Adds a batch of entities to the sink. | ||
* <p> | ||
* The list and entities need to stay usable at least until this method returns, | ||
* as they will be consumed synchronously. | ||
* Afterwards, they can be discarded or reused at will. | ||
* | ||
* @param batch The next batch of identifiers. Never {@code null}, never empty. | ||
*/ | ||
void accept(List<? extends E> batch); | ||
|
||
} |
Oops, something went wrong.