Changeset 8364
- Timestamp:
- Aug 15, 2006, 4:26:00 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r8354 r8364 41 41 42 42 static bool mapPositionToDetRun(psArray *mds); 43 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile); 43 44 static psArray *validDetInputClassIds(pxConfig *config, const char *det_id); 44 45 static psArray *searchInputImfiles(pxConfig *config, const char *det_id); … … 1720 1721 " AND detInputExp.iteration = detStackedImfile.iteration" 1721 1722 " GROUP BY" 1722 " rawDetrendExp. imfiles"1723 " rawDetrendExp.exp_id" 1723 1724 " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)" 1724 1725 ); … … 1771 1772 static bool addnormstatMode(pxConfig *config) 1772 1773 { 1773 return true; 1774 PS_ASSERT_PTR_NON_NULL(config, NULL); 1775 1776 // select * from detStackedImfile 1777 // by det_id, iteration, class_id 1778 // where det_id, iteration, class_id is not in detNormalizedStatImfile 1779 psString query = psStringCopy( 1780 "SELECT DISTINCT" 1781 " detStackedImfile.*" 1782 " FROM detStackedImfile" 1783 " LEFT JOIN detNormalizedStatImfile" 1784 " USING(det_id, iteration, class_id)" 1785 " WHERE" 1786 " detNormalizedStatImfile.det_id IS NULL" 1787 " AND detNormalizedStatImfile.iteration IS NULL" 1788 " AND detNormalizedStatImfile.class_id IS NULL" 1789 ); 1790 1791 #if 0 1792 if (config->where) { 1793 psString whereClaus = psDBGenerateWhereConditionSQL(config->where); 1794 psStringAppend(&query, " AND %s", whereClaus); 1795 psFree(whereClaus); 1796 } 1797 #endif 1798 1799 if (!p_psDBRunQuery(config->dbh, query)) { 1800 psError(PS_ERR_UNKNOWN, false, "database error"); 1801 psFree(query); 1802 return false; 1803 } 1804 psFree(query); 1805 1806 psArray *output = p_psDBFetchResult(config->dbh); 1807 if (!output) { 1808 // XXX check psError here 1809 psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found"); 1810 return false; 1811 } 1812 1813 // start a transaction so it's all rows or nothing 1814 if (!psDBTransaction(config->dbh)) { 1815 psError(PS_ERR_UNKNOWN, false, "database error"); 1816 psFree(output); 1817 return false; 1818 } 1819 1820 for (long i = 0; i < psArrayLength(output); i++) { 1821 psMetadata *row = output->data[i]; 1822 // convert metadata into a detStackedImfile object 1823 detStackedImfileRow *stackedImfile = detStackedImfileObjectFromMetadata(row); 1824 // convert detStackedImfile object into a detNormalizedStat object 1825 detNormalizedStatImfileRow *stat = detStackedToDetNormalizedStatImfile(config, stackedImfile); 1826 psFree(stackedImfile); 1827 if (!stat) { 1828 if (!psDBRollback(config->dbh)) { 1829 psError(PS_ERR_UNKNOWN, false, "database error"); 1830 } 1831 psError(PS_ERR_UNKNOWN, false, "failed to convert detStackedImfile to detNormalizedStatImfile"); 1832 psFree(output); 1833 return false; 1834 } 1835 // insert detNormlized Stat object into the database 1836 if (!detNormalizedStatImfileInsertObject(config->dbh, stat)) { 1837 if (!psDBRollback(config->dbh)) { 1838 psError(PS_ERR_UNKNOWN, false, "database error"); 1839 } 1840 psError(PS_ERR_UNKNOWN, false, "database error"); 1841 psFree(stat); 1842 psFree(output); 1843 } 1844 psFree(stat); 1845 } 1846 1847 psFree(output); 1848 1849 if (!psDBCommit(config->dbh)) { 1850 psError(PS_ERR_UNKNOWN, false, "database error"); 1851 return false; 1852 } 1853 1854 return true; 1855 } 1856 1857 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile) 1858 { 1859 PS_ASSERT_PTR_NON_NULL(config, NULL); 1860 PS_ASSERT_PTR_NON_NULL(stackedImfile, NULL); 1861 1862 bool status = false; 1863 psF32 norm = psMetadataLookupF32(&status, config->args, "-norm"); 1864 if (!status) { 1865 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -norm"); 1866 return false; 1867 } 1868 if (isnan(norm)) { 1869 psError(PS_ERR_UNKNOWN, true, "-norm is required"); 1870 return false; 1871 } 1872 1873 return detNormalizedStatImfileRowAlloc( 1874 stackedImfile->det_id, 1875 stackedImfile->iteration, 1876 stackedImfile->class_id, 1877 norm 1878 ); 1774 1879 } 1775 1880 1776 1881 static bool normstatMode(pxConfig *config) 1777 1882 { 1883 PS_ASSERT_PTR_NON_NULL(config, NULL); 1884 1778 1885 return true; 1779 1886 }
Note:
See TracChangeset
for help on using the changeset viewer.
