IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35777 for trunk/Ohana


Ignore:
Timestamp:
Jul 5, 2013, 5:59:12 PM (13 years ago)
Author:
eugene
Message:

check that the buffer contains new detections for insertion

Location:
trunk/Ohana/src/dvopsps/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps.c

    r35416 r35777  
    233233
    234234  int status = TRUE;
     235  int Ninsert = 0;
    235236
    236237  gettimeofday (&start, (void *) NULL);
     
    239240    // XXX check return status
    240241    insert_detections_mysql_detvalue (&buffer, &detections[i]);
     242    Ninsert ++;
    241243    if (buffer.Nbuffer > MAX_BUFFER) {
    242244      if (!insert_detections_mysql_commit (&buffer, mysql)) {
     
    247249      bzero (buffer.buffer, buffer.Nalloc);
    248250      insert_detections_mysql_init (&buffer);
    249     }
    250   }
    251   if (!insert_detections_mysql_commit (&buffer, mysql)) {
    252     fprintf (stderr, "failure to insert detections in mysql (commit 2)\n");
    253     status = FALSE;
     251      Ninsert = 0;
     252    }
     253  }
     254  if (Ninsert > 0) {
     255    // insert the remaining detections loaded in the buffer
     256    if (!insert_detections_mysql_commit (&buffer, mysql)) {
     257      fprintf (stderr, "failure to insert detections in mysql (commit 2)\n");
     258      status = FALSE;
     259    }
    254260  }
    255261  FreeIOBuffer (&buffer);
  • trunk/Ohana/src/dvopsps/src/insert_detections_dvopsps_catalog.c

    r35578 r35777  
    104104  insert_detections_mysql_init (&buffer);
    105105  int Ninsert = 0;
     106  int Ntotal = 0;
    106107
    107108  int status = TRUE;
     
    125126        status = FALSE;
    126127      }
     128      Ninsert ++;
     129      Ntotal ++;
    127130
    128131      if (buffer.Nbuffer > MAX_BUFFER) {
     
    141144        insert_detections_mysql_init (&buffer);
    142145      }
    143 
    144       Ninsert ++;
    145146      found ++;
    146147    }
    147148  }
    148   if (!insert_detections_mysql_commit (&buffer, mysql)) {
    149     fprintf (stderr, "failure to insert detections in mysql (commit)\n");
    150     status = FALSE;
     149  if (Ninsert > 0) {
     150    // insert the remaining detections loaded in the buffer
     151    if (!insert_detections_mysql_commit (&buffer, mysql)) {
     152      fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     153      status = FALSE;
     154    }
    151155  }
    152156 
    153   if (VERBOSE) fprintf (stderr, "inserted %d rows\n", Ninsert);
     157  if (VERBOSE) fprintf (stderr, "inserted %d rows\n", Ntotal);
    154158  FreeIOBuffer (&buffer);
    155159
     
    169173  }
    170174
    171   PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n");
     175  // PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, photcode, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n");
     176  PrintIOBuffer (buffer, "INSERT INTO dvoDetectionFull (imageID, ippDetectID, detectID, ippObjID, objID, flags, zp, zpErr, airMass, expTime, ra, dec_, raErr, decErr) VALUES \n");
    172177
    173178  return TRUE;
     
    188193  // ((uint64_t)average->catID << 32) + (uint64_t)average->objID, // ippObjID
    189194  PrintIOBuffer (buffer, "%lu, ", average->extID);        // objID
    190   PrintIOBuffer (buffer, "%d, ", measure->photcode);      // photcode
     195  // XXX PrintIOBuffer (buffer, "%d, ", measure->photcode);       // photcode
    191196  PrintIOBuffer (buffer, "%u, ", measure->dbFlags);       // flags
    192197
     
    221226  } else {
    222227    fprintf (stderr, "invalid sql?\n");
     228    int Nstart = MAX(0, buffer->Nbuffer - 3000);
     229    fprintf (stderr, "buffer: ...%s...\n", &buffer->buffer[Nstart]);
    223230    return FALSE;
    224231  }
Note: See TracChangeset for help on using the changeset viewer.