Class SearchResultsMapper<R,E>

java.lang.Object
io.micronaut.data.runtime.mapper.sql.SearchResultsMapper<R,E>
Type Parameters:
R - native row/result-set type
E - mapped entity type

@Internal public final class SearchResultsMapper<R,E> extends Object
Internal row mapper that composes entity payloads with vector score/similarity metadata.

The mapper expects the SQL projection to include a score column identified by scoreAlias. When a ScoringFunction is provided, normalized similarity is derived via SimilarityNormalizer; otherwise similarity is omitted.

Since:
5.0.0
  • Constructor Details

    • SearchResultsMapper

      public SearchResultsMapper(SqlTypeMapper<R,E> entityMapper, ResultReader<R,String> resultReader, String scoreAlias)
      Parameters:
      entityMapper - Entity mapper used to map each row entity payload
      resultReader - Reader used to extract score alias values
      scoreAlias - Result column alias containing the score value
    • SearchResultsMapper

      public SearchResultsMapper(SqlTypeMapper<R,E> entityMapper, ResultReader<R,String> resultReader, String scoreAlias, @Nullable ScoringFunction scoringFunction)
      Parameters:
      entityMapper - Entity mapper used to map each row entity payload
      resultReader - Reader used to extract score alias values
      scoreAlias - Result column alias containing the score value
      scoringFunction - Optional scoring function used to compute normalized similarity
  • Method Details

    • mapAll

      public SearchResults<E> mapAll(R rs, Class<E> entityType)
      Maps all rows from the provided result set into SearchResults.
      Parameters:
      rs - Result set/row stream handle
      entityType - Entity type to map
      Returns:
      Mapped search results
    • hasNext

      public boolean hasNext(R rs)
      Parameters:
      rs - Result set/row stream handle
      Returns:
      Whether another row is available
    • mapOne

      public @Nullable SearchResult<E> mapOne(R rs, Class<E> entityType)
      Maps the current row into a SearchResult.
      Parameters:
      rs - Result set/row stream handle
      entityType - Entity type to map
      Returns:
      mapped result or null when entity mapping yields no row data