Changeset 1417 for trunk/sources/HeuristicLab.CEDMA.Core/Results.cs
- Timestamp:
- 03/25/09 14:48:56 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/Results.cs
r1287 r1417 37 37 namespace HeuristicLab.CEDMA.Core { 38 38 public class Results : ItemBase { 39 private const int PAGE_SIZE = 1000; 39 40 private string[] categoricalVariables = null; 40 41 public string[] CategoricalVariables { … … 84 85 85 86 private IEnumerable<ResultsEntry> SelectRows() { 87 int page = 0; 88 int resultsReturned = 0; 89 bool newEntry = false; 86 90 if (store == null) yield break; 87 91 entries = new List<ResultsEntry>(); 88 var results = store.Query("<" + dataSetEntity + "> <" + Ontology.PredicateHasModel + "> ?Model ." + Environment.NewLine + 89 "?Model ?Attribute ?Value .") 90 .GroupBy(x => (Entity)x.Get("Model")); 91 foreach (var modelBindings in results) { 92 ResultsEntry entry = new ResultsEntry(modelBindings.Key.Uri); 93 foreach (var binding in modelBindings) { 94 if (binding.Get("Value") is Literal) { 95 string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, ""); 96 if (entry.Get(name) == null) { 97 object value = ((Literal)binding.Get("Value")).Value; 98 entry.Set(name, value); 92 do { 93 var allBindings = store.Query("<" + dataSetEntity + "> <" + Ontology.PredicateHasModel + "> ?Model ." + Environment.NewLine + 94 "?Model ?Attribute ?Value .", page, PAGE_SIZE); 95 var allModelBindings = allBindings.GroupBy(x => (Entity)x.Get("Model")); 96 resultsReturned = allBindings.Count; 97 98 foreach (var modelBindings in allModelBindings) { 99 ResultsEntry entry = entries.FirstOrDefault(x => x.Uri == modelBindings.Key.Uri); 100 newEntry = false; 101 if (entry == null) { 102 entry = new ResultsEntry(); 103 entry.Uri = modelBindings.Key.Uri; 104 entries.Add(entry); 105 newEntry = true; 106 } 107 foreach (var binding in modelBindings) { 108 if (binding.Get("Value") is Literal) { 109 string name = ((Entity)binding.Get("Attribute")).Uri.Replace(Ontology.CedmaNameSpace, ""); 110 if (entry.Get(name) == null) { 111 object value = ((Literal)binding.Get("Value")).Value; 112 entry.Set(name, value); 113 } 99 114 } 100 115 } 116 if (newEntry) yield return entry; 101 117 } 102 entries.Add(entry); 103 yield return entry; 104 } 118 page++; 119 } while (resultsReturned == PAGE_SIZE); 105 120 106 121 FireChanged(); … … 114 129 private void LoadModelAttributes() { 115 130 this.ordinalVariables = 116 store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeOrdinalAttribute + "> ." )131 store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeOrdinalAttribute + "> .", 0, 100) 117 132 .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, "")) 118 133 .ToArray(); 119 134 this.categoricalVariables = 120 store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeCategoricalAttribute + "> ." )135 store.Query("?ModelAttribute <" + Ontology.PredicateInstanceOf + "> <" + Ontology.TypeCategoricalAttribute + "> .", 0, 100) 121 136 .Select(s => ((Entity)s.Get("ModelAttribute")).Uri.Replace(Ontology.CedmaNameSpace, "")) 122 137 .ToArray();
Note: See TracChangeset
for help on using the changeset viewer.