Пример #1
0
  bool CoordDataFile::Get(const std::set<OSMId>& ids, ResultMap& resultMap) const
  {
    assert(isOpen);

    resultMap.clear();
    resultMap.reserve(ids.size());

    try {
      for (const auto& id : ids) {
        PageId relatedId=id+std::numeric_limits<OSMId>::min();
        PageId pageId=relatedId/pageSize;

        PageIdFileOffsetMap::const_iterator pageOffset=pageFileOffsetMap.find(pageId);

        if (pageOffset==pageFileOffsetMap.end()) {
          continue;
        }

        FileOffset offset=pageOffset->second+(relatedId%pageSize)*(coordByteSize+1);

        scanner.SetPos(offset);

        uint8_t  serial;
        bool     isSet;
        GeoCoord coord;

        scanner.Read(serial);
        scanner.ReadConditionalCoord(coord,
                                     isSet);

        if (!isSet) {
          continue;
        }

        resultMap.insert(std::make_pair(id,
                                        Coord(serial,
                                              coord)));
      }
    }
    catch (IOException& e) {
      log.Error() << e.GetDescription();
      return false;
    }

    return true;
  }
Пример #2
0
void
QueryGeometry::releaseGLObjects( osg::State* state )
{
    if (!state)
        // delete all query IDs for all contexts.
        reset();

    else
    {
        // Delete all query IDs for the specified context.
        unsigned int contextID = state->getContextID();
        ResultMap::iterator it = _results.begin();
        while (it != _results.end())
        {
            TestResult& tr = it->second;
            if (tr._contextID == contextID)
            {
                QueryGeometry::deleteQueryObject( contextID, tr._id );
                tr._init = false;
            }
            it++;
        }
    }
}
Пример #3
0
    void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){
        Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to();


        if(detail){
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);

                const std::string& path = (res_map.getFileFromIdx(i)->get_path());
                const std::string& comment = res_map.getCommentAt(i);

                if(!res_map.getIsNAAt(i)){
                    for (unsigned int j=0; j<res_ref.size();++j){
                        std::stringstream ss;
                        const OneObjectRow& oor = res_ref.getRow(j);
                        ss <<"\""<<path<<"\", "<< oor.print()<<", \""<<comment<<"\""<<std::endl;
                        fout->write(ss.str());
                    }
                }
            }
        }
        else{
            for (auto i : idxs){
                const Result& res_ref = res_map.getResultAt(i);
                Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i);
                const std::vector<int> roi_keys = res_ref.getROIs();
                const std::string& comment = res_map.getCommentAt(i);

                std::map < unsigned int,std::pair<unsigned int,unsigned int> > table;
                table[0].first = res_ref.getNValid();
                table[0].second =  res_ref.size() - res_ref.getNValid();
                for(unsigned int i=0; i != (unsigned int)res_ref.size(); ++i){
                    OneObjectRow object = res_ref.getRow(i);
                    int roi = object.getROI();
                    if (roi > 0){
                        if(object.getGUIValid() && object.isValid()) //otherwise colour filters etc. don't work
                            ++(table[roi].first);
                        else
                            ++(table[roi].second);
                    }
                }


                for (auto &it : table){
                    int roi = it.first;
                    if ((table.size() == 1) || (roi >= 1)){

                        std::stringstream ss;
                        ss  <<i<<","
                            <<"\""<<tmp_file->get_basename()<<"\""<<","
                            <<roi<<",";

                        if(!res_map.getIsNAAt(i)){
                            ss<<it.second.first<<","
                            <<it.second.second<<",";
                        }
                        else{
                            ss<<"NA,NA,";
                        }
                            ss<<res_ref.getROIClusterData(roi).clusterPop(1)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(2)<<","
                            <<res_ref.getROIClusterData(roi).clusterPop(3)<<","
                            <<"\""<<comment<<"\""<<","
                            <<"\""<<tmp_file->get_path()<<"\","
                            <<"\""<<res_ref.getROIClusterData(roi).str()<<"\""<<std::endl;

                        fout->write(ss.str());
                    }
                }
            }
        }
        fout->flush ();
        fout->close();

    }
