edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlaboss <...@git.apache.org>
Subject [GitHub] incubator-quarks-website pull request: [QUARKS-159] Update website...
Date Fri, 29 Apr 2016 21:02:07 GMT
Github user dlaboss commented on a diff in the pull request:

    https://github.com/apache/incubator-quarks-website/pull/53#discussion_r61644260
  
    --- 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.
     
         <img src="images/Build_Path_Jars.JPG" style="width:661px;height:444px;">
     
    -<br/>
     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&mdash;such
as, in a car engine, on an Android phone, or Raspberry Pi&mdash;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> {
    -  		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> {
    +    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<Double> tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS);
    -		    TStream<Double> 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<Double> tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS);
    +        TStream<Double> 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<Double> tempReadings = topology.poll(sensor, 1, TimeUnit.MILLISECONDS);
    +TStream<Double> 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<Double>`
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 --
    
    An impressive set of all-encompassing changes!  I just got lucky noticing this :-)


---
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.
---

Mime
View raw message