Skip to content

DataStax-Examples/beam-sdks-java-io-astra

Repository files navigation

beam-sdks-java-io-astra

Apache Beam SDK to work with Astra Pipelines

How To

Installation

To use this SDK, add the following dependency to your project:

GitHub release (with filter)

<dependency>
  <groupId>com.datastax.astra</groupId>
  <artifactId>beam-sdks-java-io-astra</artifactId>
  <version>${latest-version}</version>
</dependency>

Usage

Documentation is available in Awesome Astra with sample codes

  • Read Data From Astra
// Get binary from File path
byte[] scbZip = AstraSecureConnectBundleUtils
                .loadFromFilePath(options.getAstraSecureConnectBundle());

// Build a Source
AstraDbIO.Read<LanguageCode> read = AstraDbIO.<LanguageCode>read()
  .withToken(options.getAstraToken())
  .withKeyspace(options.getAstraKeyspace())
  .withSecureConnectBundle(scbZip)
  .withTable(options.getTable())
  .withCoder(SerializableCoder.of(LanguageCode.class))
  .withMapperFactoryFn(new LanguageCodeDaoMapperFactoryFn())
  .withEntity(LanguageCode.class))