Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
titlePartitionStringCncDefinition.scala
borderStylesolid
object PartitionStringCncDefinition {
  def main(args: Array[String]): Unit = {
    ApplicationName("PartitionString")
    TargetPackage("partitionstring")
    TargetDirectory("partitionstring")

    Comment("Item Collections")
    ItemCollection[String, String]("input")
    ItemCollection[String, String]("span")
    ItemCollection[String, String]("results")

    Comment("Tag Collections")
    TagCollection[String]("singletonTagstringTag")
    TagCollection[String]("spanTags")

    Comment("Step Prescriptions")
    Presription("singletonTag", List("createSpan"))
    Presription("spanTags", List("processSpan"))

    Comment("Step Dependences")
    StepDependence("createSpan", List[String]("input"), List("spanTags", "span"))
    StepDependence("processSpan", List[String]("span"), List("results"))

    Comment("Environment Collections")
    EnvironmentDependence(
      List("input", "singletonTagstringTag"),
      List("results")
    )
  }
}

This graph is a little more interesting than the Find-Primes example since it has two Steps: createSpan and processSpan. createSpan produces Items for the span Item Collection. This in turn triggers the prescription of the processSpan step which writes results to the results Item Collection. The environment reads off these values from the results Item Collection.

Diagrammatically, this is how the CnC graph looks: Image Added
(Image from Kathleen Knobe's CnC Tutorial)

Next, run the CnC-Scala translator:

...

Code Block
Contents of Collection'results'
  19=sss
  22=rrrrr
  27=w
  6=bbbbb
HabaneroRuntime: 
  num workers=4
  executor service=jsr166y.ForkJoinPool@647109c4[Terminating, parallelism = 4, size = 4, active = 4, running = 4, steals = 6, tasks = 0, submissions = 0]
  async instances=9
  activity instances=9