Sample Pipeline
HereThe point of this pipeline is some sample codeto read a set of suchcoordinates from a CSV (into String raw) and pass the string through a pipeline being constructedthat will parse the string, cluster the points, and plot the clusters. The classescluster data and plot images are extracted from the pipeline after it is run.
The string is parsed into a collection of PointExtractorPoint, objects at the PointClusterer"ExtractPoints", and stage. That collection is clustered/segmented into a set of ClusterPlotterCluster all inherit fromobjects at the Stage"ClusterPoints" stage. The StageTunerPoint takes the class of theand StageCluster data is used to tune and implementsplot the above feedback looppoints visually into a Plot image object at the "PlotClusters" stage.
... QueuedPipeline pipeline = new QueuedPipeline() String raw = readFile("points.csv") pipeline.setInput(raw) <-- raw is an InputObject taken as input elsewhere // addStage() takes the name of the stage, the stage runner, and the names of the stages it needs results from pipeline.addStage("ExtractPoints", new StageRunnerStageTuner(PointExtractor, ), []) pipeline.addStage("ClusterPoints", new StageRunnerStageTuner(PointClusterer), ["ExtractPoints"]) pipeline.addStage("PlotClusters", new StageRunnerStageTuner(ClusterPlotter), ["ExtractPoints", "ClusterPoints"]) // tune and execute each stage with the StageRunnersStageTuners PipelineResultList results = pipeline.run() // pipeline is done, collect the interesting results Result someResultpointClusters = results.getResult(1"ClusterPoints") Result anotherResultclusterPlot = results.getResult(4"PlotClusters") saveResultFilesaveClusterFile(someResult, anotherResultpointClusters) saveCllusterPlotImage(clusterPlot) - The classes
PointExtractor,PointClusterer, andClusterPlotterall inherit fromStage. - Each
StageTunertakes the class of theStageto tune and implements the above feedback loop. - Variables
pointClustersandclusterPlotsare ofResulttype
Problem
SimplyBut simply passing around classes for construction is a headache in some languages. Also, I'm not really sure how to generically construct and set parameters of each Stage subclass because of the different number/type of parameters - perhaps each Stage subclass needs a corresponding StageRunner subclass. Finally, casting Result objects to the type I need within the final two functions sounds dangerous. ...but these are just symptoms of my real problem: This is all starting to get complex and fuzzy for what I expected to be a straightforward problem.