Exemple #1
0
 static ACE_THR_FUNC_RETURN
 thread_thunk (void* arg)
 {
   Scheduler* obj = reinterpret_cast<Scheduler*> (arg);
   obj->execute ();
   return 0;
 }
Exemple #2
0
int main() {
    //typedef int T;
	Scheduler scheduler;
	
    TriggeredClock tClock (&scheduler);
	TriggerOut triggerOut (&scheduler);
	tClock.output.connect(&(triggerOut.input));
	triggerOut.output.connect(&(tClock.trigger));
	Time endTime = {50, 0};
	Time period = {5, 0};
	Time phase = {1, 0};
	tClock.setEndTime(endTime);
    tClock.setPeriod(period);
    tClock.setPhase(phase);
	tClock.initialize();
	triggerOut.initialize();
	
	std::cout <<"Start execution:"<<std::endl;
	scheduler.execute();
}
Exemple #3
0
//---------------------------------------------------------------------------
static void evalQuery(Database& db,const string& query,bool silent)
   // Evaluate a query
{
   QueryGraph queryGraph;
   {
      // Parse the query
      SPARQLLexer lexer(query);
      SPARQLParser parser(lexer);
      try {
         parser.parse();
      } catch (const SPARQLParser::ParserException& e) {
         cout << "parse error: " << e.message << endl;
         return;
      }

      // And perform the semantic anaylsis
      try {
         SemanticAnalysis semana(db);
         semana.transform(parser,queryGraph);
      } catch (const SemanticAnalysis::SemanticException& e) {
         cout << "semantic error: " << e.message << endl;
         return;
      }
      if (queryGraph.knownEmpty()) {
         cout << "<empty result>" << endl;
         return;
      }
   }

   // Run the optimizer
   PlanGen plangen;
   Plan* plan=plangen.translate(db,queryGraph);
   if (!plan) {
      cout << "plan generation failed" << endl;
      return;
   }
   if (getenv("SHOWCOSTS"))
      plan->print(0);
   if (getenv("DISABLESKIPPING"))
      Operator::disableSkipping=true;

   // Build a physical plan
   TemporaryDictionary tempDict(db.getDictionary());
   Runtime runtime(db,0,&tempDict);
   Operator* operatorTree=CodeGen().translate(runtime,queryGraph,plan,silent);

   if (getenv("SHOWPLAN")) {
      DebugPlanPrinter out(runtime,false);
      operatorTree->print(out);
   }

   // And execute it
   Scheduler scheduler;
   Timestamp start;
   scheduler.execute(operatorTree);
   Timestamp stop;
   cout << "Execution time: " << (stop-start) << " ms" << endl;

   if (getenv("SHOWCARD")) {
      DebugPlanPrinter out(runtime,true);
      operatorTree->print(out);
   }

   delete operatorTree;
}
//---------------------------------------------------------------------------
static bool evalQuery(Database& db,SPARQLLexer& lexer,ostream& planOut,ostream& statsOut,bool showJoins)
   // Evaluate a query
{
   QueryGraph queryGraph;
   std::string::const_iterator queryStart=lexer.getReader();
   {
      // Parse the query
      SPARQLParser parser(lexer);
      try {
         parser.parse(true);
      } catch (const SPARQLParser::ParserException& e) {
         cerr << "parse error: " << e.message << endl;
         return false;
      }

      // And perform the semantic anaylsis
      SemanticAnalysis semana(db);
      semana.transform(parser,queryGraph);
      if (queryGraph.knownEmpty()) {
         cerr << "known empty result ignored" << endl;
         return true;
      }
   }

   // Run the optimizer
   PlanGen plangen;
   Plan* plan=plangen.translate(db,queryGraph);
   if (!plan) {
      cerr << "plan generation failed" << endl;
      return true;
   }
   Operator::disableSkipping=true;

   // Build a physical plan
   Runtime runtime(db);
   Operator* operatorTree=CodeGen().translate(runtime,queryGraph,plan,true);
   Operator* root=dynamic_cast<ResultsPrinter*>(operatorTree)->getInput();

   // And execute it
   Scheduler scheduler;
   scheduler.execute(root);
   Timestamp stop;

   // Write the plan
   planOut << "# SPARQL Query:" << endl << "# ";
   std::string::const_iterator queryEnd=lexer.getReader();
   for (string::const_iterator iter=queryStart;iter!=queryEnd;++iter)
      if ((*iter)=='\n')
         planOut << endl << "# "; else
         planOut << *iter;
   planOut << endl << endl << "# Execution plan: <Operator expectedCardinality observedCardinalit [args] [input]>" << endl << endl;
   {
      DebugPlanPrinter out(planOut,runtime,true);
      root->print(out);
   }

   // Write the selectivities
   {
      if (showJoins)
         statsOut << "# relations joinVar1 joinVar2 bindings expectedSelectivity observedSelectivity" << endl; else
         statsOut << "# Stats: {relations} {new predicates(s)} {previous predicate(s)} expectedCardinality observedCardinality expectedSelectivity observedSelectivity" << endl;
      PredicateCollector out(statsOut,runtime,showJoins);
      root->print(out);
   }

   delete operatorTree;
   return true;
}
Exemple #5
0
void loop()
{
    ps.update();
    ts.execute();
}