Fix for TPC-H Q2 not reaching a fix point
parent
25a138139a
commit
e80013d96d
|
@ -37,6 +37,7 @@ object Generate
|
|||
|import org.apache.spark.sql.catalyst.plans.logical._
|
||||
|import org.apache.spark.sql.catalyst.expressions._
|
||||
|import com.astraldb.catalyst.SparkMethods._
|
||||
|import scala.collection.mutable
|
||||
|""".stripMargin)
|
||||
of.write(content)
|
||||
of.close()
|
||||
|
|
|
@ -12,6 +12,6 @@ object Optimizer
|
|||
|
||||
def bdd(family: Type.AST): String =
|
||||
{
|
||||
scala.Optimizer(Seq(s"${family.scalaType}BDD"), s"${family.scalaType}BDDOptimizer").toString
|
||||
scala.BDDOptimizer(Seq(s"${family.scalaType}BDD"), s"${family.scalaType}BDDOptimizer").toString
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
@import com.astraldb.spec.Definition
|
||||
|
||||
@(rules: Seq[String], clazz: String = "Optimizer")
|
||||
|
||||
object @clazz
|
||||
{
|
||||
val rules = Seq[Rule[LogicalPlan]](
|
||||
@for(rule <- rules){ @rule ,
|
||||
}
|
||||
)
|
||||
|
||||
def MAX_ITERATIONS = 100
|
||||
|
||||
def rewrite(plan: LogicalPlan): (LogicalPlan, Int) =
|
||||
{
|
||||
var current = plan
|
||||
var last = plan
|
||||
|
||||
val hashPlanSet = mutable.Set[Int]()
|
||||
|
||||
hashPlanSet.add(plan.hashCode)
|
||||
for(i <- 0 until MAX_ITERATIONS)
|
||||
{
|
||||
for(rule <- rules)
|
||||
{
|
||||
current = rule(current)
|
||||
if(!hashPlanSet.add(current.hashCode))
|
||||
{
|
||||
return (current, i+1)
|
||||
}
|
||||
}
|
||||
if(last.fastEquals(current))
|
||||
{
|
||||
return (current, i+1)
|
||||
}
|
||||
last = current
|
||||
}
|
||||
return (current, MAX_ITERATIONS)
|
||||
}
|
||||
}
|
10
docs/LANG.md
10
docs/LANG.md
|
@ -1 +1,9 @@
|
|||
# ASTral Language Specification
|
||||
# Compiling and runing ASTral
|
||||
1. Set JAVA_HOME correctly:
|
||||
echo $JAVA_HOME
|
||||
echo $(/usr/libexec/java_home)
|
||||
export JAVA_HOME=$(/usr/libexec/java_home)
|
||||
2. mill clean
|
||||
3. mill astral.catalyst.impl.compile
|
||||
4. To run TPCH tests: mill astral.catalyst.impl.runMain com.astraldb.catalyst.TPCHTest
|
||||
# ASTral Language Specification
|
Loading…
Reference in New Issue