- Timestamp:
- Dec 23, 2013, 2:32:53 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bills_branches/bills_201312/ippTools/src/fftool.c
r36392 r36409 40 40 static bool updateresultMode(pxConfig *config); 41 41 42 static bool setfullForceRunState(pxConfig *config, psS64 sky_id, const char *state);42 // static bool setfullForceRunState(pxConfig *config, psS64 sky_id, const char *state); 43 43 44 44 # define MODECASE(caseName, func) \ … … 103 103 PXOPT_LOOKUP_STR(sources_path_base, config->args, "-set_sources_path_base", false, false); 104 104 105 psMetadata *whereMD = psMetadataAlloc(); 106 pxAddLabelSearchArgs(config, whereMD, "-select_warp_label", "warpRun.label", "LIKE"); 107 pxAddLabelSearchArgs(config, whereMD, "-select_warp_data_group","warpRun.data_group", "LIKE"); 108 PXOPT_COPY_S64(config->args, whereMD, "-select_warp_id", "warpRun.warp_id", "=="); 109 110 pxAddLabelSearchArgs(config, whereMD, "-select_skycal_label", "skycalRun.label", "LIKE"); 111 pxAddLabelSearchArgs(config, whereMD, "-select_skycal_data_group", "skycalRun.data_group", "LIKE"); 112 PXOPT_COPY_S64(config->args, whereMD, "-select_skycal_id", "skycalRun.skycal_id", "=="); 113 114 // XXX: REQUIRE at least one of the stack selectors and one of the warp selectors are supplied 115 116 PXOPT_COPY_STR(config->args, whereMD, "-select_skycell_id", "stackRun.skycell_id", "LIKE"); 117 PXOPT_COPY_STR(config->args, whereMD, "-select_tess_id", "stackRun.tess_id", "=="); 118 pxAddLabelSearchArgs(config, whereMD, "-select_filter", "stackRun.filter", "LIKE"); 119 120 if (!pxskycellAddWhere(config, whereMD)) { 105 psMetadata *skycalWhereMD = psMetadataAlloc(); 106 pxAddLabelSearchArgs(config, skycalWhereMD, "-select_skycal_label", "skycalRun.label", "LIKE"); 107 pxAddLabelSearchArgs(config, skycalWhereMD, "-select_skycal_data_group", "skycalRun.data_group", "LIKE"); 108 PXOPT_COPY_S64(config->args, skycalWhereMD, "-select_skycal_id", "skycalRun.skycal_id", "=="); 109 110 if (!psListLength(skycalWhereMD->list)) { 111 psError(PXTOOLS_ERR_CONFIG, false, "skycal search parameters are required"); 112 psFree(skycalWhereMD); 113 return false; 114 } 115 116 PXOPT_COPY_STR(config->args, skycalWhereMD, "-select_skycell_id", "stackRun.skycell_id", "LIKE"); 117 PXOPT_COPY_STR(config->args, skycalWhereMD, "-select_tess_id", "stackRun.tess_id", "=="); 118 pxAddLabelSearchArgs(config, skycalWhereMD, "-select_filter", "stackRun.filter", "LIKE"); 119 if (!pxskycellAddWhere(config, skycalWhereMD)) { 121 120 psError(PXTOOLS_ERR_CONFIG, false, "failed to add skycell search arguments"); 122 return false; 123 } 121 psFree(skycalWhereMD); 122 return false; 123 } 124 125 psMetadata *warpWhereMD = psMetadataAlloc(); 126 pxAddLabelSearchArgs(config, warpWhereMD, "-select_warp_label", "warpRun.label", "LIKE"); 127 pxAddLabelSearchArgs(config, warpWhereMD, "-select_warp_data_group","warpRun.data_group", "LIKE"); 128 PXOPT_COPY_S64(config->args, warpWhereMD, "-select_warp_id", "warpRun.warp_id", "=="); 129 if (!psListLength(warpWhereMD->list)) { 130 psError(PXTOOLS_ERR_CONFIG, false, "warp search parameters are required"); 131 psFree(warpWhereMD); 132 psFree(skycalWhereMD); 133 return false; 134 } 135 if (!psListLength(warpWhereMD->list)) { 136 psError(PXTOOLS_ERR_CONFIG, false, "skycal search parameters are required"); 137 psFree(skycalWhereMD); 138 psFree(warpWhereMD); 139 return false; 140 } 141 142 PXOPT_COPY_STR(config->args, warpWhereMD, "-select_tess_id", "warpRun.tess_id", "=="); 143 pxAddLabelSearchArgs(config, warpWhereMD, "-select_filter", "warpRun.filter", "LIKE"); 144 if (!pxskycellAddWhere(config, warpWhereMD)) { 145 psError(PXTOOLS_ERR_CONFIG, false, "failed to add skycell search arguments"); 146 psFree(skycalWhereMD); 147 psFree(warpWhereMD); 148 return false; 149 } 150 124 151 125 152 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); … … 130 157 if (!select) { 131 158 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 132 psFree(whereMD); 133 return false; 134 } 135 136 if (!psListLength(whereMD->list)) { 137 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 138 psFree(whereMD); 159 psFree(skycalWhereMD); 160 psFree(warpWhereMD); 139 161 return false; 140 162 } 141 163 142 164 psString where = NULL; 143 psString whereClause = psDBGenerateWhereConditionSQL( whereMD, NULL);165 psString whereClause = psDBGenerateWhereConditionSQL(skycalWhereMD, NULL); 144 166 psStringAppend(&where, "\nAND %s", whereClause); 145 167 psStringAppend(&select, where); 146 168 psFree(whereClause); 147 psFree( whereMD);169 psFree(skycalWhereMD); 148 170 149 171 psString joinHook = NULL; 150 172 if (!rerun) { 173 psStringAppend(&joinHook, "\nLEFT JOIN fullForceRun ON fullForceRun.skycal_id = fullForceRun.skycal_id"); 151 174 psStringAppend(&joinHook, "\n %s\nAND fullForceRun.label = '%s'", where, label); 152 175 psStringAppend(&select, "\nAND ff_id IS NULL"); … … 181 204 return true; 182 205 } 206 183 207 if (pretend) { 184 208 // negative simple so the default is true 185 if (!ippdbPrintMetadatas(stdout, output, " staticskyInput", !simple)) {209 if (!ippdbPrintMetadatas(stdout, output, "toFullForce", !simple)) { 186 210 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 187 211 psFree(output); … … 193 217 return true; 194 218 } 219 220 psString warpQueryTemplate = pxDataGet("fftool_definebyquery_select_warps.sql"); 221 222 whereClause = psDBGenerateWhereConditionSQL(warpWhereMD, NULL); 223 psStringAppend(&warpQueryTemplate, "\nAND %s", whereClause); 195 224 196 225 for (long i = 0; i < output->n; i++) { … … 204 233 } 205 234 206 psS64 warp_id = psMetadataLookupS64(&status, row, "warp_id");235 // psS64 warp_id = psMetadataLookupS64(&status, row, "warp_id"); 207 236 psS64 skycal_id = psMetadataLookupS64(&status, row, "skycal_id"); 208 237 … … 216 245 217 246 psString skycal_data_group = psMetadataLookupStr(&status, row, "data_group"); 247 psString tess_id = psMetadataLookupStr(&status, row, "tess_id"); 248 psString skycell_id = psMetadataLookupStr(&status, row, "skycell_id"); 249 psString filter = psMetadataLookupStr(&status, row, "filter"); 250 251 psString query = NULL; 252 psStringAppend(&query, warpQueryTemplate, tess_id, skycell_id, filter); 253 254 if (!p_psDBRunQuery(config->dbh, query)) { 255 psError(PS_ERR_UNKNOWN, false, "database error"); 256 psFree(query); 257 return false; 258 } 259 psFree(query); 260 261 // Find the warps for this skycell and filter combination 262 psArray *warpOutput = p_psDBFetchResult(config->dbh); 263 if (!warpOutput) { 264 psErrorCode err = psErrorCodeLast(); 265 switch (err) { 266 case PS_ERR_DB_CLIENT: 267 psError(PXTOOLS_ERR_SYS, false, "database error"); 268 case PS_ERR_DB_SERVER: 269 psError(PXTOOLS_ERR_PROG, false, "database error"); 270 default: 271 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 272 } 273 return false; 274 } 275 if (!psArrayLength(warpOutput)) { 276 // no warps for this skycal. Suprise? 277 psFree(warpOutput); 278 psFree(query); 279 continue; 280 } 218 281 219 282 // create a staticskyRun 220 283 if (!fullForceRunInsert(config->dbh, 221 284 0x0, // ff_id 222 warp_id,223 285 skycal_id, 224 286 path_base, … … 241 303 } 242 304 305 psS64 ff_id = psDBLastInsertID(config->dbh); 306 307 for (int j = 0; j < warpOutput->n; j++) { 308 psMetadata *warpRow = warpOutput->data[j]; 309 psS64 warp_id = psMetadataLookupS64(&status, warpRow, "warp_id"); 310 311 if (!fullForceInputInsert(config->dbh, 312 ff_id, 313 warp_id) 314 ) { 315 if (!psDBRollback(config->dbh)) { 316 psError(PS_ERR_UNKNOWN, false, "database error failed to rollback transaction"); 317 } 318 psError(PS_ERR_UNKNOWN, false, "database error"); 319 psFree(warpOutput); 320 psFree(output); 321 return false; 322 } 323 } 324 243 325 if (!psDBCommit(config->dbh)) { 244 326 psError(PS_ERR_UNKNOWN, false, "database error"); 327 psFree(warpOutput); 245 328 psFree(output); 246 329 return false; 247 330 } 331 psFree(warpOutput); 248 332 } 249 333 psFree(output); … … 365 449 // required 366 450 PXOPT_LOOKUP_S64(ff_id, config->args, "-ff_id", true, false); 451 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false); 367 452 368 453 // optional … … 384 469 if (!fullForceResultInsert(config->dbh, 385 470 ff_id, 471 warp_id, 386 472 path_base, 387 473 dtime_script, … … 398 484 } 399 485 486 #ifdef notdef 400 487 if (!fault) { 401 488 if (!setfullForceRunState(config, ff_id, "full")) { … … 407 494 } 408 495 } 496 #endif 409 497 410 498 // point of no return … … 557 645 psMetadata *where = psMetadataAlloc(); 558 646 PXOPT_COPY_S64(config->args, where, "-ff_id", "ff_id", "=="); 647 PXOPT_COPY_S64(config->args, where, "-warp_id", "ff_id", "=="); 559 648 560 649 … … 567 656 return true; 568 657 } 569 658 #ifdef notyet 570 659 static bool setfullForceRunState(pxConfig *config, psS64 ff_id, const char *state) 571 660 { … … 578 667 return true; 579 668 } 580 669 #endif 670
Note:
See TracChangeset
for help on using the changeset viewer.
