Class RowProjectionGenerator<E>

java.lang.Object
io.bloviate.gen.AbstractDataGenerator<String>
io.bloviate.datafaker.RowProjectionGenerator<E>
Type Parameters:
E - the entity type
All Implemented Interfaces:
DataGenerator<String>, IndexedDataGenerator

public final class RowProjectionGenerator<E> extends AbstractDataGenerator<String> implements IndexedDataGenerator
Emits one field of a RowContext's per-row entity. Several projections of the same context share that context, so they produce a consistent tuple per row (issue #473).

Each projection keeps its own row counter and is seekable, so the projections of a row advance in lockstep, stay order-independent, and reproduce the sequential output under intra-table partitioning (each partition seeks to its first row, then walks). The value is a pure function of the row index via the shared context, so partitioned output is byte-identical to a sequential fill.

Since:
2.12.0
  • Method Details

    • generate

      public String generate()
      Projects the selected field of the entity for the current row, then advances this projection's row counter by one. The entity is resolved from the shared RowContext for the current row index, so sibling projections of the same context yield a consistent tuple.
      Specified by:
      generate in interface DataGenerator<E>
      Returns:
      the selected field of the current row's entity, as a string
    • seek

      public void seek(long rowIndex)
      Positions this projection's row counter at the given row index, so the next generate() projects that row's entity. Used for positional or partitioned access, where each partition seeks to its first row and then walks forward.
      Specified by:
      seek in interface IndexedDataGenerator
      Parameters:
      rowIndex - the zero-based row index to position at
      Throws:
      IllegalArgumentException - if rowIndex is negative
    • get

      public String get(ResultSet resultSet, int columnIndex) throws SQLException
      Reads this projection's value back from a ResultSet as a string.
      Specified by:
      get in interface DataGenerator<E>
      Parameters:
      resultSet - the result set positioned on the row to read
      columnIndex - the one-based column index to read
      Returns:
      the column value as a string
      Throws:
      SQLException - if the value cannot be read from the result set