Changeset 26236 for branches/eam_branches/20091113/ippTools/src/difftool.c
- Timestamp:
- Nov 20, 2009, 4:13:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091113/ippTools/src/difftool.c
r25851 r26236 95 95 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 96 96 MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileMode); 97 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode);98 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode);97 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode); 98 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 99 99 100 100 default: … … 210 210 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 211 211 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 212 212 213 213 // Copy of my hacky work around from stacktool.c 214 214 if ((state)&&(diff_id)) { … … 383 383 } 384 384 385 psString whereClause = NULL;385 psString whereClause = psStringCopy(""); 386 386 if (psListLength(where->list)) { 387 387 whereClause = psDBGenerateWhereConditionSQL(where, NULL); 388 psStringPrepend(&whereClause, "\n AND");388 psStringPrepend(&whereClause, "\n WHERE "); 389 389 } 390 390 psFree(where); 391 391 392 392 // Add condition to get only templates or only inputs 393 psString templateClause = psStringCopy(""); 393 394 { 394 psString templateClause = NULL;395 395 if (template) { 396 psStringAppend(&templateClause, " %s", " template != 0");396 psStringAppend(&templateClause, "\n WHERE %s", " template != 0"); 397 397 } else if (input) { 398 psStringAppend(&templateClause, " %s", " template = 0"); 399 } 400 if (templateClause) { 401 psStringAppend(&whereClause, "\n AND %s", templateClause); 402 } 403 psFree(templateClause); 398 psStringAppend(&templateClause, "\n WHERE %s", " template = 0"); 399 } 404 400 } 405 401 … … 412 408 } 413 409 414 if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause, whereClause, whereClause)) { 415 psError(PS_ERR_UNKNOWN, false, "database error"); 410 if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause, whereClause, whereClause, templateClause)) { 411 psError(PS_ERR_UNKNOWN, false, "database error"); 412 psFree(templateClause); 416 413 psFree(whereClause); 417 414 psFree(query); 418 415 return false; 419 416 } 417 psFree(templateClause); 420 418 psFree(whereClause); 421 419 psFree(query); … … 816 814 psMetadata *where = psMetadataAlloc(); 817 815 PXOPT_COPY_S64(config->args, where, "-diff_id", "diffSkyfile.diff_id", "=="); 816 PXOPT_COPY_STR(config->args, where, "-skycell_id", "diffSkyfile.skycell_id", "=="); 818 817 PXOPT_COPY_STR(config->args, where, "-label", "diffRun.label", "=="); 819 818 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); … … 914 913 if (magicked) { 915 914 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 916 915 917 916 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 918 917 psError(PS_ERR_UNKNOWN, false, … … 923 922 else { 924 923 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 925 924 926 925 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 927 926 psError(PS_ERR_UNKNOWN, false, … … 930 929 } 931 930 } 932 931 933 932 return true; 934 933 } … … 948 947 if (!p_psDBRunQueryF(config->dbh,query,state,label)) { 949 948 psError(PS_ERR_UNKNOWN, false, 950 "failed to change state for label %s", label);949 "failed to change state for label %s", label); 951 950 return(false); 952 951 } … … 1138 1137 1139 1138 psMetadata *expWhere = psMetadataAlloc(); 1140 psMetadata *warpWhere = psMetadataAlloc(); 1139 psMetadata *warp1Where = psMetadataAlloc(); // First set of restrictions on warp 1140 psMetadata *warp2Where = psMetadataAlloc(); // Second set of restriction on warp 1141 1141 psMetadata *stackWhere = psMetadataAlloc(); 1142 1142 1143 1143 PXOPT_COPY_S64(config->args, expWhere, "-exp_id", "exp_id", "=="); 1144 1144 PXOPT_COPY_STR(config->args, expWhere, "-filter", "filter", "=="); 1145 PXOPT_COPY_S64(config->args, warpWhere, "-warp_id", "warpRun.warp_id", "=="); 1146 PXOPT_COPY_STR(config->args, warpWhere, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1147 PXOPT_COPY_STR(config->args, warpWhere, "-tess_id", "warpRun.tess_id", "=="); 1148 PXOPT_COPY_STR(config->args, warpWhere, "-warp_label", "warpRun.label", "=="); 1149 PXOPT_COPY_F32(config->args, warpWhere, "-good_frac", "warpSkyfile.good_frac", ">="); 1145 PXOPT_COPY_S64(config->args, warp1Where, "-warp_id", "warpRun.warp_id", "=="); 1146 PXOPT_COPY_STR(config->args, warp1Where, "-warp_label", "warpRun.label", "=="); 1147 PXOPT_COPY_STR(config->args, warp1Where, "-tess_id", "warpRun.tess_id", "=="); 1148 PXOPT_COPY_S64(config->args, warp2Where, "-warp_id", "warpRun.warp_id", "=="); 1149 PXOPT_COPY_STR(config->args, warp2Where, "-tess_id", "warpRun.tess_id", "=="); 1150 PXOPT_COPY_STR(config->args, warp2Where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1151 PXOPT_COPY_STR(config->args, warp2Where, "-warp_label", "warpRun.label", "=="); 1152 PXOPT_COPY_F32(config->args, warp2Where, "-good_frac", "warpSkyfile.good_frac", ">="); 1150 1153 PXOPT_COPY_STR(config->args, stackWhere, "-stack_label", "stackRun.label", "=="); 1151 1154 … … 1171 1174 } 1172 1175 1173 psString warpQuery = NULL; 1176 psString warp1Query = NULL; 1177 psString warp2Query = NULL; 1174 1178 psString stackQuery = NULL; 1175 1179 psString expQuery = NULL; … … 1183 1187 } 1184 1188 psFree(expWhere); 1185 if (psListLength(warp Where->list)) {1186 psString whereClause = psDBGenerateWhereConditionSQL(warp Where, NULL);1187 psStringAppend(&warp Query, "\n AND %s", whereClause);1189 if (psListLength(warp1Where->list)) { 1190 psString whereClause = psDBGenerateWhereConditionSQL(warp1Where, NULL); 1191 psStringAppend(&warp1Query, "\n AND %s", whereClause); 1188 1192 psFree(whereClause); 1189 1193 } else { 1190 warpQuery = psStringCopy("\n"); 1191 } 1192 psFree(warpWhere); 1193 1194 if (!available) { 1195 // diff what's available, even if warp run has some faults and is incomplete 1196 psStringAppend(&warpQuery, " AND warpRun.state = 'full'"); 1197 } 1194 warp1Query = psStringCopy("\n"); 1195 } 1196 psFree(warp1Where); 1197 if (psListLength(warp2Where->list)) { 1198 psString whereClause = psDBGenerateWhereConditionSQL(warp2Where, NULL); 1199 psStringAppend(&warp2Query, "\n AND %s", whereClause); 1200 psFree(whereClause); 1201 } else { 1202 warp2Query = psStringCopy("\n"); 1203 } 1204 psFree(warp2Where); 1198 1205 1199 1206 // don't queue for exposures that have already been diff'd unless requested … … 1214 1221 psFree(stackWhere); 1215 1222 1216 psTrace("difftool", 1, query, warp Query, diffQuery, expQuery, stackQuery);1223 psTrace("difftool", 1, query, warp1Query, warp2Query, diffQuery, expQuery, stackQuery); 1217 1224 1218 1225 if (!psDBTransaction(config->dbh)) { … … 1221 1228 } 1222 1229 1223 if (!p_psDBRunQueryF(config->dbh, query, warp Query, expQuery, diffQuery)) {1230 if (!p_psDBRunQueryF(config->dbh, query, warp1Query, warp2Query, expQuery, diffQuery)) { 1224 1231 psError(PS_ERR_UNKNOWN, false, "database error"); 1225 1232 psFree(query); … … 1281 1288 return false; 1282 1289 } 1290 psFree(warp1Query); 1283 1291 psFree(query); 1284 1292 query = NULL; … … 1312 1320 if (!p_psDBRunQuery(config->dbh, "DELETE FROM skycellsToDiff")) { 1313 1321 psError(PS_ERR_UNKNOWN, false, "database error"); 1314 psFree(warp Query);1322 psFree(warp2Query); 1315 1323 psFree(stackQuery); 1316 1324 psFree(skycell_query); … … 1323 1331 if (!mdok) { 1324 1332 psError(PXTOOLS_ERR_PROG, false, "warp_id not found --- ignoring row %ld", i); 1325 psFree(warp Query);1333 psFree(warp2Query); 1326 1334 psFree(stackQuery); 1327 1335 psFree(skycell_query); … … 1334 1342 if (!mdok) { 1335 1343 psError(PXTOOLS_ERR_PROG, false, "skycell_count not found"); 1336 psFree(warp Query);1344 psFree(warp2Query); 1337 1345 psFree(stackQuery); 1338 1346 psFree(skycell_query); … … 1345 1353 if (!mdok) { 1346 1354 psError(PXTOOLS_ERR_PROG, false, "tess_id not found"); 1347 psFree(warp Query);1355 psFree(warp2Query); 1348 1356 psFree(stackQuery); 1349 1357 psFree(skycell_query); … … 1356 1364 if (!mdok) { 1357 1365 psError(PXTOOLS_ERR_PROG, false, "filter not found"); 1358 psFree(warp Query);1366 psFree(warp2Query); 1359 1367 psFree(stackQuery); 1360 1368 psFree(skycell_query); … … 1364 1372 return false; 1365 1373 } 1366 if (!p_psDBRunQueryF(config->dbh, skycell_query, stackQuery, warp_id, filter, warp Query)) {1367 psError(PS_ERR_UNKNOWN, false, "database error"); 1368 psFree(warp Query);1374 if (!p_psDBRunQueryF(config->dbh, skycell_query, stackQuery, warp_id, filter, warp2Query)) { 1375 psError(PS_ERR_UNKNOWN, false, "database error"); 1376 psFree(warp2Query); 1369 1377 psFree(stackQuery); 1370 1378 psFree(skycell_query); … … 1377 1385 1378 1386 if (num == 0) { 1379 psTrace("difftool", PS_LOG_INFO, "no skycells with stack found for %" PRId64, warp_id);1387 psTrace("difftool", PS_LOG_INFO, "no skycells with stack found for warp_id %" PRId64, warp_id); 1380 1388 continue; 1381 1389 } … … 1383 1391 if (!available && (num != skycell_count)) { 1384 1392 psTrace("difftool", PS_LOG_INFO, "%" PRId64 " skyfiles with stack found for warp_id %" PRId64 1385 " need %" PRId64, num, warp_id, skycell_count);1393 " but need %" PRId64, num, warp_id, skycell_count); 1386 1394 continue; 1387 1395 } … … 1418 1426 if (!p_psDBRunQuery(config->dbh, query)) { 1419 1427 psError(PS_ERR_UNKNOWN, false, "database error"); 1420 psFree(warp Query);1428 psFree(warp2Query); 1421 1429 psFree(stackQuery); 1422 1430 psFree(skycell_query); … … 1432 1440 if (!p_psDBRunQuery(config->dbh, query)) { 1433 1441 psError(PS_ERR_UNKNOWN, false, "database error"); 1434 psFree(warp Query);1442 psFree(warp2Query); 1435 1443 psFree(stackQuery); 1436 1444 psFree(skycell_query); … … 1447 1455 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1448 1456 run->diff_id); 1449 psFree(warp Query);1457 psFree(warp2Query); 1450 1458 psFree(stackQuery); 1451 1459 psFree(skycell_query); … … 1461 1469 } 1462 1470 psFree(output); 1463 psFree(warp Query);1471 psFree(warp2Query); 1464 1472 psFree(stackQuery); 1465 1473 psFree(skycell_query); … … 2062 2070 return(false); 2063 2071 } 2064 2072 2065 2073 return(true); 2066 2074 }
Note:
See TracChangeset
for help on using the changeset viewer.
