Changeset 20692
- Timestamp:
- Nov 11, 2008, 2:55:35 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/magictool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/magictool.c
r18701 r20692 801 801 if (!psArrayLength(output)) { 802 802 psTrace("magictool", PS_LOG_INFO, "no rows found"); 803 // psFree(output);804 // return true;805 803 } 806 804 … … 843 841 } 844 842 845 psHash *forest = psHashAlloc(psArrayLength(magicTree)); 846 847 // convert the array of metadata into a pxTree structure 848 for (long i = 0; i < psArrayLength(magicTree); i++) { 843 // entries are ordered by magic_id 844 long index = 0; 845 while (index < psArrayLength(magicTree)) { 849 846 bool status; 850 psS tring node = psMetadataLookupStr(&status, magicTree->data[i], "node");847 psS64 current_magic_id = psMetadataLookupS64(&status, magicTree->data[index], "magic_id"); 851 848 if (!status) { 852 psAbort("failed to lookup value for node column"); 853 } 854 855 psString dep = psMetadataLookupStr(&status, magicTree->data[i], "dep"); 856 if (!status) { 857 psAbort("failed to lookup value for dep column"); 858 } 859 860 pxTreeBuilder(forest, node, dep, magicTree->data[i]); 861 862 } 863 psFree(magicTree); 864 865 // find the root of the tree 866 pxNode *root = psMemIncrRefCounter(psHashLookup(forest, "root")); 867 psFree(forest); 868 // pxTreePrint(stdout, root); 869 870 // crawl through the tree and looking for nodes with children that are all 871 // "done" 872 pxTreeCrawl(root, findReadyNodes, output); 873 psFree(root); 849 psAbort("failed to lookup value for magic_id column"); 850 } 851 852 // find the end of this block 853 long first = index; 854 long last = index; 855 for (long i = index + 1; i < psArrayLength(magicTree); i++) { 856 psS64 magic_id = psMetadataLookupS64(&status, magicTree->data[i], "magic_id"); 857 if (!status) { 858 psAbort("failed to lookup value for magic_id column"); 859 } 860 if (magic_id != current_magic_id) { 861 break; 862 } 863 last = i; 864 } 865 866 index = last + 1; 867 868 psHash *forest = psHashAlloc(last - first + 1); 869 870 // convert the array of metadata into a pxTree structure 871 for (long i = first; i <= last; i++) { 872 bool status; 873 psString node = psMetadataLookupStr(&status, magicTree->data[i], "node"); 874 if (!status) { 875 psAbort("failed to lookup value for node column"); 876 } 877 878 psString dep = psMetadataLookupStr(&status, magicTree->data[i], "dep"); 879 if (!status) { 880 psAbort("failed to lookup value for dep column"); 881 } 882 883 pxTreeBuilder(forest, node, dep, magicTree->data[i]); 884 885 } 886 887 // find the root of the tree 888 pxNode *root = psMemIncrRefCounter(psHashLookup(forest, "root")); 889 psFree(forest); 890 // pxTreePrint(stdout, root); 891 892 // crawl through the tree and looking for nodes with children that are all 893 // "done" 894 pxTreeCrawl(root, findReadyNodes, output); 895 psFree(root); 896 897 } 874 898 875 899 if (psArrayLength(output)) { … … 882 906 } 883 907 908 psFree(magicTree); 884 909 psFree(output); 885 910 psFree(whereClause);
Note:
See TracChangeset
for help on using the changeset viewer.
