java.lang.Object
jakarta.batch.api.chunk.AbstractItemReader
org.hibernate.search.jakarta.batch.core.massindexing.step.spi.EntityIdReader
All Implemented Interfaces:
ItemReader

@Named("org.hibernate.search.jsr352.massindexing.impl.steps.lucene.EntityReader") @HibernateSearchPartitionScoped public class EntityIdReader extends AbstractItemReader
Reads entity identifiers from the database.

This reader builds a scroll and outputs IDs from that scroll.

Each reader pertains to only one entity type.

The reading range is restricted by the PartitionBound, which always represents a left-closed interval. See HibernateSearchPartitionMapper for more information about these bounds.

Author:
Mincong Huang
  • Constructor Details

    • EntityIdReader

      public EntityIdReader()
    • EntityIdReader

      public EntityIdReader(String entityName, String serializedIdFetchSize, String reindexOnlyHql, String serializedReindexOnlyParameters, String serializedMaxResultsPerEntity, String partitionIdStr, String serializedLowerBound, String serializedUpperBound, JobContext jobContext, StepContext stepContext)
  • Method Details

    • open

      public void open(Serializable checkpointInfo) throws IOException, ClassNotFoundException
      Initialize the environment. If checkpoint does not exist, then it should be the first open. If checkpoint exists, then it isn't the first open, re-use the input object "checkpoint" as the last ID already read.
      Specified by:
      open in interface ItemReader
      Overrides:
      open in class AbstractItemReader
      Parameters:
      checkpointInfo - The last checkpoint info persisted in the batch runtime, previously given by checkpointInfo(). If this is the first start, then the checkpoint will be null.
      Throws:
      IOException
      ClassNotFoundException
    • close

      public void close()
      Close operation(s) before the class destruction.
      Specified by:
      close in interface ItemReader
      Overrides:
      close in class AbstractItemReader
    • readItem

      public Object readItem()
      Read item from database using JPA. Each read, there will be only one identifier fetched.
      Specified by:
      readItem in interface ItemReader
      Specified by:
      readItem in class AbstractItemReader
    • checkpointInfo

      public Serializable checkpointInfo()
      The checkpointInfo method returns the current checkpoint data for this reader. It is called before a chunk checkpoint is committed.
      Specified by:
      checkpointInfo in interface ItemReader
      Overrides:
      checkpointInfo in class AbstractItemReader
      Returns:
      the checkpoint info