} /* UpdateProcess */ private void UpdateProcessAdd(PicesDataBase updDbConn) { updDbConn.MLClassInsert(newClassEntry); if (updDbConn.Valid()) { RunLogAddMsg("Class [" + newClassEntry.Name + "] Inserted into database." + "\n"); } else { RunLogAddMsg("Error inserting Class [" + newClassEntry.Name + "] into database." + "\n"); RunLogAddMsg(updDbConn.LastErrorDesc() + "\n"); } }
} /* ImportValidatedClassAssignments */ private PicesClass GetClassFromName(PicesDataBase threadConn, String _name ) { PicesClass pc = threadConn.MLClassLoad(_name); if (pc == null) { pc = new PicesClass(_name, ""); threadConn.MLClassInsert(pc); } return(pc); }
} /* ProcessOneFeatureVector */ private PicesClass UpdateClassId(PicesClass mlClass) { // We lock 'predictionUpdateQueue' because all other classification processes refer to it. // lock (predictionUpdateQueue) { // Maybe another Classification process already updated the database and hence updated the classId field. if (mlClass.ClassId >= 0) { //int zed = 888; } else { String className = mlClass.Name; String parentName = mlClass.ParentName; if (String.IsNullOrEmpty(parentName)) { parentName = "AllClasses"; mlClass.Parent = PicesClassList.GetUniqueClass(parentName, ""); } if (runLog == null) { runLog = new PicesRunLog(); } PicesDataBase dbConn = null; if (dbServer == null) { dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); } else { dbConn = new PicesDataBase(dbServer, runLog); } mlClass.Description = "Added by 'Classification'"; dbConn.MLClassInsert(mlClass); if (mlClass.ClassId < 0) { PicesClass pc = dbConn.MLClassLoad(className); if (mlClass.ClassId < 0) { runLog.Writeln("ClassifierProcess.UpdateClassId ***ERROR*** mlClass.ClassId < 0 ClassName[" + className + "]"); } } // I do not know what the impact of opening and closing a lot of connections // to the MySQL data base will be, and since this method should only get called // when a new MLClass is introduced I want to sleep a little to make // sure that we do not over stress resources that I am not aware of. Thread.Sleep(100); //dbConn.Close (); dbConn = null; GC.Collect(); } } return(mlClass); }