Sparkwave is available as open-source project on Github and licensed under GPL license. To compile and run the software the following requirements need to be fulfilled:
Prerequisite:
- Git 1.7.x+
- Java Development Kit 6+
- Maven 3.x+
In the following all steps required to compile, run and test the software are described:
-
Get the source code: The source code can be retrieved from the Github repository using git. After cloning the repository change to the created directory “Sparkwave”.
$ git clone https://github.com/rogger/Sparkwave/
$ cd Sparkwave
-
Compile: Switch to the folder “spark-project” and execute the maven command as listed. Maven installs all dependencies, compiles the source code and packages Sparkwave into a single jar file. After completion, the Sparkwave package can be found in the folder spark-distribution/target/.
$ cd spark-project
$ mvn clean install package
-
Run: Sparkwave can be started with the script “spark.sh”, it is mandatory to supply a pattern file. Optional input arguments is the path to the configuration file. In the configuration file the port for the socket Sparkwave is specified. The pre-processing plugins can also be specified in the configuration file. In the following an example is listed that starts Sparkwave using the pattern “pattern-PT1-TW100.tpg”.
$ sh spark.sh $PWD/bsbm/pattern-PT1-TW100.tpg
-
Test: Sparkwave accepts streams of N3 triples. The script “spark-stream.sh” reads a file and sents the stream to localhost with the specified port. In the listed example “offers-trunc100.nt” is streamed to localhost:8080.
$ sh spark-streamer.sh 8080 $PWD/bsbm/offers-trunc100.nt
The example pattern should match 9 times, the results are written to the output console (console handler) of Sparkwave.
A single Sparkwave pattern can configure a number of handlers dedicated to further process pattern matches. A handler configuration is declared in a HANDLERS section of a pattern, where each handler is represented with a HANLDER entry (see Listing). Each handler, if needed, expects a list of configuration parameters in the form of key-pair values through which a handler is configured. Configuration parameters are specific for a specific handler type but one parameter is shared across all handlers - "class" parameter. The parameter instructs Sparkwave engine which Java class (implementing the interface at.sti2.spark.handler.SparkwaveHandler) to instantiate for a specific handler. The interface is given in the Listing.
package at.sti2.spark.handler;
import at.sti2.spark.core.solution.Match;
import at.sti2.spark.grammar.pattern.Handler;
public interface SparkwaveHandler {
public void init(Handler invokerProperties) throws SparkwaveHandlerException;
public void invoke(Match match) throws SparkwaveHandlerException;
}