- Timestamp:
- Mar 5, 2012, 5:19:48 PM (14 years ago)
- Location:
- branches/meh_branches/ppstack_test
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (2 props)
-
ippTools/src/addtool.c (modified) (35 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/meh_branches/ppstack_test
- Property svn:mergeinfo changed
-
branches/meh_branches/ppstack_test/ippTools/src
- Property svn:ignore
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20110710/ippTools/src (added) merged: 32337 /branches/eam_branches/ipp-20110906/ippTools/src (added) merged: 32630 /branches/eam_branches/ipp-20111110/ippTools/src (added) merged: 32694 /branches/haf_add201112/ippTools/src (added) merged: 32980,32986,33003,33023,33027
-
branches/meh_branches/ppstack_test/ippTools/src/addtool.c
r31680 r33415 143 143 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 144 144 } 145 145 if (strcmp(stage, "staticsky_multi")== 0) { 146 147 pxAddLabelSearchArgs (config, where, "-label", "staticskyRun.label", "=="); // define using camRun label 148 pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label 149 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyyRun.reduction", "=="); 150 //no filter here 151 } 146 152 if (!psListLength(where->list)) { 147 153 psFree(where); … … 237 243 } 238 244 239 245 if (strcmp(stage,"staticsky_multi") == 0) { 246 if (dvodb ) { 247 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage); 248 // find the cam_id of all the exposures that we want to queue up. 249 bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql"); 250 // user supplied dvodb 251 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 252 } else { 253 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage); 254 // find the cam_id of all the exposures that we want to queue up. 255 bare_query = pxDataGet("addtool_find_sky_id_multi.sql"); 256 // inherit dvodb from camRun, avoid matching NULL 257 psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)"); 258 } 259 } 240 260 241 261 if (!bare_query) { … … 272 292 } else { 273 293 //This picks only the unmagicked/uncensored ones 274 if (strcmp(stage,"cam") == 0) { 275 psStringAppend(&query, " AND (camRun.magicked = 0)"); 276 } 294 //if (strcmp(stage,"cam") == 0) { 295 //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored. 296 //psStringAppend(&query, " AND (camRun.magicked = 0)"); 297 //} 277 298 if (strcmp(stage,"stack") == 0) { 278 299 psStringAppend(&query, " AND (stackRun.magicked = 0)"); … … 280 301 281 302 } 303 304 //if we grab a group of camRun/stackRuns that have multiple camRun/stackRun pointing to the same exp_id/stack_id, and that exp_id/stack_id has never before been added to addRun, we need to group by exp_id/stack_id to ensure that only 1 of the camRun/stackRun for that exp_id is added to the addRun stage. 305 306 if (strcmp(stage,"cam") == 0) { 307 psStringAppend(&query, " GROUP BY exp_id"); 308 } 309 if (strcmp(stage,"stack") == 0) { 310 psStringAppend(&query, " GROUP BY stack_id"); 311 } 312 if (strcmp(stage,"staticsky") == 0) { 313 psStringAppend(&query, " GROUP BY stack_id"); 314 } 315 if (strcmp(stage,"staticsky_multi") == 0) { 316 psStringAppend(&query, " GROUP BY sky_id"); //some reason it needs this 317 } 318 282 319 283 320 psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query); … … 391 428 } 392 429 } 430 if (strcmp(stage,"staticsky_multi") == 0) { 431 for (long i = 0; i < psArrayLength(output); i++) { 432 psMetadata *md = output->data[i]; 433 bool status = false; 434 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 435 if (!status) { 436 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs"); 437 return false; 438 } 439 if (num_inputs < 0) { 440 psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs"); 441 return false; 442 } 443 444 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 445 446 if (!row) { 447 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 448 psFree(output); 449 return false; 450 } 451 452 if (!dvodb) { //there's no staticsky.dvodb 453 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id); 454 psFree(output); 455 return false; 456 } 457 if (!workdir && !row->workdir) { 458 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id); 459 psFree(output); 460 return false; 461 } 462 463 psFree(row); 464 } 465 } 466 467 468 393 469 394 470 // start a transaction so we don't end up with an exp without any associted … … 424 500 stage, 425 501 stage_id, 502 0, 426 503 workdir ? workdir : row->workdir, 427 504 reduction ? reduction : row->reduction, … … 465 542 stage, 466 543 stage_id, 544 0, 467 545 workdir ? workdir : row->workdir, 468 546 reduction ? reduction : row->reduction, … … 506 584 stage, 507 585 stage_id, 586 0, 508 587 workdir ? workdir : row->workdir, 509 588 reduction ? reduction : row->reduction, … … 530 609 } 531 610 611 if (strcmp(stage,"staticsky_multi") == 0) { 612 for (long i = 0; i < psArrayLength(output); i++) { 613 psMetadata *md = output->data[i]; 614 psS64 stage_id =0; 615 bool status = false; 616 psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs"); 617 if (!status) { 618 psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs"); 619 return false; 620 } 621 staticskyRunRow *row = staticskyRunObjectFromMetadata(md); 622 stage_id = row->sky_id; 623 624 if (!row) { 625 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 626 psFree(output); 627 return false; 628 } 629 630 // queue the exp 631 for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 632 if (!pxaddQueueByCamID(config, 633 stage, 634 stage_id, 635 filter_id, 636 workdir ? workdir : row->workdir, 637 reduction ? reduction : row->reduction, 638 label ? label : row->label, 639 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 640 dvodb ? dvodb : NULL, 641 note ? note : NULL, 642 image_only, 643 minidvodb, 644 minidvodb_group, 645 minidvodb_name 646 )) { 647 if (!psDBRollback(config->dbh)) { 648 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 649 } 650 psError(PS_ERR_UNKNOWN, false, 651 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 652 psFree(row); 653 psFree(output); 654 return false; 655 } 656 } 657 psFree(row); 658 } 659 } 660 661 662 663 532 664 psFree(output); 533 665 … … 571 703 } 572 704 if (strcmp(stage, "staticsky")==0) { 705 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 706 } 707 if (strcmp(stage, "staticsky_multi")==0) { 573 708 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 574 709 } … … 612 747 query = pxDataGet("addtool_find_pendingexp_staticsky.sql"); 613 748 } 614 749 if (strcmp(stage, "staticsky_multi")==0) { 750 query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql"); 751 } 752 615 753 616 754 if (!query) { … … 634 772 psStringAppend(&query, " GROUP BY %s", "sky_id"); 635 773 } 636 774 if (strcmp(stage, "staticsky_multi") == 0) { 775 //this group by is needed to join against all the warps (to get camera) 776 psStringAppend(&query, " GROUP BY %s", "sky_id, stage_extra1"); 777 } 637 778 // treat limit == 0 as "no limit" 638 779 if (limit) { … … 684 825 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-minidvodb_name", false, false); 685 826 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 686 827 PXOPT_LOOKUP_S64(stage_extra1, config->args, "-stage_extra1", false, false); 687 828 // generate restrictions 688 829 psMetadata *where = psMetadataAlloc(); … … 762 903 } 763 904 } 764 905 //if there is a stage_extra1, set it in addRun (it's not known until it is processed) 906 if (stage_extra1) { 907 psString setExtra = NULL; 908 psStringAppend (&setExtra, "UPDATE addRun set stage_extra1 = %" PRId64, stage_extra1); 909 psStringAppend (&setExtra, " where add_id = %" PRId64, row->add_id); 910 911 if (!p_psDBRunQuery(config->dbh, setExtra)) { 912 if (!psDBRollback(config->dbh)) { 913 psError(PS_ERR_UNKNOWN, false, "database error"); 914 } 915 psError(PS_ERR_UNKNOWN, false, "database error"); 916 917 return false; 918 } 919 } 765 920 766 921 … … 824 979 query = pxDataGet("addtool_find_processedexp_staticsky.sql"); 825 980 } 981 if (strcmp (stage,"staticsky_multi") == 0) { 982 query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql"); 983 } 984 826 985 827 986 if (!query) { … … 905 1064 PXOPT_COPY_S64(config->args, where, "-add_id", "addRun.add_id", "=="); 906 1065 PXOPT_COPY_S64(config->args, where, "-stage_id", "addRun.stage_id", "=="); 907 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false);1066 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 908 1067 pxcamGetSearchArgs (config, where); 909 1068 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); … … 934 1093 query = pxDataGet("addtool_revertprocessedexp_staticsky.sql"); 935 1094 } 1095 if (strcmp(stage, "staticsky_multi") == 0) { 1096 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql"); 1097 } 1098 1099 1100 936 1101 if (!query) { 937 1102 // rollback … … 1071 1236 1072 1237 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", true, false); 1073 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-set_mergedvodb_path", true, false); 1074 1075 //optional 1238 //optional 1076 1239 PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false); 1077 1240 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false); … … 1088 1251 if (minidvodb_path) { 1089 1252 minidvodbpath = minidvodb_path; 1253 } else { 1254 psError(PS_ERR_UNKNOWN, false, "require minidvodb_path"); 1255 return false; 1090 1256 } 1091 1257 … … 1095 1261 minidvodb_group, 1096 1262 minidvodbpath, 1097 mergedvodb_path, 1098 "new", 1263 "new", 1099 1264 0 1100 1265 )) { … … 1118 1283 psStringAppend(&minidvodb_name, "%s.%" PRIu64,minidvodb_group,minidvodb_id); 1119 1284 } 1120 1121 if (!minidvodb_path) {1122 psStringAppend(&minidvodb_path,"%s/%s",mergedvodb_path,minidvodb_name);1123 }1124 1125 1285 if (minidvodb_path) { 1126 1286 psStringAppend(&minidvodb_path,"/%s",minidvodb_name); … … 1154 1314 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 1155 1315 PXOPT_COPY_STR(config->args, where, "-minidvodb_path", "minidvodb_path", "=="); 1156 PXOPT_COPY_STR(config->args, where, "-mergedvodb_path", "mergedvodb_path", "==");1157 1316 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodb_group", "=="); 1158 1317 … … 1160 1319 PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false); 1161 1320 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1162 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-set_mergedvodb_path", false, false);1163 1321 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false); 1164 1322 … … 1195 1353 } 1196 1354 1197 if (mergedvodb_path) {1198 if (cnt) {1199 psStringAppend(&query, "%s", comma);1200 }1201 psStringAppend(&query, " mergedvodb_path = '%s'", mergedvodb_path);1202 cnt++;1203 }1204 1205 1355 if (minidvodb_group) { 1206 1356 if (cnt) { … … 1246 1396 } 1247 1397 1248 psString firstquery = psStringCopy("SELECT * from minidvodbRun where state = 'new' and minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL");1398 psString firstquery = psStringCopy("SELECT * from minidvodbRun where state = 'new' and minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL"); 1249 1399 1250 1400 psString firstwhereClause = psDBGenerateWhereConditionSQL(where, NULL); … … 1294 1444 1295 1445 //now flip new -> active 1296 psString query2 = psStringCopy("UPDATE minidvodbRun SET state = 'active' WHERE state = 'new' AND minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL and mergedvodb_path IS NOT NULL");1446 psString query2 = psStringCopy("UPDATE minidvodbRun SET state = 'active' WHERE state = 'new' AND minidvodb_name is NOT NULL and minidvodb_group IS NOT NULL and minidvodb_path IS NOT NULL "); 1297 1447 psStringAppend(&query2, " AND minidvodb_group = '%s' limit 1;", minidvodb_group); 1298 1448 if (!p_psDBRunQuery(config->dbh, query2)) { … … 1471 1621 // required 1472 1622 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1473 PXOPT_LOOKUP_STR(mergedvodb_path, config->args, "-mergedvodb_path", true, false);1474 1623 PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-minidvodb_group", true, false); 1475 1624 1476 1625 // optional 1477 PXOPT_LOOKUP_U64(merge_order, config->args, "-merge_order", false, false);1478 1626 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-dtime_relphot", false, false); 1479 1627 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-dtime_resort", false, false); 1480 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-dtime_merge", false, false);1481 PXOPT_LOOKUP_F32(dtime_verify, config->args, "-dtime_verify", false, false);1482 1628 PXOPT_LOOKUP_F32(dtime_script, config->args, "-dtime_script", false, false); 1483 1629 … … 1530 1676 minidvodbProcessedRow *row = minidvodbProcessedRowAlloc( 1531 1677 pendingRow->minidvodb_id, 1532 merge_order,1533 1678 dtime_resort, 1534 1679 dtime_relphot, 1535 dtime_verify,1536 dtime_merge,1537 1680 dtime_script, 1538 1681 epoch, 1539 mergedvodb_path,1540 1682 fault 1541 1683 ); … … 1552 1694 } 1553 1695 1554 1555 1556 1557 //this finds the # of merged things (for the merge order)1558 psString query3 = NULL;1559 psStringAppend(&query3, "select count(*) from minidvodbRun join minidvodbProcessed using (minidvodb_id) where state = 'merged' and minidvodb_group = '%s';", minidvodb_group);1560 1561 if (!p_psDBRunQuery(config->dbh, query3)) {1562 // rollback1563 if (!psDBRollback(config->dbh)) {1564 psError(PS_ERR_UNKNOWN, false, "database error");1565 }1566 psError(PS_ERR_UNKNOWN, false, "database error");1567 psFree(query3);1568 return false;1569 }1570 psArray *output2 = p_psDBFetchResult(config->dbh);1571 if (!output2) {1572 psError(PS_ERR_UNKNOWN, false, "database error");1573 return false;1574 }1575 if (!psArrayLength(output2)) {1576 psTrace("addtool", PS_LOG_INFO, "no rows found");1577 psFree(output);1578 return true;1579 }1580 bool status;1581 psS64 m_order = psMetadataLookupS64(&status, output2->data[0], "count(*)");1582 if (!status) {1583 1584 psAbort("failed to lookup value for count column");1585 return false;1586 }1587 psString final = NULL;1588 psStringAppend(&final, "%" PRIu64, m_order);1589 //return false;1590 psFree(query3);1591 psFree(output2);1592 1593 1594 1595 //update the merge_order1596 1597 psString query4 = NULL;1598 psStringAppend(&query4, "update minidvodbProcessed set merge_order = %"PRIu64,m_order);1599 psStringAppend(&query4," where minidvodb_id = %" PRIu64, minidvodb_id);1600 //printf("%s", query4);1601 if (!p_psDBRunQuery(config->dbh, query4)) {1602 // rollback1603 if (!psDBRollback(config->dbh)) {1604 psError(PS_ERR_UNKNOWN, false, "database error");1605 }1606 psError(PS_ERR_UNKNOWN, false, "database error");1607 psFree(query4);1608 return false;1609 }1610 //1611 psFree(query4);1612 1613 1614 1615 // since there is only one exp per 'new' set mindvodbRun.state = 'merged'1616 1617 1696 psString query2 = NULL ; 1618 1697 psStringAppend(&query2, "UPDATE minidvodbRun SET state = 'merged' WHERE minidvodb_id = %'" PRIu64, row->minidvodb_id); … … 1627 1706 return false; 1628 1707 } 1629 1630 1631 1632 1633 1634 1635 1636 1637 1708 psFree(row); 1638 1709 psFree(pendingRow); … … 1647 1718 return false; 1648 1719 } 1649 1650 1651 //print the merge_order (why not!)1652 printf("%s", final);1653 psFree(final);1654 1655 1720 return true; 1656 1721 } … … 1661 1726 psMetadata *where = psMetadataAlloc(); 1662 1727 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); 1663 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodb Processed.minidvodb_name", "==");1664 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodb Processed.minidvodb_group", "==");1728 PXOPT_COPY_STR(config->args, where, "-minidvodb_name", "minidvodbRun.minidvodb_name", "=="); 1729 PXOPT_COPY_STR(config->args, where, "-minidvodb_group", "minidvodbRun.minidvodb_group", "=="); 1665 1730 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1666 1731 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 1811 1876 1812 1877 PXOPT_LOOKUP_U64(minidvodb_id, config->args, "-minidvodb_id", true, false); 1813 PXOPT_LOOKUP_U64(merge_order, config->args, "-set_merge_order", false, false);1814 1878 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 1815 1879 PXOPT_LOOKUP_F32(dtime_relphot, config->args, "-set_dtime_relphot", false, false); 1816 1880 PXOPT_LOOKUP_F32(dtime_resort, config->args, "-set_dtime_resort", false, false); 1817 PXOPT_LOOKUP_F32(dtime_merge, config->args, "-set_dtime_merge", false, false);1818 PXOPT_LOOKUP_F32(dtime_verify, config->args, "-set_dtime_verify", false, false);1819 1881 PXOPT_LOOKUP_F32(dtime_script, config->args, "-set_dtime_script", false, false); 1820 1882 PXOPT_COPY_S64(config->args, where, "-minidvodb_id", "minidvodbProcessed.minidvodb_id", "=="); … … 1836 1898 } 1837 1899 1838 if (merge_order) {1839 if (cnt) {1840 psStringAppend(&query, "%s", comma);1841 }1842 1843 psStringAppend(&query, " merge_order = %" PRId64, merge_order);1844 cnt++;1845 }1846 1847 1900 if (dtime_relphot) { 1848 1901 if (cnt) { … … 1861 1914 } 1862 1915 1863 if (dtime_merge) { 1864 if (cnt) { 1865 psStringAppend(&query, "%s", comma); 1866 } 1867 psStringAppend(&query, " dtime_merge = %f", dtime_merge); 1868 cnt++; 1869 } 1870 if (dtime_verify) { 1871 if (cnt) { 1872 psStringAppend(&query, "%s", comma); 1873 } 1874 psStringAppend(&query, " dtime_verify = %f", dtime_verify); 1875 cnt++; 1876 } 1877 if (dtime_script) { 1916 if (dtime_script) { 1878 1917 if (cnt) { 1879 1918 psStringAppend(&query, "%s", comma);
Note:
See TracChangeset
for help on using the changeset viewer.
