- Timestamp:
- 03/25/09 14:48:56 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Core/Console.cs
r1287 r1417 32 32 namespace HeuristicLab.CEDMA.Core { 33 33 public class Console : ItemBase, IEditable { 34 private DataSetList dataSetList;35 private ChannelFactory<IStore> factory;36 private IStore store;37 34 private string serverUri; 38 35 public string ServerUri { … … 40 37 } 41 38 39 private DataSetList dataSetList; 42 40 public DataSetList DataSetList { 43 41 get { return dataSetList; } … … 72 70 #endregion 73 71 74 #region WCF75 private void ResetConnection() {76 NetTcpBinding binding = new NetTcpBinding();77 binding.ReceiveTimeout = new TimeSpan(1, 0, 0);78 binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes79 binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars80 binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;81 factory = new ChannelFactory<IStore>(binding);82 store = factory.CreateChannel(new EndpointAddress(serverUri));83 dataSetList.Store = store;84 }85 #endregion86 87 72 internal void Connect(string serverUri) { 88 this.serverUri = serverUri; 89 ResetConnection(); 73 DataSetList.Store = new StoreProxy(serverUri); 90 74 } 91 75 } -
trunk/sources/HeuristicLab.CEDMA.Core/DataSet.cs
r1287 r1417 49 49 // lazy loading of problem from DB 50 50 if (problem == null) { 51 //var serializedDataVar = new HeuristicLab.CEDMA.DB.Interfaces.Variable("SerializedData");52 //var persistedData = Store.Query(53 // new Statement[] { new Statement(new Entity(Ontology.CedmaNameSpace + Guid), Ontology.PredicateSerializedData, serializedDataVar)});54 51 var persistedData = Store.Query( 55 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData ." );52 "<" + Ontology.CedmaNameSpace + Guid + "> <" + Ontology.PredicateSerializedData.Uri + "> ?SerializedData .", 0, 10); 56 53 if (persistedData.Count() == 1) { 57 54 Literal persistedLiteral = (Literal)persistedData.First().Get("SerializedData"); -
trunk/sources/HeuristicLab.CEDMA.Core/DataSetList.cs
r1287 r1417 62 62 var bindings = store.Query( 63 63 "?DataSet <"+Ontology.PredicateInstanceOf.Uri+"> <"+Ontology.TypeDataSet.Uri+"> ." + Environment.NewLine + 64 "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name ."); 65 // new Statement[] { 66 // new Statement(dataSetVar, Ontology.PredicateInstanceOf, Ontology.TypeDataSet), 67 // new Statement(dataSetVar, Ontology.PredicateName, dataSetNameVar) 68 //}); 64 "?DataSet <"+Ontology.PredicateName.Uri+"> ?Name .",0, 100); 69 65 foreach (var binding in bindings) { 70 66 DataSet d = new DataSet(store, (Entity)binding.Get("DataSet")); -
trunk/sources/HeuristicLab.CEDMA.Core/HeuristicLab.CEDMA.Core.csproj
r1290 r1417 72 72 </ItemGroup> 73 73 <ItemGroup> 74 <Compile Include="StoreProxy.cs" /> 74 75 <Compile Include="IResultsViewFactory.cs" /> 75 76 <Compile Include="ResultsEntry.cs" /> -
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(); -
trunk/sources/HeuristicLab.CEDMA.Core/ResultsEntry.cs
r1287 r1417 43 43 44 44 private string uri; 45 public string Uri { get { return uri; } } 46 47 public ResultsEntry(string uri) { 48 this.uri = uri; 45 public string Uri { 46 get { return uri; } 47 set { uri = value; } 49 48 } 50 49 -
trunk/sources/HeuristicLab.CEDMA.DB.Interfaces/IStore.cs
r1287 r1417 35 35 36 36 [OperationContract] 37 ICollection<VariableBindings> Query(ICollection<Statement> query );37 ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize); 38 38 39 39 [OperationContract(Name="QueryN3")] 40 ICollection<VariableBindings> Query(string query );40 ICollection<VariableBindings> Query(string query, int page, int pageSize); 41 41 } 42 42 } -
trunk/sources/HeuristicLab.CEDMA.DB/Store.cs
r1287 r1417 62 62 63 63 64 public ICollection<VariableBindings> Query(string query ) {64 public ICollection<VariableBindings> Query(string query, int page, int pageSize) { 65 65 MyQueryResultSink resultSink = new MyQueryResultSink(); 66 66 SemWeb.N3Reader n3Reader = new SemWeb.N3Reader(new StringReader(query)); 67 67 SemWeb.Query.GraphMatch matcher = new SemWeb.Query.GraphMatch(n3Reader); 68 68 matcher.Run(store, resultSink); 69 return resultSink.Bindings ;70 } 71 72 public ICollection<VariableBindings> Query(ICollection<Statement> query ) {69 return resultSink.Bindings.Skip(page*pageSize).Take(pageSize).ToList(); 70 } 71 72 public ICollection<VariableBindings> Query(ICollection<Statement> query, int page, int pageSize) { 73 73 MyQueryResultSink resultSink = new MyQueryResultSink(); 74 74 Translate(query).Run(store, resultSink); 75 return resultSink.Bindings ;75 return resultSink.Bindings.Skip(page * pageSize).Take(pageSize).ToList(); 76 76 } 77 77 … … 82 82 return new SemWeb.Query.GraphMatch(queryStore); 83 83 } 84 85 86 //public ICollection<Statement> Select(Statement template) {87 // SemWeb.MemoryStore memStore = new SemWeb.MemoryStore();88 // lock (bigLock) {89 // store.Select(Translate(template), memStore);90 // }91 // return memStore.Select(x=>Translate(x)).ToList();92 //}93 94 //public ICollection<Statement> Select(SelectFilter filter) {95 // SemWeb.MemoryStore memStore = new SemWeb.MemoryStore();96 // lock (bigLock) {97 // store.Select(Translate(filter), memStore);98 // }99 // return memStore.Select(x => Translate(x)).ToList();100 //}101 102 //private SemWeb.SelectFilter Translate(SelectFilter filter) {103 // SemWeb.SelectFilter f = new SemWeb.SelectFilter();104 // f.Subjects = Array.ConvertAll(filter.Subjects, s => Translate(s));105 // f.Predicates = Array.ConvertAll(filter.Predicates, p => Translate(p));106 // f.Objects = Array.ConvertAll(filter.Properties, prop => Translate(prop));107 // return f;108 //}109 84 110 85 private static SemWeb.Entity Translate(Entity e) { -
trunk/sources/HeuristicLab.CEDMA.Server/DispatcherBase.cs
r1287 r1417 68 68 }; 69 69 70 Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> ." )70 Entity[] datasets = store.Query("?DataSet <" + Ontology.PredicateInstanceOf.Uri + "> <" + Ontology.TypeDataSet.Uri + "> .", 0, 100) 71 71 .Select(x => (Entity)x.Get("DataSet")) 72 72 .ToArray(); -
trunk/sources/HeuristicLab.CEDMA.Server/Server.cs
r1287 r1417 71 71 try { 72 72 NetTcpBinding binding = new NetTcpBinding(); 73 binding.SendTimeout = new TimeSpan(1 , 0, 0);74 binding.MaxReceivedMessageSize = 1000000000; // 100Mbytes75 binding.ReaderQuotas.MaxStringContentLength = 1000000000; // also 100M chars76 binding.ReaderQuotas.MaxArrayLength = 1000000000; // also 100M elements;73 binding.SendTimeout = new TimeSpan(10, 0, 0); 74 binding.MaxReceivedMessageSize = int.MaxValue; 75 binding.ReaderQuotas.MaxStringContentLength = int.MaxValue; 76 binding.ReaderQuotas.MaxArrayLength = int.MaxValue; 77 77 host.AddServiceEndpoint(typeof(IStore), binding, cedmaServiceUrl); 78 78 host.Open();
Note: See TracChangeset
for help on using the changeset viewer.