Changeset 24174 for trunk/ippTools/src/magictool.c
- Timestamp:
- May 13, 2009, 12:37:33 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/magictool.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/pap_magic (added) merged: 24120,24132-24136,24145,24147-24154,24156-24164,24168-24173
- Property svn:mergeinfo changed
-
trunk/ippTools/src/magictool.c
r23970 r24174 127 127 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 128 128 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 129 130 psMetadata *where = psMetadataAlloc(); 131 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 132 PXOPT_COPY_STR(config->args, where, "-diff_label", "diffRun.label", "=="); 133 129 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 130 131 psMetadata *diffWhere = psMetadataAlloc(); // WHERE conditions for diffRuns 132 PXOPT_COPY_STR(config->args, diffWhere, "-diff_label", "diffRun.label", "=="); 133 PXOPT_COPY_S64(config->args, diffWhere, "-diff_id", "diff_id", "=="); 134 135 psMetadata *queryWhere = psMetadataAlloc(); // WHERE conditions for everything else 136 PXOPT_COPY_S64(config->args, queryWhere, "-exp_id", "exp_id", "=="); 134 137 135 138 // Get list of exposures ready to magic … … 146 149 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 147 150 148 psString queryWhere = NULL; // WHERE conditions for entire query 151 psString diffWhereStr = NULL; // WHERE conditions for diffRuns 152 psString queryWhereStr = NULL; // WHERE conditions for entire query 149 153 if (!available) { 150 psStringAppend(& queryWhere, " \nWHEREdiffRun.state = 'full'");151 } else {152 // what if no skycells for the diff run completed?153 } 154 psStringAppend(&diffWhereStr, "\nAND diffRun.state = 'full'"); 155 } 156 // what if no skycells for the diff run completed? 157 154 158 if (!rerun) { 155 const char *newWhere = " magic_id IS NULL"; // String to add 156 if (queryWhere) { 157 psStringAppend(&queryWhere, " AND %s", newWhere); 158 } else { 159 psStringAppend(&queryWhere, "\nWHERE %s", newWhere); 160 } 161 } 159 psStringAppend(&queryWhereStr, "\n%s magic_id IS NULL", queryWhereStr ? "AND" : "WHERE"); 160 } 161 162 162 // now add the user specified qualifiers 163 if (psListLength( where->list)) {164 psString whereClause = psDBGenerateWhereConditionSQL( where, NULL);165 psStringAppend(& queryWhere, "\n%s %s", queryWhere == NULL ? "WHERE" : "AND", whereClause);163 if (psListLength(diffWhere->list)) { 164 psString whereClause = psDBGenerateWhereConditionSQL(diffWhere, NULL); 165 psStringAppend(&diffWhereStr, "\nAND %s", whereClause); 166 166 psFree(whereClause); 167 167 } 168 psFree(where); 169 if (!queryWhere) { 170 psStringAppend(&queryWhere, " "); 171 } 172 173 if (!p_psDBRunQueryF(config->dbh, query, queryWhere)) { 168 if (psListLength(queryWhere->list)) { 169 psString whereClause = psDBGenerateWhereConditionSQL(queryWhere, NULL); 170 psStringAppend(&queryWhereStr, "\n%s %s", queryWhereStr ? "AND" : "WHERE", whereClause); 171 psFree(whereClause); 172 } 173 psFree(diffWhere); 174 psFree(queryWhere); 175 176 // Ensure the WHERE strings have something 177 if (!diffWhereStr) { 178 diffWhereStr = psStringCopy(""); 179 } 180 if (!queryWhereStr) { 181 queryWhereStr = psStringCopy(""); 182 } 183 184 if (!p_psDBRunQueryF(config->dbh, query, diffWhereStr, diffWhereStr, queryWhereStr)) { 174 185 psError(PS_ERR_UNKNOWN, false, "database error"); 175 psFree(queryWhere); 186 psFree(diffWhereStr); 187 psFree(queryWhereStr); 176 188 psFree(query); 177 189 return false; 178 190 } 179 psFree(queryWhere); 191 psFree(diffWhereStr); 192 psFree(queryWhereStr); 180 193 psFree(query); 181 194 } … … 201 214 } 202 215 216 217 if (pretend) { 218 // negative simple so the default is true 219 if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) { 220 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 221 psFree(output); 222 return false; 223 } 224 psFree(output); 225 return true; 226 } 227 228 203 229 // Parse the list of exposures ready to magic 204 205 230 if (!psDBTransaction(config->dbh)) { 206 231 psError(PS_ERR_UNKNOWN, false, "database error"); … … 215 240 psS64 exp_id = psMetadataLookupS64(NULL, row, "exp_id"); // Exposure identifier 216 241 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); // difference identifier 242 bool inverse = psMetadataLookupU64(NULL, row, "inverse"); // Inverse subtraction? Note types! 217 243 218 244 // create a new magicRun for this group 219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, "new", workdir, "dirty", label, dvodb, registered, 0); 245 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, inverse, "new", workdir, "dirty", label, 246 dvodb, registered, 0); 220 247 if (!run) { 221 248 psAbort("failed to alloc magicRun object"); … … 296 323 297 324 // optional 325 PXOPT_LOOKUP_BOOL(inverse, config->args, "-inverse", false); 298 326 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 299 327 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); … … 305 333 exp_id, 306 334 diff_id ? diff_id : PS_MAX_S64, 335 inverse, 307 336 "reg", // state 308 337 workdir, … … 363 392 // required 364 393 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false); 365 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);366 394 PXOPT_LOOKUP_STR(node, config->args, "-node", true, false); 367 395 … … 369 397 config->dbh, 370 398 magic_id, 371 diff_id,372 399 node 373 400 ); … … 563 590 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); 564 591 565 psString query = psStringCopy("UPDATE magicRun SET fault = 0, state = ' run' WHERE fault != 0");592 psString query = psStringCopy("UPDATE magicRun SET fault = 0, state = 'new' WHERE fault != 0"); 566 593 567 594 if (psListLength(where->list)) { … … 584 611 PS_ASSERT_PTR_NON_NULL(config, false); 585 612 586 psMetadata *where = psMetadataAlloc(); 587 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 588 PXOPT_COPY_STR(config->args, where, "-node", "node", "=="); 613 // Regrettably, there are multiple WHERE hooks which call the same things different names 614 psMetadata *templatesWhere = psMetadataAlloc(); // WHERE for selecting template 615 psMetadata *magicWhere = psMetadataAlloc(); // WHERE for selecting magic runs 616 617 PXOPT_COPY_S64(config->args, templatesWhere, "-magic_id", "magicRun.magic_id", "=="); 618 PXOPT_COPY_STR(config->args, templatesWhere, "-node", "diffInputSkyfile.skycell_id", "=="); 619 620 PXOPT_COPY_S64(config->args, magicWhere, "-magic_id", "magicRun.magic_id", "=="); 621 PXOPT_COPY_STR(config->args, magicWhere, "-node", "magicTree.node", "=="); 589 622 590 623 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 597 630 } 598 631 599 if (psListLength(where->list)) { 600 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 601 psStringAppend(&query, " AND %s", whereClause); 632 psString templatesWhereStr = psStringCopy(""); // WHERE for selecting template 633 psString magicWhereStr = psStringCopy(""); // WHERE for selecting magic runs 634 635 if (psListLength(templatesWhere->list)) { 636 psString whereClause = psDBGenerateWhereConditionSQL(templatesWhere, NULL); 637 psStringAppend(&templatesWhereStr, "\nAND %s", whereClause); 602 638 psFree(whereClause); 603 639 } 604 psFree(where); 640 psFree(templatesWhere); 641 642 if (psListLength(magicWhere->list)) { 643 psString whereClause = psDBGenerateWhereConditionSQL(magicWhere, NULL); 644 psStringAppend(&magicWhereStr, "\nWHERE %s", whereClause); 645 psFree(whereClause); 646 } 647 psFree(magicWhere); 605 648 606 649 // treat limit == 0 as "no limit" … … 611 654 } 612 655 613 if (!p_psDBRunQuery(config->dbh, query)) { 614 psError(PS_ERR_UNKNOWN, false, "database error"); 656 if (!p_psDBRunQueryF(config->dbh, query, 657 templatesWhereStr, templatesWhereStr, 658 magicWhereStr, magicWhereStr)) { 659 psError(PS_ERR_UNKNOWN, false, "database error"); 660 psFree(templatesWhereStr); 661 psFree(magicWhereStr); 615 662 psFree(query); 616 663 return false; 617 664 } 665 psFree(templatesWhereStr); 666 psFree(magicWhereStr); 618 667 psFree(query); 619 668 … … 704 753 705 754 bool status = false; 706 psS 32 done = psMetadataLookupS32(&status, data, "done");755 psS64 done = psMetadataLookupS64(&status, data, "done"); 707 756 if (!status) { 708 757 psAbort("failed to lookup value for done column"); 709 758 } 710 psS 16 bad = psMetadataLookupS16(&status, data, "bad");759 psS64 bad = psMetadataLookupS64(&status, data, "bad"); 711 760 if (!status) { 712 761 psAbort("failed to lookup value for bad column"); … … 738 787 739 788 psMetadata *where = psMetadataAlloc(); 740 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic _id", "==");789 PXOPT_COPY_S64(config->args, where, "-magic_id", "magicRun.magic_id", "=="); 741 790 pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "=="); 742 791 … … 794 843 if (limit) { 795 844 if (psArrayLength(output) >= limit) { 796 // we've found enough (not that limit was applied to the query so '> limit' won't happen)845 // we've found enough (note that limit was applied to the query so '> limit' won't happen) 797 846 // negative simple so the default is true 798 847 if (!ippdbPrintMetadatas(stdout, output, "magicMe", !simple)) { … … 936 985 937 986 // optional 938 PXOPT_LOOKUP_STR( uri, config->args, "-uri", false, false);987 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 939 988 940 989 // default values … … 944 993 magic_id, 945 994 node, 946 uri,995 path_base, 947 996 fault 948 997 )) {
Note:
See TracChangeset
for help on using the changeset viewer.
