IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11766


Ignore:
Timestamp:
Feb 12, 2007, 6:13:58 PM (19 years ago)
Author:
jhoblitt
Message:

add p4tool -tooverlap mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/warptool.c

    r11765 r11766  
    470470static bool tooverlapMode(pxConfig *config)
    471471{
    472     PS_ASSERT_PTR_NON_NULL(config, NULL);
    473 
    474     psString query = psStringCopy(
    475         " SELECT DISTINCT"
    476         "   p4InputExp.p4_id,"
    477         "   p2ProcessedImfile.*,"
    478         "   p4Run.workdir"
    479         " FROM p4Run"
    480         " JOIN p4InputExp"
    481         "   USING(p4_id)"
    482         " LEFT JOIN p4Scfile"
    483         "   ON p4Run.p4_id = p4Scfile.p4_id"
    484         "   AND exp_tag, p3_version, class_id)"
    485         " JOIN p3ProcessedExp"
    486         "   ON p4InputImfile.exp_tag = p3ProcessedExp.exp_tag"
    487         "   AND p4InputImfile.p3_version = p3ProcessedExp.p3_version"
    488         " JOIN p2ProcessedImfile"
    489         "   ON p4InputImfile.exp_tag = p2ProcessedImfile.exp_tag"
    490         "   AND p3ProcessedExp.p2_version = p2ProcessedImfile.p2_version"
    491         "   AND p4InputImfile.class_id = p2ProcessedImfile.class_id"
    492         " WHERE"
    493         "   p4Run.state = 'run'"
    494         "   AND p4WarpedImfile.p4_id IS NULL"
    495         "   AND p4WarpedImfile.exp_tag IS NULL"
    496         "   AND p4WarpedImfile.p3_version IS NULL"
    497         "   AND p4WarpedImfile.class_id IS NULL"
     472    PS_ASSERT_PTR_NON_NULL(config, false);
     473
     474    bool status = false;
     475    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     476    if (!status) {
     477        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     478        return false;
     479    }
     480
     481    // find all rawImfiles matching the default query
     482    psString query = psStringCopy(
     483        "SELECT\n"
     484        "   p3ProcessedExp.*\n"
     485        " FROM p4Run\n"
     486        " JOIN p4InputExp\n"
     487        "   USING(p4_id)\n"
     488        " JOIN p3ProcessedExp\n"
     489        "   ON p4InputExp.exp_tag = p3ProcessedExp.exp_tag\n"
     490        "   AND p4InputExp.p3_version = p3ProcessedExp.p3_version\n"
     491        " LEFT JOIN p4SkyCellMap\n"
     492        "   ON p4InputExp.p4_id = p4SkyCellMap.p4_id\n"
     493        "   AND p4InputExp.exp_tag = p4SkyCellMap.exp_tag\n"
     494        "   AND p4InputExp.p3_version = p4SkyCellMap.p3_version\n"
     495        " WHERE\n"
     496        "   p4Run.state = 'run'\n"
     497        "   AND p3ProcessedExp.fault = 0\n"
     498        "   AND p4SkyCellMap.p4_id IS NULL\n"
     499        "   AND p4SkyCellMap.exp_tag IS NULL\n"
     500        "   AND p4SkyCellMap.p3_version IS NULL\n"
    498501    );
    499502
     
    504507    }
    505508
     509    // treat limit == 0 as "no limit"
     510    if (limit) {
     511        psString limitString = psDBGenerateLimitSQL(limit);
     512        psStringAppend(&query, " %s", limitString);
     513        psFree(limitString);
     514    }
     515
    506516    if (!p_psDBRunQuery(config->dbh, query)) {
    507517        psError(PS_ERR_UNKNOWN, false, "database error");
     
    513523    psArray *output = p_psDBFetchResult(config->dbh);
    514524    if (!output) {
    515         psError(PS_ERR_UNKNOWN, false, "database error");
     525        psErrorCode err = psErrorCodeLast();
     526        switch (err) {
     527            case PS_ERR_DB_CLIENT:
     528                psError(PXTOOLS_ERR_SYS, false, "database error");
     529            case PS_ERR_DB_SERVER:
     530                psError(PXTOOLS_ERR_PROG, false, "database error");
     531            default:
     532                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     533        }
     534
    516535        return false;
    517536    }
    518537    if (!psArrayLength(output)) {
    519         psError(PS_ERR_UNKNOWN, false, "no p4InputImfile rows found");
     538        psError(PS_ERR_UNKNOWN, false, "no pending rawImfile rows found");
    520539        psFree(output);
    521540        return true;
     
    532551    }
    533552
    534     // negative simple so the default is true
    535     if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) {
    536         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    537         psFree(output);
    538         return false;
     553    if (psArrayLength(output)) {
     554        // negative simple so the default is true
     555        if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) {
     556            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     557            psFree(output);
     558            return false;
     559        }
    539560    }
    540561
     
    543564    return true;
    544565}
    545 
    546566
    547567static bool addoverlapMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.