[
https://issues.apache.org/jira/browse/QUARKS-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15264700#comment-15264700
]
ASF GitHub Bot commented on QUARKS-159:
---------------------------------------
Github user queeniema commented on a diff in the pull request:
https://github.com/apache/incubator-quarks-website/pull/53#discussion_r61641834
--- 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—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> {
- 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 --
You're right, it should be a Level 3 header! Lots of changes, I was bound
to make a mistake :)
> Update website to follow style guide
> ------------------------------------
>
> Key: QUARKS-159
> URL: https://issues.apache.org/jira/browse/QUARKS-159
> Project: Quarks
> Issue Type: Improvement
> Components: Documentation, Web Site
> Reporter: Queenie Ma
> Assignee: Queenie Ma
>
> The style guide is located in
> [README.md|https://github.com/apache/incubator-quarks-website/blob/master/README.md].
> See QUARKS-153.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)