Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 02D552009D9 for ; Mon, 2 May 2016 21:38:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0153B1609B1; Mon, 2 May 2016 21:38:18 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0719A1602C5 for ; Mon, 2 May 2016 21:38:16 +0200 (CEST) Received: (qmail 93934 invoked by uid 500); 2 May 2016 19:38:16 -0000 Mailing-List: contact dev-help@quarks.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@quarks.incubator.apache.org Delivered-To: mailing list dev@quarks.incubator.apache.org Received: (qmail 93921 invoked by uid 99); 2 May 2016 19:38:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 19:38:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 97B841A0AAF for ; Mon, 2 May 2016 19:38:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id maY8UHoF-os5 for ; Mon, 2 May 2016 19:38:13 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 0A26C5F488 for ; Mon, 2 May 2016 19:38:12 +0000 (UTC) Received: (qmail 93779 invoked by uid 99); 2 May 2016 19:38:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 19:38:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 48571DFB81; Mon, 2 May 2016 19:38:12 +0000 (UTC) From: dlaboss To: dev@quarks.incubator.apache.org Reply-To: dev@quarks.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-quarks-website pull request: [QUARKS-159] Update website... Content-Type: text/plain Message-Id: <20160502193812.48571DFB81@git1-us-west.apache.org> Date: Mon, 2 May 2016 19:38:12 +0000 (UTC) archived-at: Mon, 02 May 2016 19:38:18 -0000 Github user dlaboss commented on a diff in the pull request: https://github.com/apache/incubator-quarks-website/pull/53#discussion_r61791036 --- Diff: site/docs/quarks-getting-started.md --- @@ -42,152 +44,151 @@ The Quarks Java 8 JAR files are located in the `quarks/java8/lib` directory. -
Your environment is set up! You can start writing your first Quarks application. - ## Creating a simple application + If you're new to Quarks or to writing streaming applications, the best way to get started is to write a simple program. -Quarks is a framework that pushes data analytics and machine learning to *edge devices*. (Edge devices include things like routers, gateways, machines, equipment, sensors, appliances, or vehicles that are connected to a network.) Quarks enables you to process data locally---such as, in a car engine, on an Android phone, or Raspberry Pi---before you send data over a network. +Quarks is a framework that pushes data analytics and machine learning to *edge devices*. (Edge devices include things like routers, gateways, machines, equipment, sensors, appliances, or vehicles that are connected to a network.) Quarks enables you to process data locally—such as, in a car engine, on an Android phone, or Raspberry Pi—before you send data over a network. For example, if your device takes temperature readings from a sensor 1,000 times per second, it is more efficient to process the data locally and send only interesting or unexpected results over the network. To simulate this, let's define a (simulated) TempSensor class: - - ```java - import java.util.Random; - - import quarks.function.Supplier; - - /** - * Every time get() is called, TempSensor generates a temperature reading. - */ - public class TempSensor implements Supplier { - double currentTemp = 65.0; - Random rand; - - TempSensor(){ - rand = new Random(); - } - - @Override - public Double get() { - // Change the current temperature some random amount - double newTemp = rand.nextGaussian() + currentTemp; - currentTemp = newTemp; - return currentTemp; - } - } +import java.util.Random; + +import quarks.function.Supplier; + +/** + * Every time get() is called, TempSensor generates a temperature reading. + */ +public class TempSensor implements Supplier { + double currentTemp = 65.0; + Random rand; + + TempSensor(){ + rand = new Random(); + } + + @Override + public Double get() { + // Change the current temperature some random amount + double newTemp = rand.nextGaussian() + currentTemp; + currentTemp = newTemp; + return currentTemp; + } +} ``` - Every time you call `TempSensor.get()`, it returns a new temperature reading. The continuous temperature readings are a stream of data that a Quarks application can process. Our sample Quarks application processes this stream by filtering the data and printing the results. Let's define a TempSensorApplication class for the application: ```java - import java.util.concurrent.TimeUnit; - - import quarks.providers.direct.DirectProvider; - import quarks.topology.TStream; - import quarks.topology.Topology; - - public class TempSensorApplication { - public static void main(String[] args) throws Exception { - TempSensor sensor = new TempSensor(); - DirectProvider dp = new DirectProvider(); - Topology topology = dp.newTopology(); - TStream tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS); - TStream filteredReadings = tempReadings.filter(reading -> reading < 50 || reading > 80); - - filteredReadings.print(); - dp.submit(topology); - } - } +import java.util.concurrent.TimeUnit; + +import quarks.providers.direct.DirectProvider; +import quarks.topology.TStream; +import quarks.topology.Topology; + +public class TempSensorApplication { + public static void main(String[] args) throws Exception { + TempSensor sensor = new TempSensor(); + DirectProvider dp = new DirectProvider(); + Topology topology = dp.newTopology(); + TStream tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS); + TStream filteredReadings = tempReadings.filter(reading -> reading < 50 || reading > 80); + + filteredReadings.print(); + dp.submit(topology); + } +} ``` To understand how the application processes the stream, let's review each line. ### Specifying a provider -Your first step when you write a Quarks application is to create a -[`DirectProvider`](http://quarks-edge.github.io/quarks/docs/javadoc/index.html?quarks/providers/direct/DirectProvider.html) : + +Your first step when you write a Quarks application is to create a [`DirectProvider`](http://quarks-edge.github.io/quarks/docs/javadoc/index.html?quarks/providers/direct/DirectProvider.html): ```java - DirectProvider dp = new DirectProvider(); +DirectProvider dp = new DirectProvider(); ``` -A **Provider** is an object that contains information on how and where your Quarks application will run. A **DirectProvider** is a type of Provider that runs your application directly within the current virtual machine when its `submit()` method is called. +A `Provider` is an object that contains information on how and where your Quarks application will run. A `DirectProvider` is a type of Provider that runs your application directly within the current virtual machine when its `submit()` method is called. ### Creating a topology -Additionally a Provider is used to create a -[`Topology`](http://quarks-edge.github.io/quarks/docs/javadoc/index.html?quarks/topology/Topology.html) instance : + +Additionally a Provider is used to create a [`Topology`](http://quarks-edge.github.io/quarks/docs/javadoc/index.html?quarks/topology/Topology.html) instance: ```java - Topology topology = dp.newTopology(); +Topology topology = dp.newTopology(); ``` -In Quarks, **Topology** is a container that describes the structure of your application: +In Quarks, `Topology` is a container that describes the structure of your application: * Where the streams in the application come from - * How the data in the stream is modified -In the TempSensor application above, we have exactly one data source: the `TempSensor` object. We define the source stream by calling `topology.poll()`, which takes both a Supplier function and a time parameter to indicate how frequently readings should be taken. In our case, we read from the sensor every millisecond: +In the TempSensor application above, we have exactly one data source: the `TempSensor` object. We define the source stream by calling `topology.poll()`, which takes both a `Supplier` function and a time parameter to indicate how frequently readings should be taken. In our case, we read from the sensor every millisecond: ```java - TStream tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS); +TStream tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS); ``` -### Defining the TStream object +### Defining the `TStream` object + Calling `topology.poll()` to define a source stream creates a `TStream` instance, which represents the series of readings taken from the temperature sensor. -A streaming application can run indefinitely, so the TStream might see an arbitrarily large number of readings pass through it. Because a TStream represents the flow of your data, it supports a number of operations which allow you to modify your data. +A streaming application can run indefinitely, so the `TStream` might see an arbitrarily large number of readings pass through it. Because a `TStream` represents the flow of your data, it supports a number of operations which allow you to modify your data. + +## Filtering a `TStream` --- End diff -- I made the adjustment when merging --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---