Interface Mapper<T>


public interface Mapper<T>
This interface allows you to implement a custom mapper to read and persist elements from/to Cassandra.

To Implement a custom mapper you need to: 1) Create an implementation of Mapper. 2) Create a SerializableFunction that instantiates the Mapper for a given Session, for an example see DefaultObjectMapperFactory). 3) Pass this function to CassandraIO.Read.withMapperFactoryFn(SerializableFunction) in the CassandraIO builder.
Example:


 SerializableFunction<Session, Mapper> factory = new MyCustomFactory();
 pipeline
    .apply(...)
    .apply(CassandraIO.<>read()
        .withMapperFactoryFn(factory));
 
  • Method Summary

    Modifier and Type
    Method
    Description
    deleteAsync(T entity)
    This method is called for each delete event.
    map(ResultSet resultSet)
    This method is called when reading data from Cassandra.
    saveAsync(T entity)
    This method is called for each save event.
  • Method Details

    • map

      Iterator<T> map(ResultSet resultSet)
      This method is called when reading data from Cassandra. It should map a ResultSet into the corresponding Java objects.
      Parameters:
      resultSet - A resultset containing rows.
      Returns:
      An iterator containing the objects that you want to provide to your downstream pipeline.
    • deleteAsync

      Future<Void> deleteAsync(T entity)
      This method is called for each delete event. The input argument is the Object that should be deleted in Cassandra. The return value should be a Future that completes when the delete action is completed.
      Parameters:
      entity - Entity to be deleted.
    • saveAsync

      Future<Void> saveAsync(T entity)
      This method is called for each save event. The input argument is the Object that should be saved or updated in Cassandra. The return value should be a future that completes when the save action is completed.
      Parameters:
      entity - Entity to be saved.