You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/12/05 16:20:33 UTC

[streampipes-website] 02/02: Add missing field extraction to processor tutorial (apache/streampipes#800)

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes-website.git

commit d202889377453d6962e0cd0460b39e08c963d9da
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Sun Dec 4 20:20:58 2022 +0100

    Add missing field extraction to processor tutorial (apache/streampipes#800)
---
 documentation/docs/06_extend-tutorial-data-processors.md | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/documentation/docs/06_extend-tutorial-data-processors.md b/documentation/docs/06_extend-tutorial-data-processors.md
index 408159b8..b4be1dbb 100644
--- a/documentation/docs/06_extend-tutorial-data-processors.md
+++ b/documentation/docs/06_extend-tutorial-data-processors.md
@@ -183,8 +183,8 @@ Once users start a pipeline that uses our geofencing component, the _onInvocatio
 Next, we are interested in the fields of the input event stream that contains the latitude and longitude value we would like to compute against the geofence center location as follows:
 
 ```java
-String latitudeFieldName = extractor.mappingPropertyValue("latitude-field");
-String longitudeFieldName = extractor.mappingPropertyValue("longitude-field");
+String latitudeFieldName = parameters.extractor().mappingPropertyValue("latitude-field");
+String longitudeFieldName = parameters.extractor().mappingPropertyValue("longitude-field");
 ```
 
 We use the same `internalId` we've used to define the mapping property requirements in the `declareModel` method.
@@ -232,6 +232,9 @@ public class GeofencingProcessor extends StreamPipesDataProcessor {
 
  private float centerLatitude;
  private float centerLongitude;
+ private String latitudeFieldName;
+ private String longitudeFieldName;
+ 
  private int radius;
 
  @Override
@@ -257,9 +260,13 @@ public class GeofencingProcessor extends StreamPipesDataProcessor {
  }
 
  @Override
- public void onInvocation(ProcessorParams parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
+ public void onInvocation(ProcessorParams parameters, 
+                          SpOutputCollector spOutputCollector, 
+                          EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException {
   this.centerLatitude = parameters.extractor().singleValueParameter(LATITUDE_CENTER, Float.class);
   this.centerLongitude = parameters.extractor().singleValueParameter(LONGITUDE_CENTER, Float.class);
+  this.latitudeFieldName = parameters.extractor().mappingPropertyValue("latitude-field");
+  this.longitudeFieldName = parameters.extractor().mappingPropertyValue("longitude-field");
   this.radius = parameters.extractor().singleValueParameter("radius", Integer.class);
  }