changeset 358:7b16193bd5db no-hierarchy

~ replace the uuid trick for identifying tuples by a row id counter, so it's predictable
author Alexandre Bertails <bertails@gmail.com>
date Sat, 12 Mar 2011 11:36:46 -0500
parents 0c37406e4268
children 22cc49dbf0e6
files rdb/src/main/scala/RDB.scala
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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
 
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.