Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2217


Ignore:
Timestamp:
07/31/09 12:11:41 (15 years ago)
Author:
mkommend
Message:

first part of performance improvements (ticket #712)

Location:
branches/HeuristicLab.Modeling Database Backend/sources
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.CEDMA.Core/3.3/Results.cs

    r2208 r2217  
    8585
    8686    private IEnumerable<ResultsEntry> SelectRows() {
     87      database.GetAllModelResults();
    8788      entries = new List<ResultsEntry>();
    8889      foreach (var model in database.GetAllModels()) {
     
    9192          modelEntry.Set(modelResult.Result.Name, modelResult.Value);
    9293        }
    93         modelEntry.Set("PersistedData", model.Data);
     94        modelEntry.Set("PersistedData", database.GetModelData(model));
    9495        modelEntry.Set("TargetVariable", model.TargetVariable.Name);
    9596        Dictionary<HeuristicLab.Modeling.Database.IVariable, ResultsEntry> inputVariableResultsEntries =
     
    100101            inputVariableResultsEntries[inputVariableResult.Variable] = new ResultsEntry();
    101102            inputVariableResultsEntries[inputVariableResult.Variable].Set("InputVariableName", inputVariableResult.Variable.Name);
    102             }
    103            inputVariableResultsEntries[inputVariableResult.Variable].Set(inputVariableResult.Result.Name, inputVariableResult.Value);
     103          }
     104          inputVariableResultsEntries[inputVariableResult.Variable].Set(inputVariableResult.Result.Name, inputVariableResult.Value);
    104105        }
    105106        modelEntry.Set("VariableImpacts", inputVariableResultsEntries.Values);
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs

    r2203 r2217  
    1414    }
    1515
    16     public Model(Variable targetVariable, Algorithm algorithm, byte[] data)
     16    public Model(Variable targetVariable, Algorithm algorithm)
    1717      : this() {
    1818      this.targetVariableId = targetVariable.Id;
    1919      this.algorithmId = algorithm.Id;
    20       this.Data = data;
    2120    }
    2221
     
    2625      get { return this.id; }
    2726      private set { this.id = value; }
    28     }
    29 
    30     private byte[] data;
    31     [Column(Storage = "data", DbType = "image", CanBeNull = false)]
    32     public byte[] Data {
    33       get { return this.data; }
    34       set { this.data = value; }
    3527    }
    3628
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DatabaseService.cs

    r2207 r2217  
    4545
    4646      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    47         model = new Model(target, algo, PersistenceManager.SaveToGZip(algorithm.Model.Data));
     47        model = new Model(target, algo);
    4848        model.TrainingSamplesStart = trainingSamplesStart;
    4949        model.TrainingSamplesEnd = trainingSamplesEnd;
     
    5959
    6060      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
     61        ctx.ModelData.InsertOnSubmit(new ModelData(model, PersistenceManager.SaveToGZip(algorithm.Model.Data)));
     62      }
     63
     64      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
    6165        foreach (string inputVariable in algorithm.Model.InputVariables) {
    62           ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable]));         
     66          ctx.InputVariables.InsertOnSubmit(new InputVariable(model, variables[inputVariable]));
    6367        }
    6468        ctx.SubmitChanges();
     
    194198
    195199    public IEnumerable<IResult> GetAllResultsForInputVariables() {
    196       using(ModelingDataContext ctx = new ModelingDataContext(connection) ){
    197         return (from ir in ctx.InputVariableResults  select ir.Result).Distinct().ToList().Cast<IResult>();
     200      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
     201        return (from ir in ctx.InputVariableResults select ir.Result).Distinct().ToList().Cast<IResult>();
    198202      }
    199203    }
     
    205209      ModelingDataContext ctx = new ModelingDataContext(connection);
    206210      DataLoadOptions dlo = new DataLoadOptions();
    207       dlo.LoadWith<ModelResult>(mr => mr.Model);
    208211      dlo.LoadWith<ModelResult>(mr => mr.Result);
    209212      ctx.LoadOptions = dlo;
     
    214217      return results.ToList().Cast<IModelResult>();
    215218    }
     219
     220    public void GetAllModelResults() {
     221      ModelingDataContext ctx = new ModelingDataContext(connection);
     222      DataLoadOptions dlo = new DataLoadOptions();
     223      dlo.LoadWith<ModelResult>(mr => mr.Result);
     224      dlo.LoadWith<ModelResult>(mr => mr.Model);
     225      ctx.LoadOptions = dlo;
     226
     227      var results = from result in ctx.ModelResults
     228                    select result;
     229      results.ToList();     
     230
     231    }
    216232    #endregion
    217233
     
    221237      DataLoadOptions dlo = new DataLoadOptions();
    222238      dlo.LoadWith<InputVariableResult>(ir => ir.Variable);
    223       dlo.LoadWith<InputVariableResult>(ir => ir.Result);
    224       dlo.LoadWith<InputVariableResult>(ir => ir.Model);
     239      dlo.LoadWith<InputVariableResult>(ir => ir.Result);     
    225240      ctx.LoadOptions = dlo;
    226241
     
    241256      return ctx.Models.ToList().Cast<IModel>();
    242257    }
     258
     259    public byte[] GetModelData(IModel model) {
     260      using (ModelingDataContext ctx = new ModelingDataContext(connection)) {
     261        var data = (from md in ctx.ModelData
     262                    where md.Model == model
     263                    select md);
     264        if (data.Count() == 0)
     265          return null;
     266        return data.Single().Data;
     267      }
     268    }
    243269    #endregion
    244270
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/HeuristicLab.Modeling.Database.SQLServerCompact-3.2.csproj

    r2213 r2217  
    122122    <Compile Include="DataObjects\InputVariableResult.cs" />
    123123    <Compile Include="DataObjects\Model.cs" />
     124    <Compile Include="DataObjects\ModelData.cs" />
    124125    <Compile Include="HeuristicLabModelingDatabaseSQLServerCompactPlugin.cs" />
    125126    <Compile Include="ModelingDataContext.cs" />
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/ModelingDataContext.cs

    r2194 r2217  
    3333    }
    3434
     35    public Table<ModelData> ModelData {
     36      get { return GetTable<ModelData>(); }
     37    }
     38
    3539    public Table<InputVariableResult> InputVariableResults {
    3640      get { return GetTable<InputVariableResult>(); }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database/3.2/IModel.cs

    r2194 r2217  
    2929    IVariable TargetVariable { get; }
    3030    IAlgorithm Algorithm { get; }
    31     byte[] Data { get; }
    3231    int TrainingSamplesStart { get; }
    3332    int TrainingSamplesEnd { get; }
  • branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.Database/3.2/IModelingDatabase.cs

    r2207 r2217  
    3232    IEnumerable<IResult> GetAllResultsForInputVariables();
    3333    IEnumerable<IModelResult> GetModelResults(IModel model);
    34     IEnumerable<IInputVariableResult> GetInputVariableResults(IModel model);   
     34    byte[] GetModelData(IModel model);
     35    IEnumerable<IInputVariableResult> GetInputVariableResults(IModel model);
     36
     37    void GetAllModelResults();
    3538  }
    3639}
Note: See TracChangeset for help on using the changeset viewer.