Example #1
0
void MergePrefixSum::executePlanOperation() {
  if (input.numberOfTables() == 1) {
    addResult(getInputTable());
    return;
  }

  const auto resultSize = getInputTable()->size();
  std::vector<storage::ColumnMetadata> meta {storage::ColumnMetadata::metadataFromString(types::integer_name, "count")};
  auto result = std::make_shared<storage::Table>(&meta, nullptr, resultSize, true, false);
  result->resize(resultSize);

  const auto &res_vec = getDataVector(result).first;

  std::vector<std::shared_ptr<storage::FixedLengthVector<value_id_t>>> vecs;
  for(size_t i=0, stop=input.numberOfTables(); i < stop; ++i) {
    vecs.emplace_back(getDataVector(getInputTable(i)).first);
  }

  for(size_t i=0; i < resultSize; ++i) {
    value_id_t pos = std::numeric_limits<value_id_t>::max();
    for(size_t j=0, stop=vecs.size(); j < stop; ++j) {
      auto tmp = vecs[j]->get(0,i);
      pos = tmp < pos ? tmp : pos;
    }
    res_vec->set(0, i, pos);
  }
  addResult(result);
}
Example #2
0
ResultTreeNode* addResult(ResultTreeNode* prtree, double value, double volume, OctNode* pnode) {

    // put address in result tree based on value

    if (prtree == NULL) { // at empty node
        if ((prtree = (ResultTreeNode*) malloc(sizeof (ResultTreeNode))) == NULL)
            fprintf(stderr, "ERROR allocating memory for result-tree node.\n");
        prtree->value = value;
        prtree->level = pnode->level;
        prtree->volume = volume; // node volume depends on geometry in physical space, may not be dx*dy*dz
        prtree->pnode = pnode;
        prtree->left = prtree->right = NULL;

        /* 20101213 AJL removed this block - causes memory errors in trace_processing/location.c
           } else if (value == prtree->value) { // prevent assymetric tree if multiple identical values
            if (get_rand_int(-10000, 9999) < 0)
                prtree->left = addResult(prtree->left, value, volume, pnode);
            else
                prtree->right = addResult(prtree->right, value, volume, pnode);
         */

    } else if (value < prtree->value) {
        prtree->left = addResult(prtree->left, value, volume, pnode);

    } else {
        prtree->right = addResult(prtree->right, value, volume, pnode);
    }

    return (prtree);
}
Example #3
0
void JabberAdd::setBrowser(bool bBrowser)
{
	if (m_bBrowser == bBrowser)
		return;
	m_bBrowser = bBrowser;
	if (m_bBrowser && (m_browser == NULL)){
		m_browser = new JabberBrowser;
		emit addResult(m_browser);
		m_browser->setClient(m_client);
		connect(m_browser, SIGNAL(destroyed()), this, SLOT(browserDestroyed()));
	}
	emit showResult(m_bBrowser ? m_browser : NULL);
	const QIconSet *is = Icon(m_bBrowser ? "1leftarrow" : "1rightarrow");
	if (is)
		btnBrowser->setIconSet(*is);
	if (m_bBrowser){
		edtJID->setEnabled(false);
		edtMail->setEnabled(false);
		edtFirst->setEnabled(false);
		edtLast->setEnabled(false);
		edtNick->setEnabled(false);
		lblFirst->setEnabled(false);
		lblLast->setEnabled(false);
		lblNick->setEnabled(false);
		emit setAdd(false);
	}else{
		m_btnJID->slotToggled(m_btnJID->isChecked());
		m_btnName->slotToggled(m_btnName->isChecked());
		m_btnMail->slotToggled(m_btnMail->isChecked());
	}
}
Example #4
0
// Executing this on a store with delta results in undefined behavior
// Execution with horizontal tables results in undefined behavior
void Distinct::executePlanOperation() {
  // Map to cache values
  std::unordered_map<storage::value_id_t, storage::pos_t> map;
  auto distinct = _field_definition[0];

  // iterate over all rows
  const auto &in = input.getTable(0);
  uint64_t numRows = in->size();
  ValueId val;

  // Build distinct value list
  for (uint64_t i = 0; i < numRows; ++i) {
    val = in->getValueId(distinct, i);
    if (map.count(val.valueId) == 0)
      map[val.valueId] = i;
  }

  //Build result list
  storage::atable_ptr_t result;
  auto pos = new storage::pos_list_t;
  for (const auto &e : map)
    pos->push_back(e.second);

  // Return pointer calculator
  addResult(PointerCalculatorFactory::createPointerCalculator(input.getTable(0),
                                                              nullptr,
                                                              pos));
}
Example #5
0
// merges all input tables or input hash tables with the current output and clears the input.
void PipelineUnion::executePlanOperation() {
  LOG4CXX_DEBUG(_pipelineLogger, "executePlanOperation()");
  auto tables = _pipelineInput([](OperationData & pipelineInput)->std::vector<storage::c_atable_ptr_t> {
    return pipelineInput.allOf<storage::AbstractTable>();
  });
  addResult(unionTables(tables));
}
Example #6
0
void JabberAdd::setBrowser(bool bBrowser)
{
    if (m_bBrowser == bBrowser)
        return;
    m_bBrowser = bBrowser;
    if (m_bBrowser && (m_browser == NULL)){
        m_browser = new JabberBrowser;
        emit addResult(m_browser);
        m_browser->setClient(m_client);
        connect(m_browser, SIGNAL(destroyed()), this, SLOT(browserDestroyed()));
    }
    emit showResult(m_bBrowser ? m_browser : NULL);
    QIconSet is = Icon(m_bBrowser ? "1leftarrow" : "1rightarrow");
    if (!is.pixmap(QIconSet::Small, QIconSet::Normal).isNull())
        btnBrowser->setIconSet(is);
    if (m_bBrowser){
        edtJID->setEnabled(false);
        edtMail->setEnabled(false);
        edtFirst->setEnabled(false);
        edtLast->setEnabled(false);
        edtNick->setEnabled(false);
        lblFirst->setEnabled(false);
        lblLast->setEnabled(false);
        lblNick->setEnabled(false);
        emit setAdd(false);
    }else{
        grpJID->slotToggled();
        grpName->slotToggled();
        grpMail->slotToggled();
    }
}
Example #7
0
void mainWindow::performSearch()
{
    disconnect(searchResults,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(showSoftDetails(QListWidgetItem *,QListWidgetItem *)));
    searchResults->clear();
    softwareDetails->setText("");
    connect(searchResults,SIGNAL(currentItemChanged(QListWidgetItem *,QListWidgetItem *)),this,SLOT(showSoftDetails(QListWidgetItem *,QListWidgetItem *)));
    searchKey=searchKey.toLower();
    QStringList keywordList=searchKey.split(QRegExp("\\s+"));
    std::vector<std::string> keywords;
    for (int i = 0; i < keywordList.size(); ++i)
    keywords.push_back(keywordList.at(i).toLocal8Bit().constData());

    int totalFound=0;
    int softIndex=0;
    int totalKeywords=keywords.size();
    for(int i=0;i<discList.size();i++)
    {
        tmpDisc=discList[i];
        if((year==tmpDisc.year || year==0) && (month==tmpDisc.month || month==0))
        {
            for(int k=softIndex;k<softIndex+tmpDisc.count;k++)
            {
                bool flag=false;
                bool found=false;
                int j=totalKeywords;
                tmpSoft=softList[k];
                flag=(QString(tmpSoft.license).toLower()==license.toLower() || license=="");

                while(j-- && flag)
                {
                    if(dbSearchContent(keywords[j]))
                    {
                         found=true;
                         if(mode==1)
                         break;
                    }
                    else
                    {
                         if(mode==0)
                         {
                              found=false;
                              break;
                         }
                    }
                }
                if(found)
                {
                    totalFound++;
                    addResult(k,i);
                }
            }
        }
        softIndex+=tmpDisc.count;

    }
    if(totalFound==0)
    {
        QMessageBox::warning(this,tr("Not Found!!!"),tr("No matches found in the archive"));
    }
}
Example #8
0
void CGroupSearchResultPage::onSearchGroupReply(GROUP_INFO *info)
{
	GetDlgItem(IDC_REFRESH)->EnableWindow();

	if (info)
		addResult(info);
}
Example #9
0
void LayoutTableLoad::executePlanOperation() {
  const auto &input = this->input.getTable(0);
  if ((input->columnCount() >= 1) && (input->size() >= _input_row)) {
    std::string tmp_table_description = input->getValue<std::string>(0, _input_row);

    std::vector<std::string> description_lines;
    splitString(description_lines, tmp_table_description, "\n");

    if (_override_group != "") {
      std::vector<std::string> group_lines;
      splitString(group_lines, description_lines[2], "|");
      for (size_t index = 0; index < group_lines.size(); ++index) {
        if (_override_group == "C")
          group_lines[index] = std::to_string(index) + "_C";
        else if (_override_group == "R")
          group_lines[index] = "0_R";
        else
          throw std::runtime_error("unknown override_group " + _override_group);
      }
      description_lines[2] = joinString(group_lines, "|");
    }

    std::string table_description = joinString(description_lines, "\n");

    StringHeader header(table_description);
    CSVInput input(_file_name, CSVInput::params().setCSVParams(csv::HYRISE_FORMAT));
    StorageManager *sm = StorageManager::getInstance();
    sm->loadTable(_table_name, Loader::params().setHeader(header).setInput(input));
    addResult(sm->getTable(_table_name));
  } else {
    throw std::runtime_error("Input of LayoutTableLoad doesn't have at least one field to begin with");
  }
}
Example #10
0
bool ProjectBase::addOMCase(QString filePath)
{
    // do not reload if already loaded
    if(!casesFiles().contains(QFileInfo(filePath)))
    {
        OMCase* newCase = Load::newOMCase(filePath,this);
        if(!newCase)
            return false;

        Problem* problem = dynamic_cast<Problem*>(newCase);
        if(problem)
            addProblem(problem);
        else
        {
            Result* result = dynamic_cast<Result*>(newCase);
            if(result)
                addResult(result);
        }
        return true;
    }
    else
    {
        InfoSender::instance()->sendWarning(QString("OMCase already loaded. Won't be loaded a second time. [")+filePath+QString("]"));
        return false;
    }
}
Example #11
0
bool Request::incoming(const Network::Locator &locator, const BinaryString &target)
{
	// Ignore subdirectories
	String path = locator.prefix + locator.path;

	if(!mPath.empty())
	{
		if(mListDirectories)
		{
			if(mPath != path)
				return false;
		}
		else {
			if(path.size() < mPath.size() || path.substr(0, mPath.size()) != mPath)
				return false;
		}
	}

	if(fetch(locator, target, false))	// no content
	{
		Resource resource(target, true);	// local only
		if(!mListDirectories || !resource.isDirectory() || fetch(locator, target, true))
			addResult(resource, mFinishedAfterTarget);
	}

	return true;
}
Example #12
0
void TestCameraFile::testFactory()
{
	std::unique_ptr<CameraDriver> camera;
	
	camera.reset(CameraDriver::factory("file", ""));
	addResult("creating file driver", (bool) camera);
}
Example #13
0
// calculates the prefix Sum for a given table
void PrefixSum::executePlanOperation() {
   // get attribute vector of input table
  const auto &in = getInputTable();
  const size_t table_size = in->size();

  // get attribute vector of output table
  std::vector<storage::ColumnMetadata> metadata;
  metadata.push_back(in->metadataAt(0));
  auto output = std::make_shared<storage::Table>(&metadata, nullptr, table_size, true, false);
  output->resize(table_size);
  const auto &oavs = output->getAttributeVectors(0);
  auto ovector = std::dynamic_pointer_cast<storage::FixedLengthVector<value_id_t>>(oavs.at(0).attribute_vector);

  // Build ivector list to avoid lock contention while getting the vectors
  const size_t ivec_size = input.numberOfTables();
  std::vector<vec_ref_t> ivecs;
  for(size_t i=0; i < input.numberOfTables(); ++i) {
    ivecs.emplace_back(getDataVector(getInputTable(i)).first);
  }

  // calculate the prefix sum based on the index and the number of inputs
  // we need to look at to calculate the correct offset
  value_id_t sum = 0;
  for(size_t i=0; i < table_size; ++i) {
    sum += sumForIndex(ivec_size, ivecs, i);
    ovector->set(0, i, sum + sumForIndexPrev(ivec_size, ivecs, i));
  }

  addResult(output);
}
Example #14
0
void Checks_Sentences::checkUnknownCharacter ()
{
  if (isSpace) return;
  if (isCapital) return;
  if (isSmallLetter) return;
  if (isEndMark) return;
  if (isCenterMark) return;
  addResult ("Unknown character", Checks_Sentences::displayGraphemeOnly);
}
Example #15
0
 virtual void flushResults(bool complete=false)
 {
     if (resultData.length() || complete)
     {
         ActPrintLog("flushing result");
         addResult(numResults, resultData, complete);
         resultData.clear();
         ActPrintLog("result flushed");
     }
 }
