-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extend demo pipeline with square
- Loading branch information
Showing
9 changed files
with
100 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@prefix jvm: <https://w3id.org/conn/jvm#>. | ||
@prefix fno: <https://w3id.org/function/ontology#>. | ||
@prefix fnom: <https://w3id.org/function/vocabulary/mapping#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix owl: <http://www.w3.org/2002/07/owl#>. | ||
@prefix : <https://w3id.org/conn#>. | ||
@prefix sh: <http://www.w3.org/ns/shacl#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
|
||
<> owl:imports <../pipeline.ttl>. | ||
|
||
jvm:Square a jvm:Processor; | ||
jvm:file <../sources/Square.java>; | ||
jvm:language "Java". | ||
|
||
[] a sh:NodeShape; | ||
sh:targetClass jvm:Square; | ||
sh:property [ | ||
sh:path jvm:input; | ||
sh:name "input"; | ||
sh:class jvm:ChannelReader; | ||
sh:minCount 1; | ||
sh:maxCount 1; | ||
], [ | ||
sh:path jvm:output; | ||
sh:name "output"; | ||
sh:class jvm:ChannelWriter; | ||
sh:minCount 1; | ||
sh:maxCount 1; | ||
]; | ||
sh:closed true; | ||
sh:ignoredProperties (rdf:type). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import bridge.Reader; | ||
import bridge.Writer; | ||
import java.util.Map; | ||
|
||
import technology.idlab.logging.Log; | ||
import technology.idlab.runner.Processor; | ||
|
||
public class Square extends Processor { | ||
// Channels | ||
private final Reader reader; | ||
private final Writer writer; | ||
|
||
public Square(Map<String, Object> args) { | ||
// Call super constructor. | ||
super(args); | ||
|
||
// Channels | ||
this.reader = this.getArgument("input"); | ||
this.writer = this.getArgument("output"); | ||
} | ||
|
||
public void exec() { | ||
while (true) { | ||
Reader.Result data = reader.readSync(); | ||
|
||
if (data.isClosed()) { | ||
break; | ||
} | ||
|
||
int value = Integer.parseInt(new String(data.getValue())); | ||
int square = value * value; | ||
byte[] result = Integer.toString(square).getBytes(); | ||
|
||
log.info(value + " * " + value + " = " + square); | ||
writer.pushSync(result); | ||
} | ||
writer.close(); | ||
} | ||
} |