Search in sources :

Example 46 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class WordCount method configure.

@Override
public void configure() {
    WordCountConfig config = getConfig();
    setName("WordCount");
    setDescription("Example word count application");
    // Ingest data into the Application via Streams
    addStream(new Stream(config.getStream()));
    // Store processed data in Datasets
    createDataset(config.getWordStatsTable(), Table.class, TableProperties.builder().setReadlessIncrementSupport(true).setDescription("Stats of total counts and lengths of words").build());
    createDataset(config.getWordCountTable(), KeyValueTable.class, DatasetProperties.builder().setDescription("Words and corresponding counts").build());
    createDataset(config.getUniqueCountTable(), UniqueCountTable.class, DatasetProperties.builder().setDescription("Total count of unique words").build());
    createDataset(config.getWordAssocTable(), AssociationTable.class, DatasetProperties.builder().setDescription("Word associations table").build());
    // Process events in real-time using Flows
    addFlow(new WordCounter(config));
    // Retrieve the processed data using a Service
    addService(new RetrieveCounts(config));
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Example 47 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class WebAnalytics method configure.

@Override
public void configure() {
    addStream(new Stream("log"));
    addFlow(new WebAnalyticsFlow());
    createDataset("UniqueVisitCount", UniqueVisitCount.class, DatasetProperties.builder().setDescription("Unique Visit Counts").build());
    setName("WebAnalytics");
    setDescription("Web Analytics Application");
}
Also used : Stream(co.cask.cdap.api.data.stream.Stream)

Example 48 with Stream

use of co.cask.cdap.api.data.stream.Stream in project cdap by caskdata.

the class SparkKMeansApp method configure.

@Override
public void configure() {
    setName("SparkKMeans");
    setDescription("Spark KMeans app");
    // Ingest data into the Application via a Stream
    addStream(new Stream("pointsStream"));
    // Process points data in real-time using a Flow
    addFlow(new PointsFlow());
    // Run a Spark program on the acquired data
    addSpark(new SparkKMeansSpecification());
    // Retrieve the processed data using a Service
    addService(new CentersService());
    // Store input and processed data in ObjectStore Datasets
    try {
        ObjectStores.createObjectStore(getConfigurer(), "points", Point.class, DatasetProperties.builder().setDescription("Store points data").build());
        ObjectStores.createObjectStore(getConfigurer(), "centers", String.class, DatasetProperties.builder().setDescription("Store centers data").build());
    } catch (UnsupportedTypeException e) {
        // because String is an actual class.
        throw new RuntimeException(e);
    }
}
Also used : UnsupportedTypeException(co.cask.cdap.api.data.schema.UnsupportedTypeException) Stream(co.cask.cdap.api.data.stream.Stream)

Aggregations

Stream (co.cask.cdap.api.data.stream.Stream)48 UnsupportedTypeException (co.cask.cdap.api.data.schema.UnsupportedTypeException)10 BasicService (co.cask.cdap.api.service.BasicService)6 InputStream (java.io.InputStream)2 Schema (co.cask.cdap.api.data.schema.Schema)1 KeyValueTable (co.cask.cdap.api.dataset.lib.KeyValueTable)1 Table (co.cask.cdap.api.dataset.table.Table)1 AvroKeyOutputFormat (org.apache.avro.mapreduce.AvroKeyOutputFormat)1 TextOutputFormat (org.apache.hadoop.mapreduce.lib.output.TextOutputFormat)1