Esempio n. 1
0
// Perform the OR operation on the first word and the remaining query.
// This function designed so as to give OR precedence over AND
DocNode *doOR(char *first_word, char *rem_query, INVERTED_INDEX *index) {
  // Start building the OR result
  DocNode *OR_result = getResultsForWord(first_word, index);

  char w1[MAX_WORD_LENGTH], w2[MAX_WORD_LENGTH], wsleft[MAX_INPUT_LENGTH];
  BZERO(w1, MAX_WORD_LENGTH); BZERO(w2, MAX_WORD_LENGTH); BZERO(wsleft, MAX_INPUT_LENGTH);

  // Note that the remaining query is read.
  int total_read = sscanf (rem_query, "%s %s %999c", (char *)&w1, (char *)&w2, (char *)&wsleft);

  // This ensures the OR precedence. Since this is OR, we can just keep
  // updating the produced result.
  if (total_read > 0) {
    ORHelper(&OR_result, getResultsForWord(w1, index));
  }

  // eg: rem_query: cat dog
  if (total_read == 2) {
    return ANDHelper(OR_result, getResultsForWord(w2, index));
  }

  // eg: rem_query: cat OR dog
  if (total_read == 3) {
    if (!strncmp(w2, "OR", 2))
      ORHelper(&OR_result, getResults(wsleft, index));
    else
      return ANDHelper(OR_result, getResults(wsleft, index));
  }

  return OR_result;
}
Esempio n. 2
0
void SearchController::resultsAction()
{
    checkParams({"id"});

    const int id = params()["id"].toInt();
    int limit = params()["limit"].toInt();
    int offset = params()["offset"].toInt();

    const auto searchHandlers = sessionManager()->session()->getData<SearchHandlerDict>(SEARCH_HANDLERS);
    if (!searchHandlers.contains(id))
        throw APIError(APIErrorType::NotFound);

    const SearchHandlerPtr searchHandler = searchHandlers[id];
    const QList<SearchResult> searchResults = searchHandler->results();
    const int size = searchResults.size();

    if (offset > size)
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));

    // normalize values
    if (offset < 0)
        offset = size + offset;
    if (offset < 0)  // check again
        throw APIError(APIErrorType::Conflict, tr("Offset is out of range"));
    if (limit <= 0)
        limit = -1;

    if ((limit > 0) || (offset > 0))
        setResult(getResults(searchResults.mid(offset, limit), searchHandler->isActive(), size));
    else
        setResult(getResults(searchResults, searchHandler->isActive(), size));
}
Esempio n. 3
0
TEST_F(LLApiTest, testQueryString) {
  RSIndex* index = RediSearch_CreateIndex("index", NULL, NULL);
  RediSearch_CreateField(index, "ft1", RSFLDTYPE_FULLTEXT, RSFLDOPT_NONE);
  RediSearch_CreateField(index, "ft2", RSFLDTYPE_FULLTEXT, RSFLDOPT_NONE);
  RediSearch_CreateField(index, "n1", RSFLDTYPE_NUMERIC, RSFLDOPT_NONE);
  RediSearch_CreateField(index, "tg1", RSFLDTYPE_TAG, RSFLDOPT_NONE);

  // Insert the documents...
  for (size_t ii = 0; ii < 100; ++ii) {
    char docbuf[1024] = {0};
    sprintf(docbuf, "doc%lu\n", ii);
    Document* d = RediSearch_CreateDocumentSimple(docbuf);
    // Fill with fields..
    sprintf(docbuf, "hello%lu\n", ii);
    RediSearch_DocumentAddFieldCString(d, "ft1", docbuf, RSFLDTYPE_DEFAULT);
    sprintf(docbuf, "world%lu\n", ii);
    RediSearch_DocumentAddFieldCString(d, "ft2", docbuf, RSFLDTYPE_DEFAULT);
    sprintf(docbuf, "tag%lu\n", ii);
    RediSearch_DocumentAddFieldCString(d, "tg1", docbuf, RSFLDTYPE_TAG);
    RediSearch_DocumentAddFieldNumber(d, "n1", ii, RSFLDTYPE_DEFAULT);
    RediSearch_SpecAddDocument(index, d);
  }

  // Issue a query
  auto res = getResults(index, "hello*");
  ASSERT_EQ(100, res.size());

  res = getResults(index, "@ft1:hello*");
  ASSERT_EQ(100, res.size());

  res = getResults(index, "(@ft1:hello1)|(@ft1:hello50)");
  ASSERT_EQ(2, res.size());
}
Esempio n. 4
0
void resultAvailable (int jobID) {
  pthread_mutex_lock(&end_mutex);
  if (jobID < 0) {
    Job tmpJob;
    tmpJob.jobID = jobID;
    tmpJob.returnTo = defaultRCID;
    JobResults *jr = getResults(&tmpJob);
    printf("JM  (%i): got profiling result number %i\n", myid, jobID);
    deleteResults(jr);
    printf("JM  (%i): deleted profiling result number %i.\n", myid, jobID);
    profilesReceived++;
    pthread_cond_signal(&profile_over);
    pthread_mutex_unlock(&end_mutex);
    return;
  }
//  printf("JM  (%i): jobID %i's results arrived. GONNA FETCH'EM.\n", myid, jobID);

  jobRes[jobID] = getResults(job[jobID]);


//  printf("JM  (%i): jobID %i's results fetched. Job %s (%i).\n", myid, jobID,
//      jobRes[jobID]->returnStatus == JOB_RETURN_STATUS_FAILURE ? "FAILED to execute" : "executed successfully",
//      jobRes[jobID]->returnStatus);

  if (jobRes[jobID]->returnStatus == JOB_RETURN_STATUS_FAILURE)
    exit (EXIT_FAILURE);


  nArrivals++;
  pthread_mutex_unlock(&end_mutex);

  if (nArrivals == NJOBS)
    savePic();
}
void RouterKeygen::calc(QString ssid, QString mac) {
	if (calculator != NULL) {
		return; //ignore while a calculator is still running
	}
	if (router != NULL)
		delete router;
	if (ssid == "")
		return;
	if (mac.length() < 17) {
		mac = "";
		if (mac.length() != 5)
			ui->statusBar->showMessage(tr("Invalid MAC. It will not be used."));
	}

	router = matcher.getKeygen(ssid, mac, 0, "");
	if (!router) {
		ui->statusBar->showMessage(
				tr("Unsupported network. Check the MAC address and the SSID."));
		return;
	}
	ui->passwordsList->clear();
	setLoadingAnimation(tr("Calculating keys. This can take a while."));
	this->calculator = new KeygenThread(router);
	connect(this->calculator, SIGNAL( finished() ), this, SLOT( getResults() ));
	ui->calculateButton->setEnabled(false);
	ui->refreshScan->setEnabled(false);
	this->calculator->start();
}
bool CUpnpBrowserGui::getItems(std::string id, unsigned int index, std::vector<UPnPEntry> * &entries, unsigned int &total)
{
	bool tfound = false;
	bool rfound = false;
	bool nfound = false;
	unsigned int returned = 0;
	std::list<UPnPAttribute>results;
	std::list<UPnPAttribute>::iterator i;

	delete entries;
	entries = NULL;

	printf("getItems: getResults: index %d count %d\n", index, m_listmaxshow);
	if (!getResults(id, index, m_listmaxshow, results))
		return false;

	for (i=results.begin(); i!=results.end(); ++i) {
		if (i->first=="NumberReturned") {
			returned=atoi(i->second.c_str());
			nfound=true;
		} else if (i->first=="TotalMatches") {
			total=atoi(i->second.c_str());
			tfound=true;
		} else if (i->first=="Result") {
			entries=decodeResult(i->second);
			rfound=true;
		}
	}
	if (!entries || !nfound || !tfound || !rfound || returned != entries->size() || returned == 0)
		return false;

	return true;
}
Esempio n. 7
0
void RDORuntime::postProcess()
{
    getTracer()->startWriting();
    LPIResultList::iterator it = m_resultAllList.begin();
    while (it != m_resultAllList.end())
    {
        try
        {
            (*it)->calcStat(this, getResults().getOStream());
        }
        catch (const RDORuntimeException&)
        {}
        ++it;
    }

    try
    {
        parent_type::postProcess();
        writeExitCode();
        getTracer()->stopWriting();
    }
    catch (const RDORuntimeException& e)
    {
        writeExitCode();
        getTracer()->stopWriting();
        throw e;
    }
}
Esempio n. 8
0
int DroidStoreAPI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 34)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 34;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QVariantList*>(_v) = getResults(); break;
        case 1: *reinterpret_cast< QVariantList*>(_v) = getTopApps(); break;
        case 2: *reinterpret_cast< QVariantList*>(_v) = getScreenshots(); break;
        case 3: *reinterpret_cast< QVariantList*>(_v) = getPopularAll(); break;
        case 4: *reinterpret_cast< QVariantList*>(_v) = getTrendingAll(); break;
        case 5: *reinterpret_cast< QVariantList*>(_v) = getPopularApps(); break;
        case 6: *reinterpret_cast< QVariantList*>(_v) = getTrendingApps(); break;
        case 7: *reinterpret_cast< QVariantList*>(_v) = getPopularGames(); break;
        case 8: *reinterpret_cast< QVariantList*>(_v) = getTrendingGames(); break;
        case 9: *reinterpret_cast< QVariantList*>(_v) = getDownloads(); break;
        case 10: *reinterpret_cast< bool*>(_v) = getLoading(); break;
        case 11: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getResultsDataModel(); break;
        case 12: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getTopAppsDataModel(); break;
        case 13: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getScreenshotsDataModel(); break;
        case 14: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getPopularAllDataModel(); break;
        case 15: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getTrendingAllDataModel(); break;
        case 16: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getPopularAppsDataModel(); break;
        case 17: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getTrendingAppsDataModel(); break;
        case 18: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getPopularGamesDataModel(); break;
        case 19: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getTrendingGamesDataModel(); break;
        case 20: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getDownloadsDataModel(); break;
        }
        _id -= 21;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 10: setLoading(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 21;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 21;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 21;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 21;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 21;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 21;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 21;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Esempio n. 9
0
void GraphicMode::finished()
{
  running = false;
  output->setText("Calculation finished!");
  calc->setText("Calculate");
  getResults();

}
vector<double> CompositionsInDiffSamples(vector<TString> hnames, TString filename, TString folder, double scale){
  vector<double> hao;
  for(unsigned int i=0; i <hnames.size(); i++ ){
    double entries = getResults( filename, folder, hnames[i], scale);
    hao.push_back(entries);
  }
  return hao;
}
int main(int argc, char* argv[]) {
	VirtualCPU cpu0;
	initCPU(&cpu0);

  	//initialise the program
	Settings* set = setup(argc,argv);
	header(set->htmloutput);
	list_Job* list=FileToJobList(set->jobinput); // list would be sorted on arrival time
	list_Job_sort(list, compare_Job_Arrival);

	setSchedulingMode(&cpu0,set->mode);
	setRoundRobinCPUQuanta(&cpu0,set->rr_quanta);
	setMemoryManagement(&cpu0,set->mem_management);

	int clock=cpu0.current_clock;
	int totalclocks=0;
	int startclocks=clock;

	list_iterator_Job* it = malloc(sizeof(*it));
	list_Job_iterator_init(it, list);

	Job* current = list_Job_examine(it);
	while(current!=NULL){
		while(current!=NULL && clock==current->arrival_time){
			if(current->arrival_time < clock){
				//Error when process is behind the clock
				fprintf(stderr,"Process to be scheduled in the past- ERROR\n");
				exit(EXIT_FAILURE);
			}


			if(totalclocks==0)
				startclocks=clock;
			totalclocks+=current->length_time;

			debug_print("%s: %d @ %d \n",current->jobname,current->arrival_time,clock);
			addJobToCPU(&cpu0,current);		
			current= list_Job_next(it);
		}
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
		
	}
	free(list);
	while(isCPUIdle(&cpu0)==false){
		debug_print("Incrementing clock %d\n",clock);
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
	}
	debug_print_string("Complete!\n");

	list_JobScheduleResult* results = getResults(&cpu0);
	printResultsCompressed(results);

	footer(set->htmloutput);

	return 0;
}
Esempio n. 12
0
void ScanResults::setWpaGui(WpaGui *_wpagui)
{
	wpagui = _wpagui;
	updateResults();
    
	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), SLOT(getResults()));
	timer->start(10000, FALSE);
}
Esempio n. 13
0
bool SimulatorResult::writeToFile(std::string outputFile) {
    std::ofstream output;
    bool result = false; //whether or not writing to file worked
    output.open(outputFile);
    if(output.is_open()) {
        output << getResults();
        output.flush();
        output.close();
        result = true;
    }
    return result;
}
Esempio n. 14
0
int testpluginPlugin::msg(int msgId, void* wParam, void* lParam)
{
    bool handled = false;
    switch (msgId)
    {
    case MSG_INIT:
        init();
        handled = true;
        break;
    case MSG_GET_LABELS:
        getLabels((InputList*) wParam);
        handled = true;
        break;
    case MSG_GET_ID:
        getID((uint*) wParam);
        handled = true;
        break;
    case MSG_GET_NAME:
        getName((QString*) wParam);
        handled = true;
        break;
    case MSG_GET_RESULTS:
        getResults((InputList*) wParam, (QList<CatItem>*) lParam);
        handled = true;
        break;
    case MSG_GET_CATALOG:
        getCatalog((QList<CatItem>*) wParam);
        handled = true;
        break;
    case MSG_EXTEND_CATALOG:
        extendCatalog((SearchInfo*) wParam, (QList<CatItem>*)lParam);
        handled = true;
        break;
    case MSG_LAUNCH_ITEM:
        handled = launchItem((InputList*) wParam, (QList<CatItem>*) lParam);
        break;
    case MSG_HAS_DIALOG:
        handled = true;
        break;
    case MSG_DO_DIALOG:
        doDialog((QWidget*) wParam, (QWidget**) lParam);
        break;
    case MSG_END_DIALOG:
        endDialog((bool) wParam);
        break;
    case MSG_PATH:
        setPath((QString *) wParam);
    default:
        break;
    }

    return handled;
}
vector<double> CompositionSumOfDiffSamples( vector<TString> hnames, vector<TString> filenames, TString folder, double scale ){

  vector<double> totalentries;
  for( unsigned int i=0; i <hnames.size(); i++ ){
    double total=0;
    for(unsigned int ifile=0; ifile <filenames.size(); ifile++ ){;
      double entries = getResults( filenames[ifile], folder, hnames[i], scale);
      total = total + entries;
    }
    totalentries.push_back(total);
  }
  return totalentries;
}
Esempio n. 16
0
void MainWindow::calcChance()
{
    QVector<double> resultsFlo;
    resultsFlo = getResults(0,0);

    QVector<double> resultsDijk;
    resultsDijk = getResults(1,0);

    QVector<double> resultsRand;
    resultsRand = getResults(2,0);

    int tmp = 0;
    int plus = 0;
    for(int i = 0; i < resultsFlo.size(); i++) {
        tmp++;
        if(resultsFlo[i] != resultsDijk[i])
            plus++;
        if(tmp == SAMPLE_SIZE) {
            chanceDijkstra.push_back((double)1-(plus/SAMPLE_SIZE));
            plus = 0;
            tmp = 0;
        }
    }

    plus = 0;
    tmp = 0;

    for(int i = 0; i < resultsFlo.size(); i++) {
        tmp++;
        if(resultsFlo[i] != resultsRand[i])
            plus++;
        if(tmp == SAMPLE_SIZE) {
            chanceRand.push_back((double)1-(double)((double)plus/(double)SAMPLE_SIZE));
          //      qDebug() << chanceRand.back() << "chance" << (double)1-(double)((double)plus/(double)SAMPLE_SIZE);
            plus = 0;
            tmp = 0;
        }
    }
}
Esempio n. 17
0
TEST_F(LLApiTest, testPhoneticSearch) {
  // creating the index
  RSIndex* index = RediSearch_CreateIndex("index", NULL, NULL);
  RediSearch_CreateField(index, FIELD_NAME_1, RSFLDTYPE_FULLTEXT, RSFLDOPT_TXTPHONETIC);
  RediSearch_CreateField(index, FIELD_NAME_2, RSFLDTYPE_FULLTEXT, RSFLDOPT_NONE);

  RSDoc* d = RediSearch_CreateDocument(DOCID1, strlen(DOCID1), 1.0, NULL);
  RediSearch_DocumentAddFieldCString(d, FIELD_NAME_1, "felix", RSFLDTYPE_DEFAULT);
  RediSearch_DocumentAddFieldCString(d, FIELD_NAME_2, "felix", RSFLDTYPE_DEFAULT);
  RediSearch_SpecAddDocument(index, d);

  // make sure phonetic search works on field1
  RSQNode* qn = RediSearch_CreateTokenNode(index, FIELD_NAME_1, "phelix");
  auto res = getResults(index, qn);
  ASSERT_EQ(1, res.size());
  ASSERT_EQ(DOCID1, res[0]);

  // make sure phonetic search on field2 do not return results
  qn = RediSearch_CreateTokenNode(index, FIELD_NAME_2, "phelix");
  res = getResults(index, qn, true);
  ASSERT_EQ(0, res.size());
  RediSearch_DropIndex(index);
}
Esempio n. 18
0
void GraphicMode::processEssid()
{
  int pos;
  QString input = lineEdit->text();
  if ( this->running )
  {
    finder->stop();
    output->setText("Cancelled!");
    getResults();
    calc->setText("Calculate");
    this->running = false;
    return;
  }

  if ( input.isEmpty() )
  {
      output->setText("ESSID code empty!");
      return;
    }
  if ( lineEdit->validator()->validate( input , pos ) != QValidator::Acceptable )
  {
    output->setText("ESSID code not valid!");
    return;
  }
  else
  {
      output->setText("Calculating...");
      if (  this->singleYear->isChecked()  )
      {
        char year[5];
        sprintf( year , "%d" , this->spinboxYear->value() );
        output->append("Warning: Calculating only for routers from ");
        output->append(QString(year));
      }
  }
  this->running = true;
  calc->setText("Cancel");
  uint32_t essid = input.toInt(NULL , 16 );
  if (  finder == NULL )
  {
    finder = new BruteForce( essid );
    connect( finder, SIGNAL(finished()),  this , SLOT(finished()));
    connect( finder, SIGNAL(updateBar()),  this , SLOT(updateProgress()));
  }
  this->progressBar->setValue(0);
  if ( this->singleYear->isChecked() )
    finder->generate(essid , this->spinboxYear->value() - 2000 );
  else
    finder->generate(essid );
}
Esempio n. 19
0
int controlyPlugin::msg(int msgId, void* wParam, void* lParam)
{
	int handled = 0;
	switch (msgId)
	{		
		case MSG_INIT:
			init();
			handled = 1;
			break;
		case MSG_GET_ID:
			getID((uint*) wParam);
			handled = 1;
			break;
		case MSG_GET_NAME:
			getName((QString*) wParam);
			handled = 1;
			break;
		case MSG_GET_CATALOG:
			getCatalog((QList<CatItem>*) wParam);
			handled = 1;
			break;
		case MSG_GET_RESULTS:
			getResults((QList<InputData>*) wParam, (QList<CatItem>*) lParam);
			handled = 1;
			break;
		case MSG_LAUNCH_ITEM:
			handled = launchItem((QList<InputData>*) wParam, (CatItem*) lParam);
			break;

		case MSG_HAS_DIALOG:
			handled = true;
			break;
		case MSG_DO_DIALOG:
			doDialog((QWidget*) wParam, (QWidget**) lParam);
			break;
		case MSG_END_DIALOG:
			endDialog(wParam != 0);
			break;

		case MSG_PATH:
			setPath((QString *) wParam);
			break;

		default:
			break;
	}
		
	return handled;
}
Esempio n. 20
0
void KBBGame::giveUp()
{
  if (running) {
    bool ok;
    ok = QMessageBox::warning(0, trans->translate("Warning!"), 
			    trans->translate(
			    "Do you really want to give up this game?"), 
			    trans->translate("Yes, I'm burnt out."),
			    trans->translate("No, not yet...") );
    if (!ok) {
      getResults();
      abortGame();
    }
  }
}
Esempio n. 21
0
void RouterKeygen::calc(QScanResult * wifi) {
    if (calculator != NULL) {
        return; //ignore while a calculator is still running
    }
    if (wifi->getSupportState() == Keygen::UNSUPPORTED) {
        ui->statusBar->showMessage(
                tr("Unsupported network. Check the MAC address and the SSID."));
        return;
    }
    ui->passwordsList->clear();
    setLoadingAnimation(tr("Calculating keys. This can take a while."));
    this->calculator = new KeygenThread(wifi->getKeygens());
    connect(this->calculator, SIGNAL( finished() ), this, SLOT( getResults() ));
    enableUI(false);
    this->calculator->start();
}
Esempio n. 22
0
int VerbyPlugin::msg(int msgId, void* wParam, void* lParam)
{
	bool handled = false;
	switch (msgId)
	{		
	case MSG_INIT:
		init();
		handled = true;
		break;
	case MSG_GET_ID:
		getID((uint*) wParam);
		handled = true;
		break;
	case MSG_GET_NAME:
		getName((QString*) wParam);
		handled = true;
		break;
	case MSG_GET_LABELS:
		getLabels((QList<InputData>*) wParam);
		handled = true;
		break;
	case MSG_GET_RESULTS:
		getResults((QList<InputData>*) wParam, (QList<CatItem>*) lParam);
		handled = true;
		break;
	case MSG_LAUNCH_ITEM:
		launchItem((QList<InputData>*) wParam, (CatItem*) lParam);
		handled = true;
		break;
	case MSG_HAS_DIALOG:
		handled = true;
		break;
	case MSG_DO_DIALOG:
		doDialog((QWidget*) wParam, (QWidget**) lParam);
		break;
	case MSG_END_DIALOG:
		endDialog(wParam != 0);
		break;

	default:
		break;
	}

	return handled;
}
Esempio n. 23
0
TEST_F(LLApiTest, testMultitype) {
  RSIndex* index = RediSearch_CreateIndex("index", NULL, NULL);
  auto* f = RediSearch_CreateField(index, "f1", RSFLDTYPE_FULLTEXT, RSFLDOPT_NONE);
  ASSERT_TRUE(f != NULL);
  f = RediSearch_CreateField(index, "f2", RSFLDTYPE_FULLTEXT | RSFLDTYPE_TAG | RSFLDTYPE_NUMERIC,
                             RSFLDOPT_NONE);

  // Add document...
  RSDoc* d = RediSearch_CreateDocumentSimple("doc1");
  RediSearch_DocumentAddFieldCString(d, "f1", "hello", RSFLDTYPE_FULLTEXT);
  RediSearch_DocumentAddFieldCString(d, "f2", "world", RSFLDTYPE_FULLTEXT | RSFLDTYPE_TAG);
  RediSearch_SpecAddDocument(index, d);

  // Done
  // Now search for them...
  auto qn = RediSearch_CreateTokenNode(index, "f1", "hello");
  auto results = getResults(index, qn);
  ASSERT_EQ(1, results.size());
  ASSERT_EQ("doc1", results[0]);
}
Esempio n. 24
0
/*
** Handles communication of robot during execution of script until
** an ERROR is received or the FINISHED state is reached. Returns a
** pointer to a result structure with the results of the robot test execution
** Returns NULL on error
**
** Arguments:
** sock - pointer to socket file descriptor for communication with the robot
*/
result * handleControl(int * sock){
	char * msg;
	int done = 0;
	while(!done){
		msg = readAndClassifyMessage(&state, *sock);
		if(msg == NULL){
			return NULL;
		}

		if(state != FINISHED && state != ERROR){
			free(msg);
		}
		else{
			done = 1;
		}
	}
	result * res = getResults(msg);
	free(msg);
	return res;
}
Esempio n. 25
0
void TIME::years_loop (int run_years)
{
  bool loop = true;
  
  for (theYear = 0; theYear < run_years; theYear++)
  {
	SEEDS::zeroAllSeeds(); // just a precaution...
	pRESULTS->zeroAnnualSums();	
	pGRID->yearlyReset();
	
	informUser(theYear, run_years);
	pRAIN->drawYear(); // go to function to choose random or ordered sequence
	days_loop();		// each year
	
	pRESULTS->calcMeanAnnualValues();
	loop = getResults(run_years);	// after each year
	if (loop == false)// check if population is extinct
	  theYear = run_years; // stop loop
	if(theYear%10==3) pRESULTS->saveVegCover();
  }
}
DifferentialSteeringTest::DifferentialSteeringTest(QWidget *parent) :
	QWidget(parent) {

	this->setWindowTitle("DifferentialSteeringTest");
	this->setLayout(new QVBoxLayout());
	this->layout()->setContentsMargins(0, 0, 0, 0);

	graph = new Graph();
	slider = new QSlider(Qt::Horizontal);
	slider->setValue(50);
	btnCalculate = new QPushButton("Clear");

	this->layout()->addWidget(graph);
	this->layout()->addWidget(slider);
	this->layout()->addWidget(btnCalculate);

	connect(btnCalculate, SIGNAL(clicked()), this, SLOT(clear()));
	connect(graph, SIGNAL(clicked(double, double)), this, SLOT(clicked(double,double)));
	connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int)));

	getResults();
}
Esempio n. 27
0
void KBBGame::gameFinished()
{
  if (running) {
    QMessageBox mb;
    QString s;
    if (ballsPlaced == balls) {
      getResults();
      abortGame();
      s.sprintf( trans->translate("Your final score is: %d."), score );
      if (score <= (balls*3))
	mb.setButtonText( trans->translate("Wow!") );
      else
	mb.setButtonText( trans->translate("Damned!") );
    } else {
      s.sprintf( trans->translate(
                 "You should place %d balls!\nYou have placed %d."),
		balls, ballsPlaced );
      mb.setButtonText( trans->translate("D'accord") );
    }
    mb.setText( s );
    mb.show();  
  }
}
Esempio n. 28
0
// Perform the AND operation on the first word and the remaining query.
// To keep the tasks parallel to OR, this was added. Could have done without it.
DocNode *doAND(char *first_word, char *rem_query, INVERTED_INDEX *index) {
  return ANDHelper(getResultsForWord(first_word, index), getResults(rem_query, index));
}
void DifferentialSteeringTest::sliderChanged(int value) {
	graph->setScale(value);
	getResults();
	graph->setResults(results);
}
void DifferentialSteeringTest::clear() {

	getResults();
	graph->setResults(results);
}