Skip to content

Commit

Permalink
First plugin support.
Browse files Browse the repository at this point in the history
  • Loading branch information
vjovanov committed Jul 7, 2014
1 parent f4cc750 commit 7d2dbcf
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 312 deletions.
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ scalaVersion := "2.11.1"

libraryDependencies += "org.scala-lang" % "scala-reflect" % "2.11.1"

scalacOptions += "-language:postfixOps"

scalacOptions += "-language:implicitConversions"

scalacOptions += "-deprecation"

scalacOptions += "-optimise"

scalacOptions += "-Yinline-warnings"

unmanagedJars in Compile <<= baseDirectory map { base => (base ** "*.jar").classpath }

// there is a bug in SBT that does not allow compiler plugins to have dependencies
addCommandAlias("embed", ";clean ;legolifter/run ;project lego-core ;set scalacOptions ++= Seq(s\"-Xplugin:${System.getProperty(\"user.home\")}/.ivy2/local/ch.epfl.data/autolifter_2.11/0.1-SNAPSHOT/jars/autolifter_2.11.jar:${System.getProperty(\"user.home\")}/.ivy2/local/ch.epfl.lamp/yy-core_2.11/0.1-SNAPSHOT/jars/yy-core_2.11.jar:${System.getProperty(\"user.home\")}/.ivy2/local/ch.epfl.lamp/yin-yang_2.11/0.1-SNAPSHOT/jars/yin-yang_2.11.jar\"); compile; set scalacOptions := Seq(); project root; clean")
1 change: 1 addition & 0 deletions generator-out/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.scala
51 changes: 26 additions & 25 deletions lego/src/main/scala/LegoBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,32 @@ object MiniDB extends storagemanager.Loader with Queries {
else args.tail.toList
for (q <- queries) {
currQuery = q
Console.setOut(new PrintStream(getOutputName))
currQuery match {
case "Q1" => Q1(numRuns)
// case "Q2" => Q2(numRuns)
case _ => throw new Exception("Query not supported!")
}
// Check results
if (Config.checkResults) {
if (new java.io.File(getResultFileName).exists) {
val resq = scala.io.Source.fromFile(getOutputName).mkString
val resc = {
val str = scala.io.Source.fromFile(getResultFileName).mkString
str * numRuns
}
if (resq != resc) {
System.out.println("-----------------------------------------")
System.out.println("QUERY" + q + " DID NOT RETURN CORRECT RESULT!!!")
System.out.println("Correct result:")
System.out.println(resc)
System.out.println("Result obtained from execution:")
System.out.println(resq)
System.out.println("-----------------------------------------")
System.exit(0)
} else System.out.println("CHECK RESULT FOR QUERY " + q + ": [OK]")
} else System.out.println("Reference result file not found. Skipping checking of result")
Console.withOut(new PrintStream(getOutputName)) {
currQuery match {
case "Q1" => Q1(numRuns)
// case "Q2" => Q2(numRuns)
case _ => throw new Exception("Query not supported!")
}
// Check results
if (Config.checkResults) {
if (new java.io.File(getResultFileName).exists) {
val resq = scala.io.Source.fromFile(getOutputName).mkString
val resc = {
val str = scala.io.Source.fromFile(getResultFileName).mkString
str * numRuns
}
if (resq != resc) {
System.out.println("-----------------------------------------")
System.out.println("QUERY" + q + " DID NOT RETURN CORRECT RESULT!!!")
System.out.println("Correct result:")
System.out.println(resc)
System.out.println("Result obtained from execution:")
System.out.println(resq)
System.out.println("-----------------------------------------")
System.exit(0)
} else System.out.println("CHECK RESULT FOR QUERY " + q + ": [OK]")
} else System.out.println("Reference result file not found. Skipping checking of result")
}
}
}
}
Expand Down
29 changes: 22 additions & 7 deletions lego/src/main/scala/queryengine/volcano/Operators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@ import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.HashMap
import scala.collection.mutable.Set
import GenericEngine._
import ch.epfl.data.autolifter.annotations.{ deep, metadeep }

abstract class Operator[+A: Manifest] {
// This is a temporary solution until we introduce dependency management and adopt policies. Not a priority now!
@metadeep(
"legocompiler/src/main/scala/ch/epfl/data/legobase/deep",
"""
package ch.epfl.data
package legobase
package deep
import scalalib._
import pardis.ir._
""",
"""OperatorsComponent""")
class MetaInfo

@deep abstract class Operator[+A: Manifest] {
def open()
def next(): A
def close()
Expand Down Expand Up @@ -37,7 +52,7 @@ abstract class Operator[+A: Manifest] {
def NullDynamicRecord[D: Manifest] = null.asInstanceOf[D]
}

case class ScanOp[A: Manifest](table: Array[A]) extends Operator[A] {
@deep case class ScanOp[A: Manifest](table: Array[A]) extends Operator[A] {
var i = 0
def open() {}
def next() = {
Expand All @@ -51,14 +66,14 @@ case class ScanOp[A: Manifest](table: Array[A]) extends Operator[A] {
def reset() { i = 0 }
}

case class SelectOp[A: Manifest](parent: Operator[A])(selectPred: A => Boolean) extends Operator[A] {
@deep case class SelectOp[A: Manifest](parent: Operator[A])(selectPred: A => Boolean) extends Operator[A] {
def open() = { parent.open; }
def next() = parent findFirst selectPred
def close() = {}
def reset() { parent.reset }
}

case class AggOp[A: Manifest, B: Manifest](parent: Operator[A], numAggs: Int)(val grp: A => B)(val aggFuncs: Function2[A, Double, Double]*) extends Operator[AGGRecord[B]] {
@deep case class AggOp[A: Manifest, B: Manifest](parent: Operator[A], numAggs: Int)(val grp: A => B)(val aggFuncs: Function2[A, Double, Double]*) extends Operator[AGGRecord[B]] {
val mA = manifest[A]
val mB = manifest[B]

Expand Down Expand Up @@ -90,7 +105,7 @@ case class AggOp[A: Manifest, B: Manifest](parent: Operator[A], numAggs: Int)(va
def reset() { parent.reset; hm.clear; open }
}

case class SortOp[A: Manifest](parent: Operator[A])(orderingFunc: Function2[A, A, Int]) extends Operator[A] {
@deep case class SortOp[A: Manifest](parent: Operator[A])(orderingFunc: Function2[A, A, Int]) extends Operator[A] {
val sortedTree = new scala.collection.mutable.TreeSet()(
new Ordering[A] {
def compare(o1: A, o2: A) = orderingFunc(o1, o2)
Expand All @@ -111,7 +126,7 @@ case class SortOp[A: Manifest](parent: Operator[A])(orderingFunc: Function2[A, A
}

// Limited version of map -- touches data in place and does not create new data
case class MapOp[A: Manifest](parent: Operator[A])(aggFuncs: Function1[A, Unit]*) extends Operator[A] {
@deep case class MapOp[A: Manifest](parent: Operator[A])(aggFuncs: Function1[A, Unit]*) extends Operator[A] {
def open() = { parent.open; }
def next() = {
val t: A = parent.next
Expand All @@ -124,7 +139,7 @@ case class MapOp[A: Manifest](parent: Operator[A])(aggFuncs: Function1[A, Unit]*
def reset { parent.reset }
}

case class PrintOp[A: Manifest](var parent: Operator[A])(printFunc: A => Unit, limit: () => Boolean = () => true) extends Operator[A] {
@deep case class PrintOp[A: Manifest](var parent: Operator[A])(printFunc: A => Unit, limit: () => Boolean = () => true) extends Operator[A] {
var numRows = 0
def open() = { parent.open; }
def next() = {
Expand Down
2 changes: 1 addition & 1 deletion lego/src/main/scala/storagemanager/Loader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ trait Loader {

def fileLineCount(file: String) = {
import scala.sys.process._;
Integer.parseInt((("wc -l " + file) #| "awk {print($1)}" !!).replaceAll("\\s+$", ""))
Integer.parseInt(((("wc -l " + file) #| "awk {print($1)}").!!).replaceAll("\\s+$", ""))
}

def loadRegion() = {
Expand Down
Loading

0 comments on commit 7d2dbcf

Please sign in to comment.