@Experimental(value=SOURCE_SINK) public class CassandraIO extends java.lang.Object
CassandraIO
provides a source to read and returns a bounded collection of entities as
PCollection<Entity>
. An entity is built by Cassandra mapper (com.datastax.driver.mapping.EntityMapper
) based on a POJO containing annotations (as described
http://docs.datastax .com/en/developer/java-driver/2.1/manual/object_mapper/creating/").
The following example illustrates various options for configuring the IO:
pipeline.apply(CassandraIO.<Person>read()
.withHosts(Arrays.asList("host1", "host2"))
.withPort(9042)
.withKeyspace("beam")
.withTable("Person")
.withEntity(Person.class)
.withCoder(SerializableCoder.of(Person.class))
// above options are the minimum set, returns PCollection<Person>
CassandraIO
provides a sink to write a collection of entities to Apache Cassandra.
The following example illustrates various options for configuring the IO write:
pipeline
.apply(...) // provides a PCollection<Person> where Person is an entity
.apply(CassandraIO.<Person>write()
.withHosts(Arrays.asList("host1", "host2"))
.withPort(9042)
.withKeyspace("beam")
.withEntity(Person.class));
Modifier and Type | Class and Description |
---|---|
static class |
CassandraIO.Read<T>
A
PTransform to read data from Apache Cassandra. |
static class |
CassandraIO.Write<T>
A
PTransform to write into Apache Cassandra. |
Modifier and Type | Method and Description |
---|---|
static <T> CassandraIO.Read<T> |
read()
Provide a
CassandraIO.Read PTransform to read data from a Cassandra database. |
static <T> CassandraIO.Write<T> |
write()
Provide a
CassandraIO.Write PTransform to write data to a Cassandra database. |
public static <T> CassandraIO.Read<T> read()
CassandraIO.Read
PTransform
to read data from a Cassandra database.public static <T> CassandraIO.Write<T> write()
CassandraIO.Write
PTransform
to write data to a Cassandra database.