Changeset 28164 for branches/czw_branch/20100519/ippTools/src/warptool.c
- Timestamp:
- May 28, 2010, 3:09:59 PM (16 years ago)
- Location:
- branches/czw_branch/20100519
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/warptool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20100519
- Property svn:mergeinfo changed
/trunk (added) merged: 28046-28057,28062-28069,28072-28076,28079-28100
- Property svn:mergeinfo changed
-
branches/czw_branch/20100519/ippTools/src
- Property svn:ignore
-
branches/czw_branch/20100519/ippTools/src/warptool.c
r28043 r28164 48 48 static bool maskedMode(pxConfig *config); 49 49 static bool unblockMode(pxConfig *config); 50 static bool tosummaryMode(pxConfig *config); 51 static bool addsummaryMode(pxConfig *config); 50 52 static bool pendingcleanuprunMode(pxConfig *config); 51 53 static bool pendingcleanupwarpMode(pxConfig *config); … … 101 103 MODECASE(WARPTOOL_MODE_MASKED, maskedMode); 102 104 MODECASE(WARPTOOL_MODE_UNBLOCK, unblockMode); 105 MODECASE(WARPTOOL_MODE_TOSUMMARY, tosummaryMode); 106 MODECASE(WARPTOOL_MODE_ADDSUMMARY, addsummaryMode); 103 107 MODECASE(WARPTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 104 108 MODECASE(WARPTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupwarpMode); … … 408 412 PXOPT_COPY_STR(config->args, where, "-reduction", "warpRun.reduction", "=="); 409 413 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 410 PXOPT_COPY_STR(config->args, where, "-data_group","warpRun.data_group"," ==");411 PXOPT_COPY_STR(config->args, where, "-dist_group","warpRun.dist_group"," ==");412 pxAddLabelSearchArgs(config, where, "-label", "warpRun.label", " ==");414 PXOPT_COPY_STR(config->args, where, "-data_group","warpRun.data_group","LIKE"); 415 PXOPT_COPY_STR(config->args, where, "-dist_group","warpRun.dist_group","LIKE"); 416 pxAddLabelSearchArgs(config, where, "-label", "warpRun.label", "LIKE"); 413 417 414 418 PXOPT_COPY_TIME(config->args, where, "-registered_begin", "warpRun.registered", ">="); … … 940 944 941 945 // treat limit == 0 as "no limit" 942 psString limitString = psStringCopy("\n ");946 psString limitString = psStringCopy("\nORDER BY priority DESC, warp_id"); 943 947 if (limit) { 944 // We apply the limit to both sides of the UNION 945 // to avoid slow queries and to the query itself 946 // to satisfy the user's requested limit 948 // We apply the limit to both sides of the UNION to avoid slow queries 949 // and to the query itself to satisfy the user's requested limit 947 950 psStringAppend(&limitString, "%s", psDBGenerateLimitSQL(limit)); 948 951 psStringAppend(&query, " %s", limitString); 949 952 } 950 953 951 #define TWO_WHERES952 #ifdef TWO_WHERES953 954 if (!p_psDBRunQueryF(config->dbh, query, whereStr, limitString, whereStr, limitString)) { 954 955 psError(PS_ERR_UNKNOWN, false, "database error"); … … 956 957 return false; 957 958 } 958 #else959 if (!p_psDBRunQueryF(config->dbh, query, whereStr)) {960 psError(PS_ERR_UNKNOWN, false, "database error");961 psFree(query);962 return false;963 }964 #endif965 959 psFree(limitString); 966 960 psFree(whereStr); … … 1163 1157 1164 1158 psString software_ver = NULL; 1165 psS 32maskfrac_npix = 0;1159 psS64 maskfrac_npix = 0; 1166 1160 psF32 maskfrac_static = 0; 1167 1161 psF32 maskfrac_dynamic = 0; … … 1181 1175 return(false); 1182 1176 } 1183 // Set warpRun.software_ver to the appropriate value 1184 if (!pxSetRunSoftware(config, "warpRun", "warp_id", warp_id, software_ver)) { 1185 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.software_ver for warp_id: %" PRId64, 1186 warp_id); 1187 psFree(output); 1188 if (!psDBRollback(config->dbh)) { 1189 psError(PS_ERR_UNKNOWN, false, "database error"); 1177 // Set warpRun.software_ver to the appropriate value if ( 1178 if (software_ver) { 1179 if (!pxSetRunSoftware(config, "warpRun", "warp_id", warp_id, software_ver)) { 1180 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.software_ver for warp_id: %" PRId64, 1181 warp_id); 1182 psFree(output); 1183 if (!psDBRollback(config->dbh)) { 1184 psError(PS_ERR_UNKNOWN, false, "database error"); 1185 } 1186 return(false); 1190 1187 } 1191 return(false);1192 1188 } 1193 1189 // Set warpRun.maskfrac* to the appropriate values. 1194 if (!pxSetRunMaskfrac(config, "warpRun", "warp_id", warp_id, maskfrac_npix, maskfrac_static, 1195 maskfrac_dynamic, maskfrac_magic, maskfrac_advisory)) { 1196 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.software_ver for warp_id: %" PRId64, 1197 warp_id); 1198 psFree(output); 1199 if (!psDBRollback(config->dbh)) { 1200 psError(PS_ERR_UNKNOWN, false, "database error"); 1190 if (maskfrac_npix) { 1191 if (!pxSetRunMaskfrac(config, "warpRun", "warp_id", warp_id, maskfrac_npix, maskfrac_static, 1192 maskfrac_dynamic, maskfrac_magic, maskfrac_advisory)) { 1193 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.software_ver for warp_id: %" PRId64, 1194 warp_id); 1195 psFree(output); 1196 if (!psDBRollback(config->dbh)) { 1197 psError(PS_ERR_UNKNOWN, false, "database error"); 1198 } 1199 return(false); 1201 1200 } 1202 return(false); 1203 } 1201 } 1204 1202 1205 1203 … … 1554 1552 } 1555 1553 1554 static bool tosummaryMode(pxConfig *config) { 1555 PS_ASSERT_PTR_NON_NULL(config, NULL); 1556 1557 psMetadata *where = psMetadataAlloc(); 1558 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1559 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1560 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 1561 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1562 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1563 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 1564 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 1565 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 1566 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "LIKE"); 1567 PXOPT_COPY_S64(config->args, where, "-magicked", "warpSkyfile.magicked", "=="); 1568 pxAddLabelSearchArgs (config, where, "-label", "warpRun.label", "LIKE"); 1569 pxAddLabelSearchArgs (config, where, "-data_group", "warpRun.data_group", "LIKE"); 1570 1571 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1572 1573 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1574 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1575 1576 // find all rawImfiles matching the default query 1577 psString query = pxDataGet("warptool_tosummary.sql"); 1578 if (!query) { 1579 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1580 return false; 1581 } 1582 1583 // generate where strings for arguments that require extra processing 1584 // beyond PXOPT_COPY* 1585 psString where2 = NULL; 1586 if (!pxmagicAddWhere(config, &where2, "warpSkyfile")) { 1587 psError(psErrorCodeLast(), false, "pxMagicAddWhere failed"); 1588 return false; 1589 } 1590 1591 if (psListLength(where->list)) { 1592 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1593 psStringAppend(&query, " AND %s", whereClause); 1594 psFree(whereClause); 1595 } else if (!all && !where2) { 1596 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 1597 return false; 1598 } 1599 1600 if (where2) { 1601 psStringAppend(&query, " %s", where2); 1602 } 1603 psFree(where); 1604 1605 // treat limit == 0 as "no limit" 1606 if (limit) { 1607 psString limitString = psDBGenerateLimitSQL(limit); 1608 psStringAppend(&query, " %s", limitString); 1609 psFree(limitString); 1610 } 1611 1612 if (!p_psDBRunQuery(config->dbh, query)) { 1613 psError(PS_ERR_UNKNOWN, false, "database error"); 1614 psFree(query); 1615 return false; 1616 } 1617 psFree(query); 1618 1619 psArray *output = p_psDBFetchResult(config->dbh); 1620 if (!output) { 1621 psErrorCode err = psErrorCodeLast(); 1622 switch (err) { 1623 case PS_ERR_DB_CLIENT: 1624 psError(PXTOOLS_ERR_SYS, false, "database error"); 1625 case PS_ERR_DB_SERVER: 1626 psError(PXTOOLS_ERR_PROG, false, "database error"); 1627 default: 1628 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1629 } 1630 1631 return false; 1632 } 1633 if (!psArrayLength(output)) { 1634 psTrace("warptool", PS_LOG_INFO, "no rows found"); 1635 psFree(output); 1636 return true; 1637 } 1638 1639 if (psArrayLength(output)) { 1640 // negative simple so the default is true 1641 if (!ippdbPrintMetadatas(stdout, output, "warpRun", !simple)) { 1642 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1643 psFree(output); 1644 return false; 1645 } 1646 } 1647 1648 psFree(output); 1649 return(true); 1650 } 1651 static bool addsummaryMode(pxConfig *config) { 1652 PS_ASSERT_PTR_NON_NULL(config, NULL); 1653 1654 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false); 1655 PXOPT_LOOKUP_STR(tangent_plane, config->args, "-tangent_plane", true, false); 1656 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 1657 1658 psString query = pxDataGet("warptool_addsummary.sql"); 1659 if (!query) { 1660 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1661 return(false); 1662 } 1663 if (!p_psDBRunQueryF(config->dbh, query, warp_id, tangent_plane, path_base)) { 1664 psError(PS_ERR_UNKNOWN, false, "database error"); 1665 psFree(query); 1666 return(false); 1667 } 1668 psS64 numUpdated = psDBAffectedRows(config->dbh); 1669 1670 if (numUpdated != 1) { 1671 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 1672 psFree(query); 1673 return false; 1674 } 1675 1676 psFree(query); 1677 1678 // Print anything here? 1679 1680 return(true); 1681 } 1682 1556 1683 static bool pendingcleanuprunMode(pxConfig *config) 1557 1684 {
Note:
See TracChangeset
for help on using the changeset viewer.