Пример #4
0
  virtual void process_iq(service::sptr sp,
                          const_iterator i0,
                          const_iterator i1) {
    const size_t length(std::distance(i0, i1));
    if (length != fftw_.size()) fftw_.resize(length);
    LOG_INFO_T(sp->approx_ptime(), str(boost::format("FFTProcessor::procIQ %s") % sp->id()));
    if (windowFcnName_ == "Rectangular")
      fftw_.transformRange(i0, i1, FFT::WindowFunction::Rectangular<complex_type::value_type>(length));
    else if (windowFcnName_ == "Hanning")
      fftw_.transformRange(i0, i1, FFT::WindowFunction::Hanning<complex_type::value_type>(length));
    else if (windowFcnName_ == "Hamming")
      fftw_.transformRange(i0, i1, FFT::WindowFunction::Hamming<complex_type::value_type>(length));
    else if (windowFcnName_ == "Blackman")
      fftw_.transformRange(i0, i1, FFT::WindowFunction::Blackman<complex_type::value_type>(length));
    else
      throw std::runtime_error(THROW_SITE_INFO(windowFcnName_ + ": unknown window function"));

    const FFTSpectrum<fft_type> s(fftw_, sp->sample_rate_Hz(), sp->center_frequency_Hz());

    // operate on Spectrum
    ResultMap resultMap;
    // set default calibration from the last epoch
    // it will be overwritten with the new calibration
    if (calibrationHandle_) {
      calibrationHandle_->updateTime(sp->approx_ptime());
      resultMap[calibrationKey_] = calibrationHandle_;
    } else {
      resultMap[calibrationKey_] = Result::Calibration::makeDefault(sp->approx_ptime(), calibrationKey_);
    }

    for (auto const& level : actions_) {
      for (auto const& action : level.second) {
        FFTProxy proxy(sp, level.first, resultMap);
        // LOG_INFO(str(boost::format("%s %s") % level.first % action.first));
        action.second->perform(proxy, s);
      }
    }

    ++epochCounter_;

    // collect results
    for (auto const& result : resultMap) {
      sp->put_result(result.second);
      auto const i(resultBuffer_.find(result.first));
      if (i != resultBuffer_.end())
        i->second->push_back(result.second);
      else
        resultBuffer_[result.first] = result.second;
    }

    // output results
    if (epochCounter_ == numCollectedEpochs_) {
      epochCounter_ = 0;
      for (auto const& result : resultBuffer_) {
        dump(result);
        result.second->clear();
      }
      resultBuffer_.clear();
    }

    // check if calibration has succeded
    // store (a copy of) the cal handle with "worst-case" covariance for use in the next epoch
    auto const i(resultMap.find(calibrationKey_));
    if (i != resultMap.end()) {
      auto const ch(boost::dynamic_pointer_cast<Result::Calibration>(i->second));
      if (ch)
        calibrationHandle_= ch->withWorstCaseCov(calibrationKey_);
      else
        LOG_WARNING_T(sp->approx_ptime(),
                      str(boost::format("resultMap[%s] is not of type Result::Calibration::Handle")
                          % calibrationKey_));
    }
  }
