--- a/src/main/scala/RDB2RDFMain.scala Wed Dec 16 18:54:25 2009 -0500
+++ b/src/main/scala/RDB2RDFMain.scala Wed Dec 16 19:02:56 2009 -0500
@@ -13,7 +13,7 @@
case class Enum(relaliasattr:RelAliasAttribute) extends Binding
object RDB2RDF {
- case class R2RState(joined:Set[RelAlias], allVars:List[Var], inConstraint:Set[Var], joins:List[AliasedResource], varmap:Map[Var, SQL2RDFValueMapper], exprs:Set[PrimaryExpression])
+ case class R2RState(joined:Set[RelAlias], allVars:List[Var], inConstraint:Set[Var], joins:Set[AliasedResource], varmap:Map[Var, SQL2RDFValueMapper], exprs:Set[PrimaryExpression])
sealed abstract class SQL2RDFValueMapper(relaliasattr:RelAliasAttribute)
case class StringMapper(relaliasattr:RelAliasAttribute) extends SQL2RDFValueMapper(relaliasattr)
@@ -139,7 +139,7 @@
case false => {
//joins = joins ::: List(Join(AliasedResource(rel,relalias), sconstraint))
joined += relalias
- joins = joins ::: List(AliasedResource(rel,relalias))
+ joins += AliasedResource(rel,relalias)
}
case true =>
}
@@ -180,7 +180,7 @@
joined contains(oRelAlias) match {
case false => {
- joins = joins ::: List(AliasedResource(fkrel,oRelAlias))
+ joins += AliasedResource(fkrel,oRelAlias)
joined = joined + oRelAlias
}
case true => {
@@ -272,7 +272,7 @@
Set[RelAlias](),
List[Var](),
Set[Var](),
- List[AliasedResource](),
+ Set[AliasedResource](),
Map[Var, SQL2RDFValueMapper](),
Set[PrimaryExpression]()
)
--- a/src/main/scala/SQL.scala Wed Dec 16 18:54:25 2009 -0500
+++ b/src/main/scala/SQL.scala Wed Dec 16 19:02:56 2009 -0500
@@ -12,7 +12,7 @@
case class AttrAlias(n:Name)
case class Relation(n:Name)
case class RelAlias(n:Name)
-case class TableList(joins:List[AliasedResource])
+case class TableList(joins:Set[AliasedResource])
case class AliasedResource(rel:Relation, as:RelAlias)
case class Expression(conjuncts:Set[PrimaryExpression])
sealed abstract class PrimaryExpression
@@ -84,7 +84,7 @@
"""[a-zA-Z_]\w*""".r ^^ { x => RelAlias(Name(x)) }
def tablelist:Parser[TableList] =
- repsep(aliasedjoin, "INNER" ~ "JOIN") ^^ { TableList(_) }
+ repsep(aliasedjoin, "INNER" ~ "JOIN") ^^ { m => TableList(m.toSet) }
def aliasedjoin:Parser[AliasedResource] =
relation ~ "AS" ~ relalias ^^
--- a/src/test/scala/SQLTest.scala Wed Dec 16 18:54:25 2009 -0500
+++ b/src/test/scala/SQLTest.scala Wed Dec 16 19:02:56 2009 -0500
@@ -19,7 +19,7 @@
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_manager")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_managName"))))),
- TableList(List(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
+ TableList(Set(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))))),
Expression(Set(
PrimaryExpressionEq(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))),
@@ -39,7 +39,7 @@
val expected = Select(AttributeList(List(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(List(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))))),
+ TableList(Set(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))))),
Expression(Set(PrimaryExpressionEq(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))),
RValueTyped(SQLDatatype.INTEGER,Name("18"))),
PrimaryExpressionNotNull(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("lastName")))))))
@@ -57,7 +57,7 @@
val expected = Select(AttributeList(List(NamedAttribute(RelAliasAttribute(RelAlias(Name("R_emp")),
Attribute(Name("lastName"))),
AttrAlias(Name("A_empName"))))),
- TableList(List(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
+ TableList(Set(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))))),
Expression(Set(PrimaryExpressionEq(RelAliasAttribute(RelAlias(Name("R_emp")),Attribute(Name("manager"))),
RValueAttr(RelAliasAttribute(RelAlias(Name("R_manager")),Attribute(Name("id"))))),
@@ -86,7 +86,7 @@
AttrAlias(Name("A_empName"))),
NamedAttribute(RelAliasAttribute(RelAlias(Name("R_grandManager")),Attribute(Name("lastName"))),
AttrAlias(Name("A_grandManagName"))))),
- TableList(List(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
+ TableList(Set(AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_emp"))),
AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_lower"))),
AliasedResource(Relation(Name("Employee")),RelAlias(Name("R_manager"))),
AliasedResource(Relation(Name("Manage")),RelAlias(Name("R_upper"))),