Index: trunk/ippToPsps/jython/stackbatch.py
===================================================================
--- trunk/ippToPsps/jython/stackbatch.py	(revision 37763)
+++ trunk/ippToPsps/jython/stackbatch.py	(revision 37917)
@@ -293,5 +293,11 @@
         self.generateRandomIDs()
 
+        self.logger.infoPair("Adding 'row' columns to", "StackObjectThin")
+        self.scratchDb.addRowCountColumn("StackObjectThin", "row")
+        self.logger.infoPair("Adding unique psps ids to", "StackObjectThin")
         self.generateStackDetectRowIDsAndPspsUniqueIDs()
+        self.logger.infoPair("Dropping row column from", "StackObjectThin table")
+        self.scratchDb.dropColumn("StackObjectThin", "row")
+
 
         # add indexes StackObjectThin
@@ -372,4 +378,14 @@
                 self.logger.errorPair('failed sql: ', sql)
                 raise
+
+
+            # we do not yet set bestdetection, this is a placeholder until we do
+            sql = "UPDATE StackObjectThin set bestDetection = 0"
+            try:
+                self.scratchDb.execute(sql)
+            except:
+                self.logger.errorPair('failed sql: ', sql)
+                raise
+
 
         self.tablesToExport.append("StackObjectThin")
@@ -756,5 +772,5 @@
 
         minRadius = 1
-        maxRadius = 10
+        maxRadius = 9
         if tablename == 'StackApFlx':
             minRadius = 3
@@ -765,5 +781,5 @@
 
         sqlLine = sqlUtility("UPDATE " + tablename + " SET")
-        for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:
+        for radius in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
             if radius < minRadius: continue
             if radius > maxRadius: continue
@@ -950,8 +966,10 @@
 
     def generateStackDetectRowIDsAndPspsUniqueIDs(self):
-        sql = "UPDATE StackObjectThin join (select @r:=@r+1 rownum, objID from \
-        (select @r:=0) r, StackObjectThin t) as foo using (objID) set \
-        stackDetectRowID = ((" + str(self.batchID) + " << 32 ) + rownum), \
-        uniquePspsSTid = ((" +str(self.batchID)+ "*1000000000 ) + rownum)";
+#        sql = "UPDATE StackObjectThin join (select @r:=@r+1 rownum, objID from \
+#        (select @r:=0) r, StackObjectThin t) as foo using (objID) set \
+#        stackDetectRowID = ((" + str(self.batchID) + " << 32 ) + rownum), \
+#        uniquePspsSTid = ((" +str(self.batchID)+ "*1000000000 ) + rownum)";
+        sql = "UPDATE StackObjectThin set uniquePspsSTid = (("+str(self.batchID)+"*1000000000 ) + row)"
+
         try: self.scratchDb.execute(sql)
         except:
@@ -1010,5 +1028,5 @@
             self.scratchDb.addColumn(table, filter + "haveData", "tinyint")
 
-        fields = "objID, ippObjID, randomStackObjID, primaryDetection, bestDetection, uniquePspsSTID, "
+        fields = "objID, ippObjID, randomStackObjID, primaryDetection, bestDetection, uniquePspsSTID, StackDetectRowID, "
 
         for i in range(len(self.filters)):
@@ -1016,10 +1034,11 @@
             fields += filter + "ippDetectID, "
             fields += filter + "stackDetectID, "
+#            fields += filter + "StackDetectRowID, " 
             fields += filter + "stackMetaID " # careful here: do not add comma to last entry
             if (i < len(self.filters) - 1):
                 fields += ", "
 
-        if (table == "StackObjectAttributes"):
-            fields += ", stackDetectRowID "
+        #if (table == "StackObjectAttributes"):
+        #    fields += ", stackDetectRowID "
         sql  = "INSERT INTO " + table + " (" + fields + ") "
         sql += "SELECT " + fields + " FROM " + mainTable
