当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectDatabase::unloadUnusedCleanRecords方法代码示例

本文整理汇总了C++中ProjectDatabase::unloadUnusedCleanRecords方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectDatabase::unloadUnusedCleanRecords方法的具体用法?C++ ProjectDatabase::unloadUnusedCleanRecords怎么用?C++ ProjectDatabase::unloadUnusedCleanRecords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectDatabase的用法示例。


在下文中一共展示了ProjectDatabase::unloadUnusedCleanRecords方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getPopulatedDatabase

// Test not yet to scale re: data points.
TEST_F(ProjectFixture,Profile_ClearAnalysisResults) {
  ProjectDatabase db = getPopulatedDatabase(100,500,true,toPath("./ClearAnalysisResults"));

  // mimic code in AnalysisDriver to avoid adding AnalysisDriver as a dependency

  // time the process of retrieving response function data
  ptime start = microsec_clock::local_time();
  db.unloadUnusedCleanRecords();
  ASSERT_TRUE(db.startTransaction());
  DataPointRecordVector dataPointRecords = DataPointRecord::getDataPointRecords(db);
  EXPECT_EQ(500u,dataPointRecords.size());
  BOOST_FOREACH(project::DataPointRecord& dataPointRecord,dataPointRecords) {
    // in AnalysisDriver, removes DataPoint directories, but they don't exist here
    db.removeRecord(dataPointRecord);
  }
开发者ID:NREL,项目名称:OpenStudio-resources,代码行数:16,代码来源:ProjectDatabaseProfiling_GTest.cpp

示例2: constructRelatedRecords

void RubyContinuousVariableRecord::constructRelatedRecords(const analysis::Variable& variable)
{
  analysis::RubyContinuousVariable rubyContinuousVariable = variable.cast<analysis::RubyContinuousVariable>();
  RubyContinuousVariableRecord copyOfThis(getImpl<detail::RubyContinuousVariableRecord_Impl>());
  ProjectDatabase database = projectDatabase();
  bool isNew = database.isNewRecord(copyOfThis);
  if (!isNew) {
    getImpl<detail::RubyContinuousVariableRecord_Impl>()->revertToLastRecordIds();
  }

  // Save resource RubyMeasure
  if (isNew || rubyContinuousVariable.perturbation().isDirty()) {
    RubyMeasureRecord rubyMeasureRecord(rubyContinuousVariable.measure(),database);
    getImpl<detail::RubyContinuousVariableRecord_Impl>()->setRubyMeasureRecordId(rubyMeasureRecord.id());
  }

  // Save child OSArgument
  OSArgument argument = rubyContinuousVariable.argument();
  bool saveArgument = false;
  if (!isNew) {
    {
      // see if old argument record should be removed
      OSArgumentRecord oldArgumentRecord = osArgumentRecord();
      if (oldArgumentRecord.handle() != argument.uuid()) {
        database.removeRecord(oldArgumentRecord);
        saveArgument = true;
      }
      else if (oldArgumentRecord.uuidLast() != argument.versionUUID()) {
        saveArgument = true;
      }
    }
    database.unloadUnusedCleanRecords();
  }
  if (saveArgument || isNew) {
    OSArgumentRecord osArgumentRecord(argument,copyOfThis);
  }
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:37,代码来源:RubyContinuousVariableRecord.cpp

示例3: record

// Test not yet to scale re: total data points.
TEST_F(ProjectFixture,Profile_UpdateAnalysis) {
  Analysis analysis = getAnalysisToRun(100,500);

  // save to database
  ProjectDatabase db = getCleanDatabase(toPath("./UpdateAnalysis"));
  ASSERT_TRUE(db.startTransaction());
  AnalysisRecord record(analysis,db);
  db.save();
  ASSERT_TRUE(db.commitTransaction());

  // add output data to 1 data point
  DataPointVector dataPoints = analysis.dataPoints();
  boost::mt19937 mt;
  typedef boost::uniform_real<> uniform_dist_type;
  typedef boost::variate_generator<boost::mt19937&, uniform_dist_type> uniform_gen_type;
  uniform_gen_type responseGenerator(mt,uniform_dist_type(50.0,500.0));
  for (int i = 0; i < 1; ++i) {
    std::stringstream ss;
    ss << "dataPoint" << i + 1;
    DoubleVector responseValues;
    for (int j = 0, n = analysis.problem().responses().size(); j < n; ++j) {
      responseValues.push_back(responseGenerator());
    }
    openstudio::path runDir = toPath(ss.str());
    dataPoints[i] = DataPoint(dataPoints[i].uuid(),
                              createUUID(),
                              dataPoints[i].name(),
                              dataPoints[i].displayName(),
                              dataPoints[i].description(),
                              analysis.problem(),
                              true,
                              false,
                              true,
                              DataPointRunType::Local,
                              dataPoints[i].variableValues(),
                              responseValues,
                              runDir,
                              FileReference(runDir / toPath("ModelToIdf/in.osm")),
                              FileReference(runDir / toPath("ModelToIdf/out.idf")),
                              FileReference(runDir / toPath("EnergyPlus/eplusout.sql")),
                              FileReferenceVector(1u,FileReference(runDir / toPath("Ruby/report.xml"))),
                              boost::optional<runmanager::Job>(),
                              std::vector<openstudio::path>(),
                              TagVector(),
                              AttributeVector());
    dataPoints[i].setName(dataPoints[i].name()); // set dirty
  }
  analysis = Analysis(analysis.uuid(),
                      analysis.versionUUID(),
                      analysis.name(),
                      analysis.displayName(),
                      analysis.description(),
                      analysis.problem(),
                      analysis.algorithm(),
                      analysis.seed(),
                      analysis.weatherFile(),
                      dataPoints,
                      false,
                      false);
  analysis.setName(analysis.name()); // set dirty

  // time the process of updating the database
  ptime start = microsec_clock::local_time();
  db.unloadUnusedCleanRecords();
  ASSERT_TRUE(db.startTransaction());
  record = AnalysisRecord(analysis,db);
  db.save();
  ASSERT_TRUE(db.commitTransaction());
  time_duration updateTime = microsec_clock::local_time() - start;

  std::cout << "Time: " << to_simple_string(updateTime) << std::endl;
}
开发者ID:NREL,项目名称:OpenStudio-resources,代码行数:73,代码来源:ProjectDatabaseProfiling_GTest.cpp

示例4: analysis

TEST_F(ProjectFixture,DataPoint_DataPointRecord_Synchronization) {

  // create analysis with one data point
  ProjectDatabase database = getCleanDatabase("DataPoint_DataPointRecord_Synchronization");

  analysis::Analysis analysis(
      "Test Analysis",
      analysis::Problem("Test Problem",analysis::VariableVector(),runmanager::Workflow()),
      analysis::DesignOfExperiments(analysis::DesignOfExperimentsOptions(
          analysis::DesignOfExperimentsType::FullFactorial)),
      FileReference(toPath("in.osm")));

  std::vector<QVariant> variableValues;
  analysis::DataPoint original = analysis.problem().createDataPoint(variableValues).get();
  analysis.addDataPoint(original);

  // save analysis to database
  {
    bool didStartTransaction = database.startTransaction();
    AnalysisRecord analysisRecord(analysis,database);

    DataPointRecordVector dataPointRecords = DataPointRecord::getDataPointRecords(database);
    ASSERT_EQ(1u,dataPointRecords.size());
    DataPointRecord dataPointRecord = dataPointRecords[0];
    EXPECT_FALSE(dataPointRecord.isComplete());

    database.save();
    if (didStartTransaction) {
      database.commitTransaction();
    }
  }

  // reload analysis, change data point, save back to database
  // verify that change shows up in database
  OptionalAnalysis loadedAnalysis;
  {
    AnalysisRecordVector loadedAnalysisRecords = AnalysisRecord::getAnalysisRecords(database);
    ASSERT_EQ(1u,loadedAnalysisRecords.size());
    loadedAnalysis = loadedAnalysisRecords[0].analysis();

    analysis::DataPointVector loadedDataPoints = loadedAnalysis->dataPoints();
    ASSERT_EQ(1u,loadedDataPoints.size());
    loadedDataPoints[0].getImpl<analysis::detail::DataPoint_Impl>()->markComplete();
    EXPECT_TRUE(loadedDataPoints[0].isComplete());
  }
  ASSERT_TRUE(loadedAnalysis);

  {
    bool didStartTransaction = database.startTransaction();
    database.unloadUnusedCleanRecords();
    AnalysisRecord analysisRecord(*loadedAnalysis,database);
    database.save();
    if (didStartTransaction) {
      database.commitTransaction();
    }
    EXPECT_EQ(1u,AnalysisRecord::getAnalysisRecords(database).size());

    DataPointRecordVector dataPointRecords = DataPointRecord::getDataPointRecords(database);
    ASSERT_EQ(1u,dataPointRecords.size());
    DataPointRecord dataPointRecord = dataPointRecords[0];
    EXPECT_TRUE(dataPointRecord.isComplete());
  }

}
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:64,代码来源:DataPointRecord_GTest.cpp

示例5: analysis


//.........这里部分代码省略.........
  values[2] = 0;
  dataPoint = problem.createDataPoint(values);
  ASSERT_TRUE(dataPoint);
  test = analysis.addDataPoint(*dataPoint);
  EXPECT_TRUE(test);
  EXPECT_EQ(5u,analysis.dataPoints().size());
  EXPECT_TRUE(analysis.isDirty());
  EXPECT_FALSE(problem.isDirty());
  BOOST_FOREACH(const Variable& variable, problem.variables()) {
    EXPECT_FALSE(variable.isDirty());
    ASSERT_TRUE(variable.optionalCast<DiscreteVariable>());
    BOOST_FOREACH(const DiscretePerturbation& perturbation,variable.cast<DiscreteVariable>().perturbations(false)) {
      EXPECT_FALSE(perturbation.isDirty());
    }
  }
  BOOST_FOREACH(const Function& response, problem.responses()) {
    EXPECT_FALSE(response.isDirty());
  }
  int i = 0;
  BOOST_FOREACH(const DataPoint& dataPoint, analysis.dataPoints()) {
    if (i < 3) {
      EXPECT_FALSE(dataPoint.isDirty());
    }
    else {
      EXPECT_TRUE(dataPoint.isDirty());
    }
    ++i;
  }

  // save to database, make sure changes made it in
  {
    bool transactionStarted = database.startTransaction();
    EXPECT_TRUE(transactionStarted);
    database.unloadUnusedCleanRecords(); // [email protected] - Having to call this is awkward.
                                         // Where is the best place?
    AnalysisRecord analysisRecord(analysis,database);
    database.save();
    test = database.commitTransaction();
    EXPECT_TRUE(test);
    EXPECT_EQ(analysis.uuid(),analysisRecord.handle());
    EXPECT_EQ(analysis.versionUUID(),analysisRecord.uuidLast());
    ASSERT_NO_THROW(analysisRecord.problemRecord());
    ProblemRecord problemRecord = analysisRecord.problemRecord();
    EXPECT_EQ(problemRecord.handle(),analysisRecord.problemRecord().handle());
    EXPECT_EQ(problemRecord.uuidLast(),analysisRecord.problemRecord().uuidLast());
    InputVariableRecordVector variableRecords = problemRecord.inputVariableRecords();
    EXPECT_EQ(3u,variableRecords.size());
    ASSERT_FALSE(variableRecords.empty());
    ASSERT_TRUE(variableRecords[0].optionalCast<DiscreteVariableRecord>());
    DiscretePerturbationRecordVector perturbationRecords = variableRecords[0].cast<DiscreteVariableRecord>().discretePerturbationRecords(false);
    EXPECT_EQ(5u,perturbationRecords.size());
    ASSERT_TRUE(perturbationRecords.size() > 1);
    EXPECT_TRUE(perturbationRecords[0].optionalCast<NullPerturbationRecord>());
    EXPECT_TRUE(perturbationRecords[1].optionalCast<RubyPerturbationRecord>());
    EXPECT_EQ(5u,analysisRecord.dataPointRecords().size());
    EXPECT_TRUE(analysisRecord.completeDataPointRecords().empty());
  }

  analysis.clearDirtyFlag();
  EXPECT_FALSE(analysis.isDirty());
  EXPECT_FALSE(problem.isDirty());
  BOOST_FOREACH(const Variable& variable, problem.variables()) {
    EXPECT_FALSE(variable.isDirty());
    ASSERT_TRUE(variable.optionalCast<DiscreteVariable>());
    BOOST_FOREACH(const DiscretePerturbation& perturbation,variable.cast<DiscreteVariable>().perturbations(false)) {
      EXPECT_FALSE(perturbation.isDirty());
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:67,代码来源:AnalysisRecord_GTest.cpp


注:本文中的ProjectDatabase::unloadUnusedCleanRecords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。