Пример #5
0
void DOMPatchSupport::dumpMap(const ResultMap& map, const String& name)
{
    fprintf(stderr, "\n\n");
    for (size_t i = 0; i < map.size(); ++i)
        fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map[i].second);
}
Пример #6
0
void Gui_ResultFileWriter::writeRows(const bool detail,const ResultMap& res_map,const std::vector<int>& idxs){
    Glib::RefPtr< Gio::FileOutputStream > fout = m_out_file->append_to();

    if(detail){
        for (auto i : idxs){
            const Result& res_ref = res_map.getResultAt(i);

            const std::string& path = (res_map.getFileFromIdx(i)->get_path());
            const std::string& comment = res_map.getCommentAt(i);

            if(!res_map.getIsNAAt(i)){
                for (unsigned int j=0; j<res_ref.size();++j){
                    std::stringstream ss;
                    const OneObjectRow& oor = res_ref.getRow(j);
                    cv::Scalar col = oor.getBGRMean();

                    cv::Point2f center = (oor.getPoint(0) + oor.getPoint(2) ) * 0.5;
                    ss  <<"\""<<path<<"\""<<","
                        <<oor.isValid()<<","
                        <<center.x<<","
                        <<center.y<<","
                        <<oor.getROI()<<","
                        <<(int)oor.getArea()<<","
                        <<oor.getRadius()<<","
                        <<col[2]<<","
                        <<col[1]<<","
                        <<col[0]<<","
                        <<oor.getHue()<<","
                        <<oor.getSat()<<","
                        <<oor.getNInClust()<<","
                        <<"\""<<comment<<"\""<<std::endl;
                    fout->write(ss.str());
                }
            }
        }
    }
    else{
        for (auto i : idxs){
            const Result& res_ref = res_map.getResultAt(i);
            Glib::RefPtr<Gio::File> tmp_file = res_map.getFileFromIdx(i);

            const std::string& comment = res_map.getCommentAt(i);

            std::stringstream ss;
            ss  <<i<<","
                <<"\""<<tmp_file->get_basename()<<"\""<<",";
            if(!res_map.getIsNAAt(i)){
                ss<<res_ref.getNValid()<<","
                <<res_ref.size() - res_ref.getNValid()<<",";
            }
            else{
                ss<<"NA,NA,";
            }
                ss<<comment<<","
                <<"\""<<tmp_file->get_path()<<"\""<<std::endl;

            fout->write(ss.str());
        }
    }
    fout->flush ();
    fout->close();

}
Пример #7
0
void MemoryTracker::ReportAllLeaks(std::ostream& out, bool aggregate)
{
   if (aggregate)
   {
      typedef std::map<TrackedCallstack::ptr, vector<TrackedAllocation>> ResultMap;
      ResultMap resultMap;

      int aggregateLevel = global::optionsManager.options.memoryLeakSettings.aggregateCallstackGroupLevel;

      map<vector<string>, vector<TrackedAllocation>> trackedAllocationsByLevel;

      for (TrackedAllocation a: trackedAllocations)
      {
         TrackedAllocation copy = a;
         copy.callStack = TrackedCallstack::ptr();
         if (aggregateLevel <= 0)
         {
            resultMap[a.callStack].push_back(copy);
         }
         else
         {
            vector<string> smallCallstack = getCallstackLevel(aggregateLevel, a);
            trackedAllocationsByLevel[smallCallstack].push_back(a);
         }
      }

      if (aggregateLevel <= 0)
      {
         out << resultMap.size() << " unique allocation callstacks" << std::endl;

         for (ResultMap::value_type m: resultMap)
         {
            TrackedCallstack::ptr c = m.first;
            if (!c->ignoredByFilters)
            {
               vector<TrackedAllocation>& allocs = m.second;
               UINT sum = 0;

               for (TrackedAllocation a: allocs)
               {
                  sum += a.bytes;
               }

               out << sum << " bytes, callstack: " << std::endl;
               for (std::string s: c->callstackVerbose)
               {
                  out << "\t" << s << std::endl;
               }
            }
         }
      }
      else // aggregateLevel > 0
      {
         vector<vector<string>> outValues;
         map<vector<string>, UINT> totalBytes;

         for (auto& x : trackedAllocationsByLevel)
         {
            outValues.push_back(x.first);
            UINT sum = 0;
            for (TrackedAllocation& a: x.second)
               sum += a.bytes;
            totalBytes[x.first] = sum;
         }
         
         std::sort(outValues.begin(), outValues.end(), [&](vector<string> a, vector<string> b){
            return totalBytes[a] > totalBytes[b];
         });

         for (auto vec : outValues)
         {
            out << totalBytes[vec] << " bytes, callstack: " << std::endl;
            for (std::string s : (*trackedAllocationsByLevel[vec].begin()).callStack->callstackVerbose)
               out << "\t" << s << std::endl;
         }

      }
   }
   else
   {
      for (auto& a: trackedAllocations)
      {
         out << std::hex << ((DWORD)a.mem) << ", " << std::dec << a.bytes << " bytes" << std::endl;
         for (std::string s: a.callStack->callstackVerbose)
         {
            out << "\t" << s << std::endl;
         }
      }
   }
}