Пример #1
0
int main(int argc, char * argv[] ){
	   argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
	   option::Stats  stats(usage, argc, argv);
	   option::Option options[stats.options_max], buffer[stats.buffer_max];
	   option::Parser parse(usage, argc, argv, options, buffer);

	   if (parse.error())
	     return 1;

	   if (options[HELP]) {
	     option::printUsage(std::cout, usage);
	     return 0;
	   }

	   if (options[VERB] && options[VERB].arg)
		   Log::setGlobalVerbosityForAllLoggers(atoi(options[VERB].arg));

	   int buckets = (options[QP] && options[QP].arg) ? atoi(options[QP].arg) : 0;
	   int limit = (options[LIMIT] && options[LIMIT].arg) ? atoi(options[LIMIT].arg) : CONSTS::MAXD;
	   int offset = (options[OFFSET] && options[OFFSET].arg) ? atoi(options[OFFSET].arg) : 0;
	   int topk = (options[TOPK] && options[TOPK].arg) ? atoi(options[TOPK].arg) : 10;
	   int layer = (options[LAYER] && options[LAYER].arg) ? atoi(options[LAYER].arg) : 0;

	   if(options[BUILD]) {
		   const std::string&  trecRawRoot = options[BUILD].arg ? std::string(options[BUILD].arg) : CONSTS::trecRawRoot;
		   std::string outputPath = (options[OUTPATH] && options[OUTPATH].arg) ? std::string(options[OUTPATH].arg): CONSTS::trecRoot;
		   stringIntVectorsPair tmap; //empty one
		   TrecReader* tr =  TrecFactory(trecRawRoot);
		   TrecFactory(*tr,outputPath, offset,limit,tmap);
		   delete tr;
		   return 0;
	   }

	   std::string queryFile = (options[QPATH] && options[QPATH].arg) ? std::string(options[QPATH].arg): CONSTS::ikQuery;

	   SingleHashBlocker::expectedBlockSize = (options[OFFSET] && options[OFFSET].arg) ? atoi(options[OFFSET].arg) : 8;
	   //COUT3 << "Expected block size: " << SingleHashBlocker::expectedBlockSize << Log::endl; // togo

	   //togo
	   //std::cout << "########### expected block size: 2^" << SingleHashBlocker::expectedBlockSize << std::endl;

	   if(nice(-3)) {}

	   termsCache Cache;
	   if(options[ONDEMAND] )
		   onDemandCpool::initPool(CONSTS::STORAGE_CAPACITY); //prepare the cache but load none
	   else {
		   // load different terms_mapping
		   if (layer == 0)
			   Cache.fill_cache(CONSTS::termsMapping.c_str()); //load terms //
		   else
			   Cache.fill_cache(CONSTS::termsMapping_Layer.c_str()); //load terms Layering
	   }

	   QueryProcessing qp(Cache);
	   qp(queryFile.c_str(), buckets, limit, topk, layer); //process the queries
	   qp.printReport();
	   COUT1 << "start cleanup" << Log::endl;
	   return 0;
}
Пример #2
0
 virtual void _init() {
     if ( qp().scanAndOrderRequired() ) {
         throw MsgAssertionException( OutOfOrderDocumentsAssertionCode, "order spec cannot be satisfied with index" );
     }
     _c = qp().newCursor();
     _capped = _c->capped();
     mayAdvance();
 }
Пример #3
0
 virtual void _init() {
     if ( requireIndex_ && strcmp( qp().indexKey().firstElement().fieldName(), "$natural" ) == 0 )
         throw MsgAssertionException( 9011 , "Not an index cursor" );
     c_ = qp().newCursor();
     if ( !c_->ok() ) {
         setComplete();
     }
 }
Пример #4
0
 virtual void init() {
     if ( requireIndex_ && strcmp( qp().indexKey().firstElement().fieldName(), "$natural" ) == 0 )
         throw MsgAssertionException( 9011 , "Not an index cursor" );
     c_ = qp().newCursor();
     if ( !c_->ok() )
         setComplete();
     else
         matcher_.reset( new CoveredIndexMatcher( qp().query(), qp().indexKey() ) );
 }
