Changeset 9425 for trunk/ippTools/src/dettool.c
- Timestamp:
- Oct 9, 2006, 1:59:08 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (56 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r9417 r9425 65 65 static bool rerunMode(pxConfig *config); 66 66 67 static bool mapPositionToDetRun(psArray *mds);67 static bool convertDetIdToStr(psArray *mds); 68 68 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile); 69 69 static detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile); … … 281 281 } 282 282 283 // grab the 'position' column's value as the new det_id284 283 // the first iteration is always 0 285 284 // XXX the camera name is set from the first inputExp 286 detRunInsert(config->dbh, 0, det_type, "run"); 285 // XXX det_id 286 detRunInsert(config->dbh, 0, 0, det_type, "run"); 287 287 long det_id = psDBLastInsertID(config->dbh); 288 288 … … 333 333 { 334 334 psMetadata *where = psMetadataAlloc(); 335 // map det_id -> position 336 psMetadataAddS32(where, PS_LIST_TAIL, "position", 0, "==", det_id); 335 psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", det_id); 337 336 detRuns = psDBSelectRows(config->dbh, "detRun", where, 0); 338 337 psFree(where); … … 348 347 } 349 348 350 // map position -> det_id351 if (! mapPositionToDetRun(detRuns)) {352 psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");349 // convert det_id to a str externally 350 if (!convertDetIdToStr(detRuns)) { 351 psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string"); 353 352 psFree(detRuns); 354 353 return false; … … 366 365 } 367 366 368 static bool mapPositionToDetRun(psArray *mds) 367 // This function is used to convert the det_id from an int, as it is used 368 // internally, to be a string for external use. The rational being that we may 369 // want to change how det_id is generated in the future and don't want to 370 // external programs to become depending on this value being an int. 371 static bool convertDetIdToStr(psArray *mds) 369 372 { 370 373 PS_ASSERT_PTR_NON_NULL(mds, false); 371 374 372 375 for (long i = 0; i < psArrayLength(mds); i++) { 376 psMetadata *md = mds->data[i]; 373 377 bool status = false; 374 psS32 position = psMetadataLookupS32(&status, mds->data[i], "position");378 psS32 det_id = psMetadataLookupS32(&status, md, "det_id"); 375 379 if (!status) { 376 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position"); 377 psFree(mds); 378 return false; 379 } 380 psMetadataAddS32(mds->data[i], PS_LIST_HEAD, "det_id", 0, NULL, position); 380 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for det_id"); 381 return false; 382 } 383 psMetadataRemove(md, 0, "det_id"); 384 psString det_idStr = psDBIntToString((psU64)det_id); 385 psMetadataAddStr(mds->data[i], PS_LIST_HEAD, "det_id", 0, NULL, det_idStr); 386 psFree(det_idStr); 381 387 } 382 388 … … 486 492 } 487 493 488 // grab the 'position' column's value as the new det_id489 494 // the first iteration is always 0 490 // XXX the camera name is set from the first inputExp491 detRunInsert(config->dbh, 0, det_type, "run");495 // XXX det_id 496 detRunInsert(config->dbh, 0, 0, det_type, "run"); 492 497 long det_id = psDBLastInsertID(config->dbh); 493 498 … … 538 543 { 539 544 psMetadata *where = psMetadataAlloc(); 540 // map det_id -> position 541 psMetadataAddS32(where, PS_LIST_TAIL, "position", 0, "==", det_id); 545 psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", det_id); 542 546 detRuns = psDBSelectRows(config->dbh, "detRun", where, 0); 543 547 psFree(where); … … 553 557 } 554 558 555 // map position -> det_id556 if (! mapPositionToDetRun(detRuns)) {557 psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");559 // convert det_id to a string externaly 560 if (!convertDetIdToStr(detRuns)) { 561 psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string"); 558 562 psFree(detRuns); 559 563 return false; … … 583 587 } 584 588 585 // map position -> det_id586 if (! mapPositionToDetRun(runs)) {587 psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");589 // convert det_id to a string externaly 590 if (!convertDetIdToStr(runs)) { 591 psError(PS_ERR_UNKNOWN, false, "failed to convert det_id to a string"); 588 592 psFree(runs); 589 593 return false; … … 695 699 " FROM rawImfile" 696 700 " JOIN detInputExp USING(exp_tag) " 697 " JOIN detRun ON detInputExp.det_id = detRun. position"701 " JOIN detRun ON detInputExp.det_id = detRun.det_id" 698 702 " WHERE detRun.state = 'run'" 699 703 ); … … 752 756 // select det_id, det_type & rawImfile * 753 757 // get det_id from detInputExp.det_id 754 // get det_type from detRun. position758 // get det_type from detRun.det_id 755 759 // 756 760 // det_id is in detInputExp … … 763 767 " FROM rawImfile" 764 768 " LEFT JOIN detInputExp USING(exp_tag) " 765 " LEFT JOIN detRun ON detInputExp.det_id = detRun. position"769 " LEFT JOIN detRun ON detInputExp.det_id = detRun.det_id" 766 770 " LEFT JOIN detProcessedImfile" 767 771 " ON detInputExp.det_id = detProcessedImfile.det_id" … … 1033 1037 " FROM detRun" 1034 1038 " JOIN detInputExp" 1035 " ON detRun. position= detInputExp.det_id"1039 " ON detRun.det_id = detInputExp.det_id" 1036 1040 " AND detRun.iteration = detInputExp.iteration" 1037 1041 " JOIN rawDetrendExp" … … 1055 1059 " rawImfile.class_id," 1056 1060 " detInputExp.exp_tag," 1057 " detRun. position"1061 " detRun.det_id" 1058 1062 " HAVING" 1059 1063 " COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)" … … 1191 1195 " FROM detRun" 1192 1196 " JOIN detInputExp" 1193 " ON detRun. position= detInputExp.det_id"1197 " ON detRun.det_id = detInputExp.det_id" 1194 1198 " AND detRun.iteration = detInputExp.iteration" 1195 1199 " JOIN rawDetrendExp" … … 1209 1213 " AND detProcessedExp.exp_tag IS NULL" 1210 1214 " AND detInputExp.include = 1" 1211 " AND detRun. position= %s"1215 " AND detRun.det_id = %s" 1212 1216 " AND detProcessedImfile.exp_tag = '%s'" 1213 1217 " GROUP BY" 1214 1218 " detProcessedImfile.class_id," 1215 1219 " rawImfile.class_id," 1216 " detRun. position"1220 " detRun.det_id" 1217 1221 " HAVING" 1218 1222 " COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)" … … 1342 1346 " FROM detRun" 1343 1347 " JOIN detInputExp" 1344 " ON detRun. position= detInputExp.det_id"1348 " ON detRun.det_id = detInputExp.det_id" 1345 1349 " AND detRun.iteration = detInputExp.iteration" 1346 1350 " JOIN rawDetrendExp" … … 1364 1368 " GROUP BY" 1365 1369 " rawImfile.class_id," 1366 " detRun. position"1370 " detRun.det_id" 1367 1371 " HAVING" 1368 1372 " COUNT(detProcessedImfile.class_id) = COUNT(rawImfile.class_id)" … … 1429 1433 " FROM detProcessedImfile" 1430 1434 " JOIN detRun" 1431 " ON detRun. position= detProcessedImfile.det_id"1435 " ON detRun.det_id = detProcessedImfile.det_id" 1432 1436 " JOIN detInputExp" 1433 " ON detRun. position= detInputExp.det_id"1437 " ON detRun.det_id = detInputExp.det_id" 1434 1438 " AND detRun.iteration = detInputExp.iteration" 1435 1439 " WHERE" … … 1702 1706 PS_ASSERT_PTR_NON_NULL(config, false); 1703 1707 1704 // select detRun. position(det_id)1708 // select detRun.det_id (det_id) 1705 1709 // select detRun.iteration 1706 1710 // by: … … 1717 1721 psString query = psStringCopy( 1718 1722 "SELECT DISTINCT" 1719 " detRun. positionAS det_id,"1723 " detRun.det_id AS det_id," 1720 1724 " detRun.det_type," 1721 1725 " detRun.iteration," … … 1723 1727 " FROM detRun" 1724 1728 " JOIN detInputExp" 1725 " ON detRun. position= detInputExp.det_id"1729 " ON detRun.det_id = detInputExp.det_id" 1726 1730 " AND detRun.iteration = detInputExp.iteration" 1727 1731 " JOIN rawDetrendExp" … … 1731 1735 " AND detInputExp.iteration = detStackedImfile.iteration" 1732 1736 " LEFT JOIN detNormalizedStatImfile" 1733 " ON detRun. position= detNormalizedStatImfile.det_id"1737 " ON detRun.det_id = detNormalizedStatImfile.det_id" 1734 1738 " AND detRun.iteration = detNormalizedStatImfile.iteration" 1735 1739 " WHERE" … … 1740 1744 " rawDetrendExp.exp_tag," 1741 1745 " detRun.iteration," 1742 " detRun. position"1746 " detRun.det_id" 1743 1747 " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)" 1744 1748 ); … … 1922 1926 " FROM detRun" 1923 1927 " JOIN detInputExp" 1924 " ON detRun. position= detInputExp.det_id"1928 " ON detRun.det_id = detInputExp.det_id" 1925 1929 " AND detRun.iteration = detInputExp.iteration" 1926 1930 " JOIN detStackedImfile" 1927 " ON detRun. position= detStackedImfile.det_id"1931 " ON detRun.det_id = detStackedImfile.det_id" 1928 1932 " AND detRun.iteration = detStackedImfile.iteration" 1929 1933 " JOIN detNormalizedStatImfile" 1930 " ON detRun. position= detNormalizedStatImfile.det_id"1934 " ON detRun.det_id = detNormalizedStatImfile.det_id" 1931 1935 " AND detRun.iteration = detNormalizedStatImfile.iteration" 1932 1936 " JOIN rawDetrendExp" 1933 1937 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 1934 1938 " LEFT JOIN detNormalizedImfile" 1935 " ON detRun. position= detNormalizedImfile.det_id"1939 " ON detRun.det_id = detNormalizedImfile.det_id" 1936 1940 " AND detRun.iteration = detNormalizedImfile.iteration" 1937 1941 " AND detNormalizedStatImfile.class_id = detNormalizedImfile.class_id" … … 2231 2235 psString query = psStringCopy( 2232 2236 " SELECT DISTINCT" 2233 " detRun. positionas det_id,"2237 " detRun.det_id as det_id," 2234 2238 " detRun.iteration," 2235 2239 " detRun.det_type," … … 2240 2244 " FROM detRun" 2241 2245 " JOIN detInputExp" 2242 " ON detRun. position= detInputExp.det_id"2246 " ON detRun.det_id = detInputExp.det_id" 2243 2247 " AND detRun.iteration = detInputExp.iteration" 2244 2248 " JOIN rawDetrendExp" … … 2260 2264 " GROUP BY" 2261 2265 " detNormalizedImfile.iteration," 2262 " detRun. position"2266 " detRun.det_id" 2263 2267 " HAVING" 2264 2268 " COUNT(detNormalizedImfile.class_id) = COUNT(rawImfile.class_id)" … … 2386 2390 psString query = psStringCopy( 2387 2391 " SELECT DISTINCT" 2388 " detRun. positionas det_id,"2392 " detRun.det_id as det_id," 2389 2393 " detRun.iteration," 2390 2394 " detRun.det_type," … … 2395 2399 " FROM detRun" 2396 2400 " JOIN detInputExp" 2397 " ON detRun. position= detInputExp.det_id"2401 " ON detRun.det_id = detInputExp.det_id" 2398 2402 " AND detRun.iteration = detInputExp.iteration" 2399 2403 " JOIN rawDetrendExp" … … 2413 2417 " AND detNormalizedExp.iteration IS NULL" 2414 2418 " AND detInputExp.include = 1" 2415 " AND detRun. position= %s"2419 " AND detRun.det_id = %s" 2416 2420 " AND detNormalizedImfile.iteration = %d" 2417 2421 " GROUP BY" 2418 2422 " detNormalizedImfile.iteration," 2419 " detRun. position"2423 " detRun.det_id" 2420 2424 " HAVING" 2421 2425 " COUNT(detNormalizedImfile.class_id) = COUNT(rawImfile.class_id)" … … 2606 2610 " FROM detRun" 2607 2611 " JOIN detInputExp" 2608 " ON detRun. position= detInputExp.det_id"2612 " ON detRun.det_id = detInputExp.det_id" 2609 2613 " AND detRun.iteration = detInputExp.iteration" 2610 2614 " JOIN rawDetrendExp" 2611 2615 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 2612 2616 " JOIN detProcessedImfile" 2613 " ON detRun. position= detProcessedImfile.det_id"2617 " ON detRun.det_id = detProcessedImfile.det_id" 2614 2618 " AND detInputExp.exp_tag = detProcessedImfile.exp_tag" 2615 2619 " JOIN detNormalizedImfile" 2616 " ON detRun. position= detNormalizedImfile.det_id"2620 " ON detRun.det_id = detNormalizedImfile.det_id" 2617 2621 " AND detRun.iteration = detNormalizedImfile.iteration" 2618 2622 " AND detProcessedImfile.class_id = detNormalizedImfile.class_id" 2619 2623 " LEFT JOIN detResidImfile" 2620 " ON detRun. position= detResidImfile.det_id"2624 " ON detRun.det_id = detResidImfile.det_id" 2621 2625 " AND detRun.iteration = detResidImfile.iteration" 2622 2626 " AND detProcessedImfile.exp_tag = detResidImfile.exp_tag" … … 2689 2693 " FROM detNormalizedImfile" 2690 2694 " JOIN detRun" 2691 " ON detNormalizedImfile.det_id = detRun. position"2695 " ON detNormalizedImfile.det_id = detRun.det_id" 2692 2696 " WHERE" 2693 2697 " detRun.state = 'run'" … … 3082 3086 3083 3087 3084 // select detRun. position3088 // select detRun.det_id 3085 3089 // select detRun.iteration 3086 3090 // select detRun.det_type … … 3103 3107 " FROM" 3104 3108 " (SELECT DISTINCT" 3105 " detRun. positionAS det_id,"3109 " detRun.det_id AS det_id," 3106 3110 " detRun.iteration," 3107 3111 " detRun.det_type," … … 3111 3115 " FROM detRun" 3112 3116 " LEFT JOIN detInputExp" 3113 " ON detRun. position= detInputExp.det_id"3117 " ON detRun.det_id = detInputExp.det_id" 3114 3118 " AND detRun.iteration = detInputExp.iteration" 3115 3119 " LEFT JOIN rawDetrendExp" 3116 3120 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3117 3121 " LEFT JOIN detResidImfile" 3118 " ON detRun. position= detResidImfile.det_id"3122 " ON detRun.det_id = detResidImfile.det_id" 3119 3123 " AND detRun.iteration = detResidImfile.iteration" 3120 3124 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 3121 3125 " LEFT JOIN detResidExp" 3122 " ON detRun. position= detResidExp.det_id"3126 " ON detRun.det_id = detResidExp.det_id" 3123 3127 " AND detRun.iteration = detResidExp.iteration" 3124 3128 " AND detInputExp.exp_tag = detResidExp.exp_tag" … … 3131 3135 " detInputExp.exp_tag," 3132 3136 " detRun.iteration," 3133 " detRun. position"3137 " detRun.det_id" 3134 3138 " HAVING" 3135 3139 " rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)" … … 3199 3203 3200 3204 3201 // select detRun. position3205 // select detRun.det_id 3202 3206 // select detRun.iteration 3203 3207 // select detRun.det_type … … 3219 3223 " FROM" 3220 3224 " (SELECT DISTINCT" 3221 " detRun. positionAS det_id,"3225 " detRun.det_id AS det_id," 3222 3226 " detRun.iteration," 3223 3227 " detRun.det_type," … … 3227 3231 " FROM detRun" 3228 3232 " LEFT JOIN detInputExp" 3229 " ON detRun. position= detInputExp.det_id"3233 " ON detRun.det_id = detInputExp.det_id" 3230 3234 " AND detRun.iteration = detInputExp.iteration" 3231 3235 " LEFT JOIN rawDetrendExp" 3232 3236 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3233 3237 " LEFT JOIN detResidImfile" 3234 " ON detRun. position= detResidImfile.det_id"3238 " ON detRun.det_id = detResidImfile.det_id" 3235 3239 " AND detRun.iteration = detResidImfile.iteration" 3236 3240 " AND detInputExp.exp_tag = detResidImfile.exp_tag" 3237 3241 " LEFT JOIN detResidExp" 3238 " ON detRun. position= detResidExp.det_id"3242 " ON detRun.det_id = detResidExp.det_id" 3239 3243 " AND detRun.iteration = detResidExp.iteration" 3240 3244 " AND detInputExp.exp_tag = detResidExp.exp_tag" … … 3247 3251 " detInputExp.exp_tag," 3248 3252 " detRun.iteration," 3249 " detRun. position"3253 " detRun.det_id" 3250 3254 " HAVING" 3251 3255 " rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)" … … 3491 3495 " USING(det_id, exp_tag, iteration)" 3492 3496 " JOIN detRun" 3493 " ON detResidExp.det_id = detRun. position"3497 " ON detResidExp.det_id = detRun.det_id" 3494 3498 " AND detResidExp.iteration = detRun.iteration" 3495 3499 " WHERE" … … 3552 3556 */ 3553 3557 3554 // select detRun. position3558 // select detRun.det_id 3555 3559 // select detRun.iteration 3556 3560 // select detRun.det_type … … 3569 3573 " FROM" 3570 3574 " (SELECT DISTINCT" 3571 " detRun. positionAS det_id,"3575 " detRun.det_id AS det_id," 3572 3576 " detRun.iteration," 3573 3577 " detRun.det_type," … … 3576 3580 " FROM detRun" 3577 3581 " LEFT JOIN detInputExp" 3578 " ON detRun. position= detInputExp.det_id"3582 " ON detRun.det_id = detInputExp.det_id" 3579 3583 " AND detRun.iteration = detInputExp.iteration" 3580 3584 " LEFT JOIN rawDetrendExp" 3581 3585 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3582 3586 " LEFT JOIN detResidExp" 3583 " ON detRun. position= detResidExp.det_id"3587 " ON detRun.det_id = detResidExp.det_id" 3584 3588 " AND detRun.iteration = detResidExp.iteration" 3585 3589 " AND detInputExp.exp_tag = detResidExp.exp_tag" … … 3587 3591 " detRun.state = 'run'" 3588 3592 " GROUP BY" 3589 " detRun. position,"3593 " detRun.det_id," 3590 3594 " detRun.iteration" 3591 3595 " HAVING" … … 3820 3824 PS_ASSERT_PTR_NON_NULL(config, false); 3821 3825 3822 // select detRun. position3826 // select detRun.det_id 3823 3827 // select detRun.iteration 3824 3828 // by: … … 3834 3838 " FROM" 3835 3839 " (SELECT DISTINCT" 3836 " detRun. positionAS det_id,"3840 " detRun.det_id AS det_id," 3837 3841 " detRun.iteration," 3838 3842 " detInputExp.exp_tag" 3839 3843 " FROM detRun" 3840 3844 " LEFT JOIN detInputExp" 3841 " ON detRun. position= detInputExp.det_id"3845 " ON detRun.det_id = detInputExp.det_id" 3842 3846 " AND detRun.iteration = detInputExp.iteration" 3843 3847 " LEFT JOIN rawDetrendExp" 3844 3848 " ON detInputExp.exp_tag = rawDetrendExp.exp_tag" 3845 3849 " LEFT JOIN detResidExp" 3846 " ON detRun. position= detResidExp.det_id"3850 " ON detRun.det_id = detResidExp.det_id" 3847 3851 " AND detRun.iteration = detResidExp.iteration" 3848 3852 " AND detInputExp.exp_tag = detResidExp.exp_tag" … … 3850 3854 " detRun.state = 'run'" 3851 3855 " GROUP BY" 3852 " detRun. position,"3856 " detRun.det_id," 3853 3857 " detRun.iteration" 3854 3858 " HAVING" … … 4067 4071 // -again 4068 4072 4069 // select detRun. position4073 // select detRun.det_id 4070 4074 // select detRun.iteration 4071 4075 // select detInputExp.exp_tag … … 4079 4083 psString query = psStringCopy( 4080 4084 "SELECT DISTINCT" 4081 " detRun. positionAS det_id,"4085 " detRun.det_id AS det_id," 4082 4086 " detRun.iteration," 4083 4087 " detInputExp.exp_tag," … … 4085 4089 " FROM detRun" 4086 4090 " JOIN detInputExp" 4087 " ON detRun. position= detInputExp.det_id"4091 " ON detRun.det_id = detInputExp.det_id" 4088 4092 " AND detRun.iteration = detInputExp.iteration" 4089 4093 " JOIN detResidExp" 4090 " ON detRun. position= detResidExp.det_id"4094 " ON detRun.det_id = detResidExp.det_id" 4091 4095 " AND detRun.iteration = detResidExp.iteration" 4092 4096 " AND detInputExp.exp_tag = detResidExp.exp_tag" … … 4099 4103 psStringAppend ( 4100 4104 &query, 4101 " AND detRun. position= '%s'", det_id);4105 " AND detRun.det_id = '%s'", det_id); 4102 4106 4103 4107 psStringAppend ( 4104 4108 &query, 4105 4109 " GROUP BY" 4106 " detRun. position,"4110 " detRun.det_id," 4107 4111 " detRun.iteration," 4108 4112 " detInputExp.exp_tag" … … 4374 4378 PS_ASSERT_PTR_NON_NULL(det_id, 0); 4375 4379 4376 char *query = "UPDATE detRun SET iteration = iteration + 1 WHERE position= '%s'";4380 char *query = "UPDATE detRun SET iteration = iteration + 1 WHERE det_id = '%s'"; 4377 4381 if (!p_psDBRunQuery(config->dbh, query, det_id)) { 4378 4382 psError(PS_ERR_UNKNOWN, false, … … 4382 4386 4383 4387 psMetadata *where = psMetadataAlloc(); 4384 if (!psMetadataAddS32(where, PS_LIST_TAIL, " position", 0, "==",4388 if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==", 4385 4389 (psS32)atol(det_id))) { 4386 4390 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); … … 4414 4418 PS_ASSERT_PTR_NON_NULL(state, false); 4415 4419 4416 char *query = "UPDATE detRun SET state = '%s' WHERE position= '%s'";4420 char *query = "UPDATE detRun SET state = '%s' WHERE det_id = '%s'"; 4417 4421 if (!p_psDBRunQuery(config->dbh, query, state, det_id)) { 4418 4422 psError(PS_ERR_UNKNOWN, false,
Note:
See TracChangeset
for help on using the changeset viewer.
