- Timestamp:
- 01/13/09 15:07:31 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSet.cs
r1106 r1116 48 48 // lazy loading of problem from DB 49 49 if (problem == null) { 50 IList<Statement>persistedData = Store.Select(new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, Ontology.AnyEntity));51 if (persistedData.Count == 1) {52 Literal persistedLiteral = (Literal)persistedData [0].Property;50 var persistedData = Store.Select(new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, Ontology.AnyEntity)); 51 if (persistedData.Count() == 1) { 52 Literal persistedLiteral = (Literal)persistedData.First().Property; 53 53 this.problem = (Problem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String((string)persistedLiteral.Value)); 54 54 } else 55 55 this.problem = new Problem(); // no entry in the DB => create a new problem 56 56 } 57 return problem; 57 return problem; 58 58 } 59 59 } … … 69 69 Store = store; 70 70 guid = new Guid(dataSetEntity.Uri.Remove(0, Ontology.CedmaNameSpace.Length)); 71 IList<Statement>names = store.Select(new Statement(dataSetEntity, Ontology.PredicateName, Ontology.AnyEntity));72 if (names.Count > 0) name = (string)((Literal)names[0].Property).Value;71 var names = store.Select(new Statement(dataSetEntity, Ontology.PredicateName, Ontology.AnyEntity)); 72 if (names.Count() > 0) name = (string)((Literal)names.First().Property).Value; 73 73 else name = guid.ToString(); 74 74 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetList.cs
r992 r1116 41 41 store = value; 42 42 Action reload = ReloadList; 43 lock (dataSetList) {43 lock (dataSetList) { 44 44 dataSetList.Clear(); 45 45 } … … 58 58 59 59 private void ReloadList() { 60 IList<Statement>statements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet));61 foreach (Statement s in statements) {60 var statements = store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateInstanceOf, Ontology.TypeDataSet)); 61 foreach (Statement s in statements) { 62 62 DataSet d = new DataSet(store, s.Subject); 63 lock (dataSetList) {63 lock (dataSetList) { 64 64 dataSetList.Add(d); 65 65 } … … 70 70 public IEnumerator<DataSet> GetEnumerator() { 71 71 List<DataSet> dataSets = new List<DataSet>(); 72 lock (dataSets) {72 lock (dataSets) { 73 73 dataSets.AddRange(dataSetList); 74 74 } -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/DataSetView.cs
r1109 r1116 84 84 }; 85 85 worker.DoWork += delegate(object doWorkSender, DoWorkEventArgs doWorkArgs) { 86 worker.ReportProgress(10); 87 results.GetEntries().Last(); // preload list by accessing last element 86 int n = results.GetEntries().Count(); 87 int i = 0; 88 // preload list 89 foreach (var entry in results.GetEntries()) { 90 i++; 91 if((((i*100) / n) % 10) == 0) worker.ReportProgress((i * 100) / n); 92 } 88 93 worker.ReportProgress(100); 89 94 }; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Results.cs
r1109 r1116 64 64 65 65 private List<ResultsEntry> entries = null; 66 private bool cached = false; 66 67 public IEnumerable<ResultsEntry> GetEntries() { 67 if ( entries == null)68 Reload();68 if (!cached) 69 return SelectRows(); 69 70 return entries.AsEnumerable(); 70 }71 72 internal void Reload() {73 entries = SelectRows().ToList();74 FireChanged();75 71 } 76 72 … … 78 74 if (store == null) yield break; 79 75 80 var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity)) 81 .SelectMany(x => store.Select(new SelectFilter( 82 new Entity[] { (Entity)x.Property }, 83 new Entity[] { Ontology.PredicateModelAttribute }, 84 new Resource[] { Ontology.AnyEntity }))) 85 .SelectMany(x => 86 store.Select( 87 new SelectFilter( 88 new Entity[] { (Entity)x.Property }, 89 new Entity[] { Ontology.PredicateModelAttributeName }, 90 new Entity[] { Ontology.AnyEntity })).Select(y => 91 new { 92 Model = x.Subject, 93 Attribute = (Entity)x.Property, 94 AttributeName = (Literal)y.Property 95 })) 96 .SelectMany(x => 97 store.Select( 98 new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity)) 99 .Select(y => 100 new { 101 Model = x.Model.Uri, 102 AttributeName = x.AttributeName.Value, 103 AttributeValue = ((Literal)y.Property).Value 104 })).GroupBy(x => x.Model); 76 var models = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity)); 105 77 78 //var results = store.Select(new Statement(dataSetEntity, Ontology.PredicateHasModel, Ontology.AnyEntity)) 79 // .SelectMany(x => store.Select(new SelectFilter( 80 // new Entity[] { (Entity)x.Property }, 81 // new Entity[] { Ontology.PredicateModelAttribute }, 82 // new Resource[] { Ontology.AnyEntity }))) 83 // .SelectMany(x => 84 // store.Select( 85 // new SelectFilter( 86 // new Entity[] { (Entity)x.Property }, 87 // new Entity[] { Ontology.PredicateModelAttributeName }, 88 // new Entity[] { Ontology.AnyEntity })).Select(y => 89 // new { 90 // Model = x.Subject, 91 // Attribute = (Entity)x.Property, 92 // AttributeName = (Literal)y.Property 93 // })) 94 // .SelectMany(x => 95 // store.Select( 96 // new Statement(x.Attribute, Ontology.PredicateModelAttributeValue, Ontology.AnyEntity)) 97 // .Select(y => 98 // new { 99 // Model = x.Model.Uri, 100 // AttributeName = x.AttributeName.Value, 101 // AttributeValue = ((Literal)y.Property).Value 102 // })).GroupBy(x => x.Model); 106 103 107 Random random = new Random(); 104 entries = new List<ResultsEntry>(); 105 foreach (var model in models) { 106 var attributes = store.Select(new Statement((Entity)model.Property, Ontology.PredicateModelAttribute, Ontology.AnyEntity)); 107 108 foreach (var attr in attributes) { 109 var namesAndValues = store 110 .Select(new SelectFilter(new Entity[] { (Entity)attr.Property }, 111 new Entity[] { Ontology.PredicateModelAttributeName, Ontology.PredicateModelAttributeValue }, 112 new Entity[] { Ontology.AnyEntity })); 113 } 114 } 115 108 116 foreach (var row in results) { 109 117 ResultsEntry entry = new ResultsEntry(row.First().Model); … … 111 119 entry.Set((string)attr.AttributeName, attr.AttributeValue); 112 120 } 121 entries.Add(entry); 113 122 yield return entry; 114 123 } 124 125 FireChanged(); 126 cached = true; 115 127 } 116 128 … … 120 132 var attributeNames = 121 133 store.Select(new Statement(Ontology.AnyEntity, Ontology.PredicateModelAttributeName, Ontology.AnyEntity)) 122 .Select(s => (string)((Literal)s.Property).Value) 134 .Select(s => (string)((Literal)s.Property).Value) 123 135 .Distinct(); 124 136 foreach (var name in attributeNames) {
Note: See TracChangeset
for help on using the changeset viewer.