Changeset 25051 for branches/czw_branch/cleanup/ippTools/src/magictool.c
- Timestamp:
- Aug 11, 2009, 3:54:00 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/magictool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk merged: 24940-24950,24953-24971,24973-24977,24986-24989,24993-25017,25019,25021,25023-25024,25026,25029-25031,25036-25049
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/ippTools/src/magictool.c
r24951 r25051 582 582 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 583 583 PXOPT_COPY_S16(config->args, where, "-fault", "fault", "=="); 584 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 584 585 585 586 psString query = psStringCopy("UPDATE magicRun SET fault = 0, state = 'new' WHERE fault != 0"); … … 803 804 // treat limit == 0 as "no limit" 804 805 if (limit) { 805 psString limitString = psDBGenerateLimitSQL(limit); 806 // cut limit in half 807 // hack to prevent pending leaf nodes from blocking branch nodes 808 psString limitString = psDBGenerateLimitSQL((limit + 1) / 2); 806 809 psStringAppend(&query, " %s", limitString); 807 810 psFree(limitString); … … 849 852 850 853 // look for tree nodes that need to be processed 851 // XXX: This gets all nodes from all magicRuns that are in 'new'state 852 // That doens't seem particularly efficient 853 query = pxDataGet("magictool_toprocess_tree.sql"); 854 query = pxDataGet("magictool_toprocess_runs.sql"); 854 855 if (!query) { 855 856 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 857 858 } 858 859 860 { 861 psString limitString = psDBGenerateLimitSQL( 100 ); 862 psStringAppend(&query, " %s", limitString); 863 psFree(limitString); 864 } 859 865 860 866 if (!p_psDBRunQueryF(config->dbh, query, whereString ? whereString : "")) { … … 867 873 psFree(query); 868 874 869 psArray *magic Tree= p_psDBFetchResult(config->dbh);870 if (!magic Tree) {875 psArray *magicRuns = p_psDBFetchResult(config->dbh); 876 if (!magicRuns) { 871 877 psErrorCode err = psErrorCodeLast(); 872 878 switch (err) { … … 881 887 return false; 882 888 } 883 if (!psArrayLength(magic Tree)) {889 if (!psArrayLength(magicRuns)) { 884 890 psTrace("magictool", PS_LOG_INFO, "no rows found"); 885 psFree(magic Tree);891 psFree(magicRuns); 886 892 return true; 887 893 } 888 894 889 // entries are ordered by magic_id 890 long index = 0; 891 while (index < psArrayLength(magicTree)) { 892 bool status; 895 query = pxDataGet("magictool_toprocess_tree.sql"); 896 if (!query) { 897 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 898 return false; 899 } 900 901 for (psS64 index = 0; index < psArrayLength(magicRuns); index++) { 893 902 if (limit && (psArrayLength(output) >= limit)) { 894 903 break; 895 904 } 896 psS64 current_magic_id = psMetadataLookupS64(&status, magicTree->data[index], "magic_id"); 905 bool status; 906 psS64 magic_id = psMetadataLookupS64(&status, magicRuns->data[index], "magic_id"); 897 907 if (!status) { 898 908 psAbort("failed to lookup value for magic_id column"); 899 909 } 900 901 // find the end of this block 902 long first = index; 903 long last = index; 904 for (long i = index + 1; i < psArrayLength(magicTree); i++) { 905 psS64 magic_id = psMetadataLookupS64(&status, magicTree->data[i], "magic_id"); 906 if (!status) { 907 psAbort("failed to lookup value for magic_id column"); 910 911 whereString = NULL; 912 psStringAppend(&whereString, "\nAND (magic_id = %" PRId64 ")", magic_id); 913 if (!p_psDBRunQueryF(config->dbh, query, whereString )) { 914 psError(PS_ERR_UNKNOWN, false, "database error"); 915 psFree(whereString); 916 psFree(query); 917 return false; 918 } 919 psFree(whereString); 920 psArray *magicTree = p_psDBFetchResult(config->dbh); 921 if (!magicTree) { 922 psErrorCode err = psErrorCodeLast(); 923 switch (err) { 924 case PS_ERR_DB_CLIENT: 925 psError(PXTOOLS_ERR_SYS, false, "database error"); 926 case PS_ERR_DB_SERVER: 927 psError(PXTOOLS_ERR_PROG, false, "database error"); 928 default: 929 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 908 930 } 909 if (magic_id != current_magic_id) { 910 break; 911 } 912 last = i; 913 } 914 915 index = last + 1; 916 917 psHash *forest = psHashAlloc(last - first + 1); 931 932 return false; 933 } 934 psS64 length = psArrayLength(magicTree); 935 if (!length) { 936 psTrace("magictool", PS_LOG_INFO, "no rows found for magic_id %" PRId64, magic_id); 937 psFree(magicTree); 938 continue; 939 } 940 941 psHash *forest = psHashAlloc(length); 918 942 919 943 // convert the array of metadata into a pxTree structure 920 for (long i = first; i <= last; i++) {944 for (long i = 0; i < length; i++) { 921 945 bool status; 922 946 psString node = psMetadataLookupStr(&status, magicTree->data[i], "node"); … … 943 967 pxTreeCrawl(root, findReadyNodes, output); 944 968 psFree(root); 945 946 } 947 psFree(magicTree); 969 psFree(magicTree); 970 } 948 971 949 972 if (psArrayLength(output)) {
Note:
See TracChangeset
for help on using the changeset viewer.
