~ replace the uuid trick for identifying tuples by a row id counter, so it's predictable no-hierarchy
authorAlexandre Bertails <bertails@gmail.com>
Sat, 12 Mar 2011 11:36:46 -0500
branchno-hierarchy
changeset 358 7b16193bd5db
parent 357 0c37406e4268
child 359 22cc49dbf0e6
~ replace the uuid trick for identifying tuples by a row id counter, so it's predictable
rdb/src/main/scala/RDB.scala
--- a/rdb/src/main/scala/RDB.scala	Sat Mar 12 11:35:43 2011 -0500
+++ b/rdb/src/main/scala/RDB.scala	Sat Mar 12 11:36:46 2011 -0500
@@ -40,10 +40,13 @@
 		      candidates:List[CandidateKey],
 		      pk:Option[CandidateKey],
 		      fks:ForeignKeys) {
+    var rowCounter = 0
     for {
       t <- body
     } {
       t._relation = Some(this)
+      rowCounter = rowCounter + 1
+      t.rowId = rowCounter
     }
 
     /** adds a tuple in the body of the relation */
@@ -74,12 +77,9 @@
    * this has to be retrieved from the relation
    * especially, the order of the attribute names is not known within the tuple
    */
-  case class Tuple(private val m:Map[AttrName, CellValue]) extends PartialFunction[AttrName, CellValue] {
-
-    // quick hack just for comparing tuples by reference
-    private val uuid:java.util.UUID = java.util.UUID.randomUUID()
-    override def equals(other:Any) = other.isInstanceOf[Tuple] && uuid.equals(other.asInstanceOf[Tuple].uuid)
-    override def hashCode = uuid.hashCode
+  case class Tuple(private val m:Map[AttrName, CellValue],
+                   var rowId:Int = scala.util.Random.nextInt())
+  extends PartialFunction[AttrName, CellValue] {
 
     override def toString = m.toString