Example #16
0
void SmallestTableScan::executePlanOperation() {
  auto smallestTable = getInputTable(0);
  for (size_t i = 1; i < input.numberOfTables(); ++i) {
    auto nextTable = getInputTable(i);
    if (nextTable->size() < smallestTable->size()) {
      smallestTable = nextTable;
    }
  }
  addResult(smallestTable);
}
Example #17
0
void SimpleRawTableScan::executePlanOperation() {
  auto table = std::dynamic_pointer_cast<const storage::RawTable>(input.getTable(0));
  if (!table)
    throw std::runtime_error("Input table is no uncompressed raw table");

  // Prepare a result that contains the result semi-compressed, and only row-wise
  storage::metadata_list meta(table->columnCount());
  for(size_t i=0; i<table->columnCount(); ++i)
    meta[i] = table->metadataAt(i);
  auto result = std::make_shared<storage::Table>(&meta,
                                                 nullptr,
                                                 1,  /* initial size */
                                                 false, /* sorted */
                                                 false /* compressed */);

  // Prepare the copy operator
  storage::copy_value_functor_raw_table fun(result, table);
  storage::type_switch<hyrise_basic_types> ts;
  auto positions = new storage::pos_list_t;

  size_t tabSize = table->size();
  for(size_t row=0; row < tabSize; ++row) {
    if ((*_comparator)(row)) {
      if (_materializing) {
        result->resize(result->size() + 1);
        for(size_t i=0; i < result->columnCount(); ++i) {
          fun.setValues(result->size() - 1, row, i);
          ts(table->typeOfColumn(i), fun);
        }
      }
      else {
        positions->push_back(row);
      }
    }
  }

  if (_materializing) {
    addResult(result);
  } else {
    addResult(storage::PointerCalculator::create(table, positions));
  }
}
Example #18
0
void Print::executePlanOperation() {
  std::cout << "Print Operator: " << _comment << std::endl;
  // print all input data and add it to the output
  for (size_t i = 0; i < input.numberOfTables(); ++i) {
    if (_limit > 0)
      input.getTable(i)->print(_limit);
    else
      input.getTable(i)->print();
    addResult(input.getTable(i));
  }
}
void MySQLTableLoad::executePlanOperation() {
  StorageManager *sm = StorageManager::getInstance();
  storage::atable_ptr_t t;
  if (sm->exists(_table_name)) {
    t = sm->getTable(_table_name);
    addResult(t);
  } else {
    t = Loader::load(
          Loader::params().setInput(
            MySQLInput(
              MySQLInput::params()
              .setSchema(_database_name)
              .setTable(_table_name)
              .setLimit(_load_limit)
            )
          ));
    sm->loadTable(_table_name, t);
    addResult(t);
  }
}
Example #20
0
void PosUpdateScan::executePlanOperation() {
  auto c_pc = checked_pointer_cast<const PointerCalculator>(input.getTable(0));
  auto c_store = checked_pointer_cast<const storage::Store>(c_pc->getActualTable());

  // Cast the constness away
  auto store = std::const_pointer_cast<storage::Store>(c_store);

  // Get the current maximum size
  const auto& beforSize = store->size();

  // Get the offset for inserts into the delta and the size of the delta that
  // we need to increase by the positions we are inserting
  auto writeArea = store->appendToDelta(c_pc->getPositions()->size());

  // Get the modification record for the current transaction
  auto& txmgr = tx::TransactionManager::getInstance();
  auto& modRecord = txmgr[_txContext.tid];

  // Functor we use for updating the data
  set_json_value_functor fun(store->getDeltaTable());
  storage::type_switch<hyrise_basic_types> ts;

  size_t counter = 0;
  for(const auto& p : *(c_pc->getPositions())) {
    // First delete the old record
    bool deleteOk = store->markForDeletion(p, _txContext.tid) == hyrise::tx::TX_CODE::TX_OK;
    if(!deleteOk) {
      txmgr.rollbackTransaction(_txContext);
      throw std::runtime_error("Aborted TX because TID of other TX found");
    }
    modRecord.deletePos(store, p);
    //store->setTid(p, _txContext.tid);

    // Copy the old row from the main
    store->copyRowToDelta(store, p, writeArea.first+counter, _txContext.tid);
    // Update all the necessary values
    for(const auto& kv : _raw_data) {
      const auto& fld = store->numberOfColumn(kv.first);
      fun.set(fld, writeArea.first+counter, kv.second);
      ts(store->typeOfColumn(fld), fun);
    }

    // Insert the new one
    modRecord.insertPos(store, beforSize+counter);
    ++counter;
  }

  // Update affected rows
  auto rsp = getResponseTask();
  if (rsp != nullptr)
    rsp->incAffectedRows(counter);

  addResult(c_store);
}
Example #21
0
void IndexScan::executePlanOperation() {
    StorageManager *sm = StorageManager::getInstance();
    auto idx = sm->getInvertedIndex(_indexName);

    // Handle type of index and value
    storage::type_switch<hyrise_basic_types> ts;
    ScanIndexFunctor fun(_value, idx);
    storage::pos_list_t *pos = ts(input.getTable(0)->typeOfColumn(_field_definition[0]), fun);

    addResult(PointerCalculator::create(input.getTable(0), pos));
}
Example #22
0
void ra_mean::open()
// ra_mean::open calls every program start
{
  pwr_tStatus	sts;
  pwr_tUInt32	num;
  pwr_tObjid	aoid;
  string	line, tmpSystem, tmpPointer, tmpTime;
  pwr_tBoolean	newResult = TRUE;
  pwr_tInt32	nValues = 0;
  
  isActive_ = 0;
  nResultsMax_ = 5;
  nResults_ = 0;
  resultsList_ = new ra_result[nResultsMax_]; // Allocate memory for resultsList_
  
  ifstream setup_file("ra_mean_setup.txt"); // Setup file
  
  if(setup_file.is_open() ) { // Open setup file
    
    while ( getline (setup_file, line) ) { // Get lines i setup file
      
      if(line.substr(0,1) != "#") { // Check if line don't start with #, then read info
	tmpSystem = line.substr(0, line.find(' ') );
	tmpPointer = line.substr((line.find(' ') + 1), line.length() - line.find(' ') );
	
	if(tmpPointer.find(' ') != string::npos)
	  tmpPointer = tmpPointer.substr(0, tmpPointer.find(' '));
	
	if(newResult) { // If it's the first row in description, create a new result
	  addResult( tmpSystem.c_str(), tmpPointer.c_str() );
	  newResult = FALSE;
	}
	else { // Else we create a new value to the current result 
	  resultsList_[nResults_].addValue(tmpPointer.c_str());
	  nValues++;
	}
      }
      else { // If we encounter a #, then we shall prepare for a new result entry
	nValues = 0;
	
	if(newResult == FALSE) {
	  newResult = TRUE;
	  nResults_++;
	}
      }
    }
    setup_file.close(); // When there are no more lines, close the file
  }
  else 
    alarm("ra_mean", "Unable to open file");
    
  sts = mh_ApplConnect( aoid, mh_mApplFlags(0), "", mh_eEvent_Info, mh_eEventPrio_A, mh_mEventFlags_Bell, "", &num);
    if (EVEN (sts)) throw co_error(sts);
}
Example #23
0
CLMatrixLoader::CLMatrixLoader( std::shared_ptr< SimpleMatrix<cl_float> > source,
                                Context *context,
                                cl::CommandQueue *queue )
  : ClAlgorithm ( context, queue )
{
  m_src = source;
  addDependency(m_src.get());
  m_result = std::make_shared< CLMatrix >( m_src->getHeight(),
                                          m_src->getWidth() );
  addResult(m_result.get());
}
Example #24
0
void Request::addResult(Resource &resource, bool finish)
{
	if(resource.isDirectory() && mListDirectories)
	{
		// List directory and add records
		Resource::Reader reader(&resource);
		Resource::DirectoryRecord record;
		while(reader.readDirectory(record))
			addResult(record);
	}
	else {
		// Do not list, just add corresponding record
		addResult(resource.getDirectoryRecord());
	}

	if(finish)
	{
		std::unique_lock<std::mutex> lock(mMutex);
		mFinished = true;
	}
}
Example #25
0
static inline void processCuts(
    size_t i, size_t maxCuts, BondVector_t& bonds_selected,
    const std::vector<BondVector_t>& matching_bonds, const ROMol& mol,
    std::vector<std::pair<ROMOL_SPTR, ROMOL_SPTR> >& res) {
  for (size_t x = i; x < matching_bonds.size(); x++) {
    appendBonds(bonds_selected, matching_bonds[x]);
    addResult(res, mol, bonds_selected, maxCuts);
    if (bonds_selected.size() < maxCuts)
      processCuts(x + 1, maxCuts, bonds_selected, matching_bonds, mol, res);
    bonds_selected.pop_back();
  }
}
Example #26
0
void SimpleTableScan::executePositional() {
  auto tbl = input.getTable(0);
  storage::pos_list_t* pos_list = new pos_list_t();


  size_t row = _ofDelta ? checked_pointer_cast<const storage::Store>(tbl)->deltaOffset() : 0;
  for (size_t input_size = tbl->size(); row < input_size; ++row) {
    if ((*_comparator)(row)) {
      pos_list->push_back(row);
    }
  }
  addResult(storage::PointerCalculator::create(tbl, pos_list));
}
Example #27
0
void GetLastRecords::executePlanOperation() {
  const auto& table = input.getTable(0);
  size_t end = table->size();
  storage::atable_ptr_t result;
  // if table has less rows than _recors, return table
  if (end <= _records)
    result = std::const_pointer_cast<storage::AbstractTable>(table);
  else {
    size_t start = end - _records;
    result = storage::TableRangeView::create(std::const_pointer_cast<storage::AbstractTable>(table), start, end);
  }
  addResult(result);
}
Example #28
0
void TestCameraFile::testImageLoading()
{
	std::unique_ptr<CameraDriver> camera;
	
	camera.reset(CameraDriver::factory("file", ""));
	addResult("loading invalid file", (bool) camera && ! camera->isValid());

	std::string filename = "image.tmp";
	// create if doesnt exists
	std::fstream fs(filename, std::ios::out | std::ios::trunc);
	fs << std::flush;
	fs.close();

	camera.reset(CameraDriver::factory("file", filename));
	if ( ! camera)
	{
		return;
	}

	addResult("loading valid file", camera->isValid());
	addResult("getting temporary filename", camera->getImagePath() == filename);
}
Example #29
0
      void
      handleConfigParam(std::auto_ptr<NMEAReader>& stn)
      {
        std::string arg;
        *stn >> arg;

        if (arg == "SRC")
        {
          unsigned src;
          *stn >> src;
          if (src == m_addr)
            addResult(RS_SRC_ACKD);
        }
Example #30
0
void DatabaseQuery::runQuery() {
    DatabaseQueryRequest *request = takeRequest();
    if (request) {
        QThread *thread = new QThread();
        connect(thread, SIGNAL(finished()), SLOT(threadFinished()));
        thread->start();
        request->moveToThread(thread);
        connect( request, SIGNAL(requestCompleted()), SLOT(finishQuery()) );
        connect( request, SIGNAL(resultsReady(DataStore)), SLOT(addResult(DataStore)) );
        connect( request, SIGNAL(errorMessageBox(QString,QString)), SIGNAL(errorMessageBox(QString,QString)) );
        QMetaObject::invokeMethod(request, "start", Qt::QueuedConnection);
    }
}