TEST(QueryPlannerTest, createTripleGraph) {
  try {
    {
      ParsedQuery pq = SparqlParser::parse(
          "PREFIX : <http://rdf.myprefix.com/>\n"
          "PREFIX ns: <http://rdf.myprefix.com/ns/>\n"
          "PREFIX xxx: <http://rdf.myprefix.com/xxx/>\n"
          "SELECT ?x ?z \n "
          "WHERE \t {?x :myrel ?y. ?y ns:myrel ?z.?y xxx:rel2 "
          "<http://abc.de>}");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      auto tg = qp.createTripleGraph(&pq._rootGraphPattern);
      ASSERT_EQ(
          "0 {s: ?x, p: <http://rdf.myprefix.com/myrel>, o: ?y} : (1, 2)\n"
          "1 {s: ?y, p: <http://rdf.myprefix.com/ns/myrel>, o: ?z} : (0, 2)\n"
          "2 {s: ?y, p: <http://rdf.myprefix.com/xxx/rel2>, o: "
          "<http://abc.de>} : (0, 1)",
          tg.asString());
    }

    {
      ParsedQuery pq = SparqlParser::parse(
          "SELECT ?x WHERE {?x ?p <X>. ?x ?p2 <Y>. <X> ?p <Y>}");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      auto tg = qp.createTripleGraph(&pq._rootGraphPattern);
      ASSERT_EQ(
          "0 {s: ?x, p: ?p, o: <X>} : (1, 2)\n"
          "1 {s: ?x, p: ?p2, o: <Y>} : (0)\n"
          "2 {s: <X>, p: ?p, o: <Y>} : (0)",
          tg.asString());
    }

    {
      ParsedQuery pq = SparqlParser::parse(
          "SELECT ?x WHERE { ?x <is-a> <Book> . \n"
          "?x <Author> <Anthony_Newman_(Author)> }");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      auto tg = qp.createTripleGraph(&pq._rootGraphPattern);
      ASSERT_EQ(
          "0 {s: ?x, p: <is-a>, o: <Book>} : (1)\n"
          "1 {s: ?x, p: <Author>, o: <Anthony_Newman_(Author)>} : (0)",
          tg.asString());
    }
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #6
0
 virtual void init() {
     query_ = spec_.getObjectField( "query" );
     c_ = qp().newCursor();
     matcher_.reset( new KeyValJSMatcher( query_, c_->indexKeyPattern() ) );
     if ( qp().exactKeyMatch() && ! matcher_->needRecord() ) {
         query_ = qp().simplifiedQuery( qp().indexKey() );
         bc_ = dynamic_cast< BtreeCursor* >( c_.get() );
         bc_->forgetEndKey();
     }
     
     skip_ = spec_["skip"].numberLong();
     limit_ = spec_["limit"].numberLong();
 }
TEST(QueryPlannerTest, testBFSLeaveOut) {
  try {
    {
      ParsedQuery pq = SparqlParser::parse(
          "SELECT ?x WHERE {?x ?p <X>. ?x ?p2 <Y>. <X> ?p <Y>}");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      auto tg = qp.createTripleGraph(&pq._rootGraphPattern);
      ASSERT_EQ(3u, tg._adjLists.size());
      ad_utility::HashSet<size_t> lo;
      auto out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(3u, out.size());
      lo.insert(1);
      out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(2u, out.size());
      lo.insert(2);
      out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(1u, out.size());
      lo.clear();
      lo.insert(0);
      out = tg.bfsLeaveOut(1, lo);
      ASSERT_EQ(1u, out.size());
    }
    {
      ParsedQuery pq = SparqlParser::parse(
          "SELECT ?x WHERE {<A> <B> ?x. ?x <C> ?y. ?y <X> <Y>}");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      auto tg = qp.createTripleGraph(&pq._rootGraphPattern);
      ad_utility::HashSet<size_t> lo;
      auto out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(3u, out.size());
      lo.insert(1);
      out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(1u, out.size());
      lo.insert(2);
      out = tg.bfsLeaveOut(0, lo);
      ASSERT_EQ(1u, out.size());
      lo.clear();
      lo.insert(0);
      out = tg.bfsLeaveOut(1, lo);
      ASSERT_EQ(2u, out.size());
    }
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
TEST(QueryExecutionTreeTest, testFormerSegfaultTriFilter) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "PREFIX fb: <http://rdf.freebase.com/ns/>\n"
        "SELECT DISTINCT ?1 ?0 WHERE {\n"
        "fb:m.0fkvn fb:government.government_office_category.officeholders ?0 "
        ".\n"
        "?0 fb:government.government_position_held.jurisdiction_of_office "
        "fb:m.0vmt .\n"
        "?0 fb:government.government_position_held.office_holder ?1 .\n"
        "FILTER (?1 != fb:m.0fkvn) .\n"
        "FILTER (?1 != fb:m.0vmt) .\n"
        "FILTER (?1 != fb:m.018mts)"
        "} LIMIT 300");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_TRUE(qet.varCovered("?1"));
    ASSERT_TRUE(qet.varCovered("?0"));
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
TEST(QueryExecutionTreeTest, testPlantsEdibleLeaves) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "SELECT ?a \n "
        "WHERE  {?a <is-a> <Plant> . ?c ql:contains-entity ?a. "
        "?c ql:contains-word \"edible leaves\"} TEXTLIMIT 5");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryPlanner::TripleGraph tg = qp.createTripleGraph(&pq._rootGraphPattern);
    ASSERT_EQ(1u, tg._nodeMap.find(0)->second->_variables.size());
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TEXT OPERATION WITH FILTER: co-occurrence with words: "
        "\"edible leaves\" and 1 variables with textLimit = 5 "
        "filtered by\n  {\n    SCAN POS with P = \"<is-a>\", "
        "O = \"<Plant>\"\n    qet-width: 1 \n  }\n   filtered on "
        "column 0\n  qet-width: 3 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
TEST(QueryExecutionTreeTest, testCyclicQuery) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "SELECT ?x ?y ?m WHERE { ?x <Spouse_(or_domestic_partner)> ?y . "
        "?x <Film_performance> ?m . ?y <Film_performance> ?m }");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TWO_COLUMN_JOIN\n    {\n    ORDER_BY\n    {\n      JOIN\n"
        "      {\n        SCAN PSO with P = \"<Film_performance>\"\n"
        "        qet-width: 2 \n      } join-column: [0]\n      |X|\n"
        "      {\n        "
        "SCAN PSO with P = \"<Spouse_(or_domestic_partner)>\"\n    "
        "    qet-width: 2 \n      } join-column: [0]\n "
        "     qet-width: 3 \n    } order on asc(2) asc(1) \n"
        "    qet-width: 3 \n  }\n  join-columns: [2 & 1]\n  |X|\n"
        "    {\n    SCAN PSO with P = \"<Film_performance>\"\n"
        "    qet-width: 2 \n  }\n  join-columns: [0 & 1]\n"
        "  qet-width: 3 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #11
0
void testApp :: draw()
{
	
	//ofQuaternion constructor: angle, ofVec3f axis
	
	ofQuaternion qr (roll, Znormal);	// quat roll.
	ofQuaternion qp (pitch, Xnormal);	// quat pitch.
	ofQuaternion qh (heading, Ynormal);	// quat heading or yaw.
	ofQuaternion qt;					// quat total.

	
	
	// The order IS IMPORTANT. Apply roll first, then pitch, then heading.
	qt = qr * qp * qh;
	
	
		
	ofPushMatrix();
		ofTranslate( ofGetWidth() * 0.5, ofGetHeight() * 0.5, 0 );
		
		/******************************/
		
		/*
		//GYMBAL LOCK!!
		EulerRot = qt.getEuler();
		ofRotateX(EulerRot.x);
		ofRotateY(EulerRot.y);
		ofRotateZ(EulerRot.z);
		 */
		 

		ofVec3f qaxis; float qangle;
		qt.getRotate(qangle, qaxis);
	
		ofRotate(qangle, qaxis.x, qaxis.y, qaxis.z);
 
	
		ofScale( 200, 200, 200 );
		/******************************/

		
		drawCube();
		
	ofPopMatrix();
	
	
	
	
	ofSetColor( 0x000000 );
	ofDrawBitmapString
	(
	 "fps :: " + ofToString(ofGetFrameRate(), 2) + "\n\n"
	 "incDir  :: press i to change :: " + ofToString( incDir ) + "\n\n"
	 "roll    :: press 1 to change :: " + ofToString( roll ) + "\n\n"
	 "pitch   :: press 2 to change :: " + ofToString( pitch ) + "\n\n"
	 "heading :: press 3 to change :: " + ofToString( heading ) + "\n\n",
	 20,
	 20
	 );
}
TEST(QueryExecutionTreeTest, testBornInEuropeOwCocaine) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "PREFIX : <>\n"
        "SELECT ?x ?y TEXT(?c)\n "
        "WHERE \t {"
        "?x :Place_of_birth ?y ."
        "?y :Contained_by :Europe ."
        "?c ql:contains-entity ?x ."
        "?c ql:contains-word \"cocaine\" ."
        "}");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TEXT OPERATION WITH FILTER: co-occurrence with words: "
        "\"cocaine\" and 1 variables with textLimit = 1 filtered by\n  "
        "{\n    JOIN\n    {\n      SCAN POS with P = \"<Contained_by>\", "
        "O = \"<Europe>\"\n      qet-width: 1 \n    } join-column: [0]\n"
        "    |X|\n    {\n      SCAN POS with P = \"<Place_of_birth>\"\n"
        "      qet-width: 2 \n    } join-column: [0]\n    qet-width: 2 \n"
        "  }\n   filtered on column 1\n  qet-width: 4 \n}",
        qet.asString());
    ASSERT_EQ(0u, qet.getVariableColumn("?c"));
    ASSERT_EQ(1u, qet.getVariableColumn("SCORE(?c)"));
    ASSERT_EQ(2u, qet.getVariableColumn("?y"));
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #13
0
void YResourceMgr::initConfig()
{
    // handle ~/.yzis/
    QString yzisSuffix = ".yzis";
    bool isTmpDir = false;
    mYzisUserDir = QDir::homePath() + "/" + yzisSuffix + "/";
    QDir yzisUserDir(mYzisUserDir);

    if(! yzisUserDir.exists()) {
        dbg().SPrintf("User dir does not exist, creating it: %s", qp(mYzisUserDir));
        yzisUserDir.cdUp();

        if(! yzisUserDir.mkdir(yzisSuffix)) {
            isTmpDir = true;
            mYzisUserDir = QDir::tempPath() + "/";
            err() << "initConfig(): could not create yzis user directory, falling back on " << mYzisUserDir;
        }
    }

    yzisUserDir.setPath(mYzisUserDir);

    if((!QFileInfo(mYzisUserDir).isWritable()) && (!isTmpDir)) {
        mYzisUserDir = QDir::tempPath() + "/";
        err() << "initConfig(): yzis user directory is not writable, falling back on " << mYzisUserDir;
        isTmpDir = true;
    }

    if((! QFileInfo(mYzisUserDir).isWritable())) {
        err() << "initConfig(): yzis user directory " << mYzisUserDir << " is not writable, falling back on " << mYzisUserDir;
        err() << "initConfig(): Yzis will not function properly" << endl;
    }

    dbg() << "initConfig(): yzis user directory set to " << mYzisUserDir << endl;
}
TEST(QueryPlannerTest, testActorsBornInEurope) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "PREFIX : <pre/>\n"
        "SELECT ?a \n "
        "WHERE {?a :profession :Actor . ?a :born-in ?c. ?c :in :Europe}\n"
        "ORDER BY ?a");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  JOIN\n  {\n    SCAN POS with P = \"<pre/profession>\", "
        "O = \"<pre/Actor>\"\n    qet-width: 1 \n  } join-column:"
        " [0]\n  |X|\n  {\n    SORT on column:1\n    {\n      "
        "JOIN\n      {\n        SCAN POS with P = \"<pre/born-i"
        "n>\"\n        qet-width: 2 \n      } join-column: [0]\n "
        "     |X|\n      {\n        SCAN POS with P = \"<pre/in>\""
        ", O = \"<pre/Europe>\"\n        qet-width: 1 \n      }"
        " join-column: [0]\n      qet-width: 2 \n    }\n    "
        "qet-width: 2 \n  } join-column: [1]\n  qet-width: 2 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #15
0
void VfunctionsTest::testqprodFunction()
{
    mslam::RealType qData[4] = {
        0.999981401328104647,
        0.00372253651322187237,
        0.00480838103813518037,
        0.000468179003859795124
    };
    mslam::RealVector q(qData, 4, true);

    mslam::RealType pData[4] = {
        0.999981400874166759,
        0.00372258348858517645,
        0.00480843863383016625,
        0.000468183526239199406,
    };
    mslam::RealVector p(pData, 4, true);

    mslam::RealType qpData[4] = {
        0.99992560509638384,
        0.00744498152555334112,
        0.00961664081486704111,
        0.000936345103313629347
    };
    mslam::RealMatrix qp(4, 1, qpData);

    auto res = mslam::qprod(q, p);

    CPPUNIT_ASSERT_EQUAL(0, cv::countNonZero(cv::abs(mslam::v2m(res) - qp) > 
            1e-15));
}
Пример #16
0
void Widget::paintEvent(QPaintEvent *e) {

    QPainter qp(this);
    drawWidget(qp);

    QFrame::paintEvent(e);
}
Пример #17
0
void Lines::paintEvent(QPaintEvent *e){
	Q_UNUSED(e);
	QPainter qp(this);
	/*Create serial object */
	try { 

			// Make a SimpleSerial object with the parameter for your Wunderboard/OS
			
			
			this->tmp = this->wunder->readLine();

			/*handles odd SimpleSerial Problems*/
			if(this->tmp.length() != 3)
				adcval = MADC; //send it back to the middle
			else
				adcval = atoi(this->tmp.c_str()) - MADC ;

		} catch(boost::system::system_error& e)
		{
			std::cerr<<tmp<<": Error: "<<std::endl;//<<e.what()<<std::endl;
		}
	qp.setWindow(0,0, 800, 600);
	drawBoundary(&qp);
	drawPaddle(&qp);
	drawBall(&qp);
	drawBlocks(&qp);
	check_collision();

	
}
TEST(QueryPlannerTest, testStarTwoFree) {
  try {
    {
      ParsedQuery pq = SparqlParser::parse(
          "PREFIX : <http://rdf.myprefix.com/>\n"
          "PREFIX ns: <http://rdf.myprefix.com/ns/>\n"
          "PREFIX xxx: <http://rdf.myprefix.com/xxx/>\n"
          "SELECT ?x ?z \n "
          "WHERE \t {?x :myrel ?y. ?y ns:myrel ?z. ?y xxx:rel2 "
          "<http://abc.de>}");
      pq.expandPrefixes();
      QueryPlanner qp(nullptr);
      QueryExecutionTree qet = qp.createExecutionTree(pq);
      ASSERT_EQ(
          "{\n  JOIN\n  {\n    JOIN\n    {\n      SCAN POS with P = \""
          "<http://rdf.myprefix.com/myrel>\"\n      qet-width: 2 \n "
          "   } join-column: [0]\n    |X|\n    {\n      SCAN PSO wit"
          "h P = \"<http://rdf.myprefix.com/ns/myrel>\"\n      qet-"
          "width: 2 \n    } join-column: [0]\n    qet-width: 3 \n  "
          "} join-column: [0]\n  |X|\n  {\n    SCAN POS with P = "
          "\"<http://rdf.myprefix.com/xxx/rel2>\", O = \"<http://a"
          "bc.de>\"\n    qet-width: 1 \n  } join-column: [0]\n  qet"
          "-width: 3 \n}",
          qet.asString());
    }
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
TEST(QueryExecutionTreeTest, testCoOccFreeVar) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "PREFIX : <>"
        "SELECT ?x ?y WHERE {"
        "?x :is-a :Politician ."
        "?c ql:contains-entity ?x ."
        "?c ql:contains-word \"friend*\" ."
        "?c ql:contains-entity ?y ."
        "}");
    pq.expandPrefixes();
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TEXT OPERATION WITH FILTER: co-occurrence with words: "
        "\"friend*\" and 2 variables with textLimit = 1 filtered by\n"
        "  {\n    SCAN POS with P = \"<is-a>\", O = \"<Politician>"
        "\"\n    qet-width: 1 \n  }\n   filtered on column 0\n "
        " qet-width: 4 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #20
0
void AP_TimerProcess::run(void)
{
    // we enable the interrupt again immediately and also enable
    // interrupts. This allows other time critical interrupts to
    // run (such as the serial receive interrupt). We catch the
    // timer calls taking too long using _in_timer_call.
    // This approach also gives us a nice uniform spacing between
    // timer calls
    TCNT2 = _period;
    sei();

    uint32_t tnow = micros();

    if (_in_timer_call) {
        // the timer calls took longer than the period of the
        // timer. This is bad, and may indicate a serious
        // driver failure. We can't just call the drivers
        // again, as we could run out of stack. So we only
        // call the _failsafe call. It's job is to detect if
        // the drivers or the main loop are indeed dead and to
        // activate whatever failsafe it thinks may help if
        // need be.  We assume the failsafe code can't
        // block. If it does then we will recurse and die when
        // we run out of stack
        if (_failsafe != NULL) {
            _failsafe(tnow);
        }
        return;
    }
    _in_timer_call = true;

    if (!_suspended) {
        // now call the timer based drivers
        for (int i = 0; i < _pidx; i++) {
            if (_proc[i] != NULL) {
                _proc[i](tnow);
            }
        }

        // run any queued processes
        uint8_t oldSREG = SREG;
        cli();
        ap_procedure qp = _queued_proc;
        _queued_proc = NULL;
        SREG = oldSREG;
        if( qp != NULL ) {
            _suspended = true;
            qp(tnow);
            _suspended = false;
        }
    }

    // and the failsafe, if one is setup
    if (_failsafe != NULL) {
        _failsafe(tnow);
    }

    _in_timer_call = false;
}
TEST(QueryPlannerTest, testSimpleOptional) {
  try {
    QueryPlanner qp(nullptr);

    ParsedQuery pq = SparqlParser::parse(
        "SELECT ?a ?b \n "
        "WHERE  {?a <rel1> ?b . OPTIONAL { ?a <rel2> ?c }}");
    pq.expandPrefixes();
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n"
        "  OPTIONAL_JOIN\n"
        "  {\n"
        "    SCAN PSO with P = \"<rel1>\"\n"
        "    qet-width: 2 \n"
        "  } join-columns: [0]\n"
        "  |X|\n"
        "  {\n"
        "    SCAN PSO with P = \"<rel2>\"\n"
        "    qet-width: 2 \n"
        "  } join-columns: [0]\n"
        "  qet-width: 3 \n"
        "}",
        qet.asString());

    ParsedQuery pq2 = SparqlParser::parse(
        "SELECT ?a ?b \n "
        "WHERE  {?a <rel1> ?b . "
        "OPTIONAL { ?a <rel2> ?c }} ORDER BY ?b");
    pq2.expandPrefixes();
    QueryExecutionTree qet2 = qp.createExecutionTree(pq2);
    ASSERT_EQ(
        "{\n"
        "  SORT on column:1\n"
        "  {\n"
        "    OPTIONAL_JOIN\n"
        "    {\n"
        "      SCAN PSO with P = \"<rel1>\"\n"
        "      qet-width: 2 \n"
        "    } join-columns: [0]\n"
        "    |X|\n"
        "    {\n"
        "      SCAN PSO with P = \"<rel2>\"\n"
        "      qet-width: 2 \n"
        "    } join-columns: [0]\n"
        "    qet-width: 3 \n"
        "  }\n"
        "  qet-width: 3 \n"
        "}",
        qet2.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #22
0
void Reverb1LCD::paintEvent(QPaintEvent* event) {

	(void) event;
	resizeImageBuffer();

	QPainter qp(this);
	qp.drawImage(0,0,img);

}
Пример #23
0
void QScope::refresh_all(timeref_t t) {// DB modification, extracted from refresh
  if (t) {
    qss.endtime = t;
    nspikes = 0;
  }
  QPainter qp(this);
  drawContents_all(&qp);
  //drawContents_together(&qp);
}
TEST(QueryPlannerTest, threeVarTriplesTCJ) {
  try {
    ParsedQuery pq = SparqlParser::parse(
        "SELECT ?x ?p ?o WHERE {"
        "<s> ?p ?x . ?x ?p ?o }");
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TWO_COLUMN_JOIN\n    {\n    "
        "SCAN FOR FULL INDEX SPO (DUMMY OPERATION)\n    qet-width: 3 \n  }"
        "\n  join-columns: [0 & 1]\n  |X|\n    {\n    SCAN SOP with S ="
        " \"<s>\"\n    qet-width: 2 \n  }\n  join-columns: [0 & 1]\n "
        " qet-width: 3 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }

  try {
    ParsedQuery pq = SparqlParser::parse(
        "SELECT ?s ?p ?o WHERE {"
        "?s ?p ?o . ?s ?p <x> }");
    QueryPlanner qp(nullptr);
    QueryExecutionTree qet = qp.createExecutionTree(pq);
    ASSERT_EQ(
        "{\n  TWO_COLUMN_JOIN\n    {\n    SCAN FOR FULL INDEX SPO"
        " (DUMMY OPERATION)\n    qet-width: 3 \n  }\n  join-"
        "columns: [0 & 1]\n  |X|\n    {\n    SCAN OSP with "
        "O = \"<x>\"\n    qet-width: 2 \n  }\n  join-columns"
        ": [0 & 1]\n  qet-width: 3 \n}",
        qet.asString());
  } catch (const ad_semsearch::Exception& e) {
    std::cout << "Caught: " << e.getFullErrorMessage() << std::endl;
    FAIL() << e.getFullErrorMessage();
  } catch (const std::exception& e) {
    std::cout << "Caught: " << e.what() << std::endl;
    FAIL() << e.what();
  }
}
Пример #25
0
 virtual bool prepareToYield() {
     if ( _c && !_cc ) {
         _cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , qp().ns() ) );
     }
     if ( _cc ) {
         _posBeforeYield = currLoc();
         return _cc->prepareToYield( _yieldData );
     }
     // no active cursor - ok to yield
     return true;
 }
Пример #26
0
void QScope::refresh(timeref_t t) {
  if (t) {
    qss.endtime = t;
    nspikes = 0;
  }
  QPainter qp(this);
  erase(contentsRect());
  drawContents(&qp);
  //drawContents_box(&qp);
  forall(&QScope::refresh,t); // for satellites i think
}
Пример #27
0
int
main(int argc, char* argv[]) 
{
    if (argc < 2) {
        std::cout << "USAGE:\n\t qppub <sensor-id>" << std::endl;
        return -1;
    }

    int sid = atoi(argv[1]);
    const int N = 100;

   /*segment1-start*/
   dds::core::QosProvider qp("file://defaults.xml", "DDS DefaultQosProfile");

  // create a Domain Participant, -1 defaults to value defined in configuration file
   dds::domain::DomainParticipant dp(-1);

   dds::topic::qos::TopicQos topicQos = qp.topic_qos();

   dds::topic::Topic<tutorial::TempSensorType> topic(dp, "TempSensor", topicQos);

   dds::pub::qos::PublisherQos pubQos = qp.publisher_qos();
   dds::pub::Publisher pub(dp, pubQos);

   dds::pub::qos::DataWriterQos dwqos = qp.datawriter_qos();
   dds::pub::DataWriter<tutorial::TempSensorType> dw(pub, topic, dwqos);  
   /*segment1-end*/
 
    const float avgT = 25;
    const float avgH = 0.6;
    const float deltaT = 5;
    const float deltaH = 0.15;
    // Initialize random number generation with a seed
    srandom(clock());
    
    // Write some temperature randomly changing around a set point
    float temp = avgT + ((random()*deltaT)/RAND_MAX);
    float hum  = avgH + ((random()*deltaH)/RAND_MAX);

    tutorial::TempSensorType sensor( sid, temp, hum, tutorial::CELSIUS );

    // Write the data
    for (unsigned int i = 0; i < N; ++i) {
        dw.write(sensor);
        std::cout << "DW << " << sensor << std::endl;
        std::this_thread::sleep_for(std::chrono::seconds(1));
        temp = avgT + ((random()*deltaT)/RAND_MAX);
        sensor.temp(temp); 
        hum = avgH + ((random()*deltaH)/RAND_MAX);
        sensor.hum(hum);
    }
  
   return 0;
}
Пример #28
0
void QScope::refresh_together(timeref_t t) {// DB modification, extracted from refresh
  if (t) {
    qss.endtime = t;
    nspikes = 0;
  }
  QPainter qp(this);
  //drawContents_all(&qp);
  erase(contentsRect());
  drawContents_together(&qp);
  forall(&QScope::refresh_together,t); // for satellites i think
}
Пример #29
0
void KReportPage::renderPage(int page)
{
    d->page = page - 1;
    d->pixmap.fill();
    QPainter qp(&d->pixmap);
    if (d->reportDocument) {
        KReportRendererContext cxt;
        cxt.painter = &qp;
        d->renderer->render(cxt, d->reportDocument, d->page);
    }
    update();
}
Пример #30
0
void IBConnection::post_recv(struct ibv_recv_wr* wr)
{
    struct ibv_recv_wr* bad_recv_wr;

    int err = ibv_post_recv(qp(), wr, &bad_recv_wr);
    if (err) {
        L_(fatal) << "ibv_post_recv failed: " << strerror(err);
        throw InfinibandException("ibv_post_recv failed");
    }

    ++total_recv_requests_;
}