Changeset 1029
- Timestamp:
- 12/18/08 15:33:04 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.ADODataAccess
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs
r1026 r1029 39 39 new CacheT(); 40 40 41 protected IDictionary< RowT, DataTable> parentTable =42 new Dictionary< RowT, DataTable>();41 protected IDictionary<long, DataTable> dataTable = 42 new Dictionary<long, DataTable>(); 43 43 44 44 protected ICollection<ICachedDataAdapter> parentAdapters = … … 131 131 } 132 132 133 protected virtual void RemoveRowFromCache(RowT row) { 134 if (parentTable.ContainsKey(row)) { 135 parentTable[row].Rows.Add(row); 136 parentTable.Remove(row); 137 } 138 133 protected virtual void RemoveRowFromCache(RowT row) { 139 134 cache.Rows.Remove(row); 140 135 } 141 136 142 137 protected virtual bool IsCached(RowT row) { 143 return cache.Contains<RowT>(row); 138 if (row == null) 139 return false; 140 else 141 return FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null; 144 142 } 145 143 … … 173 171 } 174 172 173 obj.Id = (long)row[row.Table.PrimaryKey[0]]; 174 175 175 Convert(obj, row); 176 176 177 if (!IsCached(row)) 178 UpdateRow(row); 179 177 180 if (IsCached(row) && 178 181 !PutInCache(obj)) { 179 182 //remove from cache 183 dataTable[obj.Id].ImportRow(row); 184 dataTable.Remove(obj.Id); 185 186 UpdateRow(row); 180 187 RemoveRowFromCache(row); 181 UpdateRow(row);182 188 } else if (!IsCached(row) && 183 189 PutInCache(obj)) { 184 190 //add to cache 185 if (row.Table != null) { 186 parentTable[row] = row.Table; 187 row.Table.Rows.Remove(row); 188 } 189 cache.Rows.Add(row); 191 cache.ImportRow(row); 192 193 dataTable[obj.Id] = row.Table; 194 row.Table.Rows.Remove(row); 190 195 } 191 192 obj.Id = (long)row[row.Table.PrimaryKey[0]];193 194 if (!IsCached(row))195 UpdateRow(row);196 196 } 197 197 } -
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs
r1021 r1029 156 156 } 157 157 158 public override void SyncWithDb() { 158 public override void SyncWithDb() { 159 159 this.adapter.Update(this.cache); 160 160 } … … 162 162 protected override bool PutInCache(Job job) { 163 163 return job != null 164 && job.State != State.offline165 && job.State != State.nullState;164 && (job.State == State.calculating 165 || job.State == State.idle); 166 166 } 167 167
Note: See TracChangeset
for help on using the changeset viewer.