Esempio n. 1
0
void G::Interval::getY(float x, std::vector<float>* y)const
{
   if ( (x > getFirst().x && x < getSecond().x)
      || (x < getFirst().x && x > getSecond().x) )
   {
      y->push_back(m_center.y + (x-m_center.x)*m_vector.y/m_vector.x);
   }
}
Esempio n. 2
0
void Implements::resolve(bool importImplements)
{
    Interface* interface = dynamic_cast<Interface*>(getFirst()->search(getParent()));
    Interface* mixin = dynamic_cast<Interface*>(getSecond()->search(getParent()));
    getFirst()->check(interface, "could not resolve '%s'.", getFirst()->getName().c_str());
    getSecond()->check(mixin, "could not resolve '%s'.", getSecond()->getName().c_str());
    interface->implements(mixin, importImplements);
}
Esempio n. 3
0
void G::Interval::getX(float y, std::vector<float>* x)const
{
   if ( (y > getFirst().y && y < getSecond().y)
      || (y < getFirst().y && y > getSecond().x) )
   {
      x->push_back(m_center.x + (y-m_center.y)*
                                    m_vector.x/m_vector.y);
   }
}
void InputMatrix::calculate(IrredundantMatrix &irredundantMatrix)
{
    auto maxThreads = std::thread::hardware_concurrency();;

    DEBUG_INFO("MaxThreads: " << maxThreads);

    std::vector<std::thread> threads(maxThreads);

    MasterWorkerPlan planBuilder(_r2Counts.data(), _r2Counts.size());
    
    for(auto threadId = 0; threadId < maxThreads; ++threadId) {
        START_COLLECT_TIME(threading, Counters::Threading);
        threads[threadId] = std::thread([this, threadId, &irredundantMatrix, &planBuilder]()
        {
            TimeCollector::ThreadInitialize();
            
            #ifdef DIFFERENT_MATRICES
            IrredundantMatrix matrixForThread(_qColsCount);
            auto currentMatrix = &matrixForThread;
            #else
            auto currentMatrix = &irredundantMatrix;
            #endif

            DEBUG_INFO("Thread " << threadId << " started");
            
            for(;;) {
                auto task = planBuilder.getTask();
                if (task->isEmpty()) {
                    DEBUG_INFO("Thread " << threadId << " stopped");
                    break;
                }

                DEBUG_INFO("Thread " << threadId << " is working on " << task->getFirst() << ":" << task->getSecond());

                #ifdef DIFFERENT_MATRICES
                matrixForThread.clear();
                #endif
 
                processBlock(*currentMatrix,
                             _r2Indexes[task->getFirst()], _r2Counts[task->getFirst()],
                             _r2Indexes[task->getSecond()], _r2Counts[task->getSecond()]);

                #ifdef DIFFERENT_MATRICES
                irredundantMatrix.addMatrixConcurrent(std::move(matrixForThread));
                #endif
            }

            TimeCollector::ThreadFinalize();
        });
        STOP_COLLECT_TIME(threading);
    }
    
    for(auto threadId = 0; threadId < maxThreads; ++threadId) {
        threads[threadId].join();
    }
}
bool BlockStreamPerformanceMonitorTop::close(){
	pthread_cancel(report_tid_);
	double eclipsed_seconds=getSecond(start_);
	double processed_data_in_bytes=tuplecount_*state_.schema_->getTupleMaxSize();

	logging_->log("Total time: %5.5f seconds\n",getSecond(start_));
	logging_->log("Total tuples: %d\n",tuplecount_);
	logging_->log("Avg throughput: %5.3f M data/s, %5.3f M tuples/s\n",processed_data_in_bytes/eclipsed_seconds/1024/1024,(float)tuplecount_/2014/1024/eclipsed_seconds);
	block_->~BlockStreamBase();
	state_.child_->close();
	return true;

}
Esempio n. 6
0
 void NDateTime::addSeconds(const nint seconds)
 {
     nint _seconds = seconds;
     while (getSecond() * _seconds > 59)
     {
         _seconds -= 60;
         addMinutes(1);
     }
     while (getSecond() + _seconds < 0)
     {
         _seconds += 60;
         addMinutes(-1);
     }
     m_Time.addSeconds(_seconds);
 }
QList<unsigned int> UpdateLinkDialog::links()
{
    QList<unsigned int> the_links;
    the_links.insert(0, getFirst());
    the_links.insert(1, getSecond());
    return the_links;
}
Esempio n. 8
0
static void query_select_sort() {
	/*
	 * select sum(a+1)+count(a),b
	 * from T
	 * group by b
	 *
	 * notation: p a p s
	 * */
	unsigned long long int start=curtick();
	TableDescriptor* table=Environment::getInstance()->getCatalog()->getTable("LINEITEM");
	//===========================scan===========================
	LogicalOperator* scan=new LogicalScan(table->getProjectoin(0));

	//==========================project=========================
	vector< vector<ExpressionItem> >expr_list1;

	vector<ExpressionItem> expr1;
	ExpressionItem ei1_1;
	ExpressionItem ei1_2;
	ExpressionItem ei1_3;
	ei1_1.setVariable("LINEITEM.L_ORDERKEY");
	ei1_2.setIntValue("1");
	ei1_3.setOperator("+");

	expr1.push_back(ei1_1);
	expr1.push_back(ei1_2);
	expr1.push_back(ei1_3);

	expr_list1.push_back(expr1);

	LogicalOperator* project1=new LogicalProject(scan,expr_list1);

	//==========================project=========================
	vector< vector<ExpressionItem> >expr_list2;

	ExpressionItem ei21_1;
	ei21_1.setVariable("LINEITEM.L_ORDERKEY+1");
	vector<ExpressionItem> expr21;
	expr21.push_back(ei21_1);
	expr_list2.push_back(expr21);
	LogicalOperator* project2=new LogicalProject(project1,expr_list2);

	//============================sort==========================
	vector<LogicalSort::OrderByAttr*> vo;

	LogicalSort::OrderByAttr tmp=LogicalSort::OrderByAttr("LINEITEM.L_ORDERKEY+1",0);
	vo.push_back(&tmp);
	LogicalOperator* sort=new LogicalSort(project1,vo);

	//===========================root===========================
	LogicalOperator* root=new LogicalQueryPlanRoot(0,sort,LogicalQueryPlanRoot::PRINT);

	cout<<"performance is ok!"<<endl;
	BlockStreamIteratorBase* physical_iterator_tree=root->getIteratorTree(64*1024);
//	physical_iterator_tree->print();
	physical_iterator_tree->open();
	while(physical_iterator_tree->next(0));
	physical_iterator_tree->close();
	printf("Q1: execution time: %4.4f second.\n",getSecond(start));
}
Esempio n. 9
0
/*!
 * \brief  UTCからローカル時間に変換
 */
void DateTime::toLocal()
{
#if defined(_WINDOWS)
    TIME_ZONE_INFORMATION timeZone;
    GetTimeZoneInformation(&timeZone);

    int32_t bias = -timeZone.Bias / 60;
#else
    struct timezone tz;
    gettimeofday(nullptr, &tz);

    int32_t bias = -tz.tz_minuteswest / 60;
#endif

    struct tm tm;
    tm.tm_year = getYear() - 1900;
    tm.tm_mon =  getMonth() - 1;
    tm.tm_mday = getDay();
    tm.tm_hour = getHour() + bias;
    tm.tm_min =  getMinute();
    tm.tm_sec =  getSecond();
    tm.tm_yday =
    tm.tm_wday =
    tm.tm_isdst = 0;

#if defined(_WINDOWS)
    time_t time = mktime(&tm);
#else
    time_t time = mktime(&tm);
//  time_t time = timegm(&tm);
#endif
    struct tm* tmLocal = localtime(&time);

    toValue(tmLocal, getMilliSecond());
}
Esempio n. 10
0
const DebugMapObject::DebugMapEntry *
DebugMapObject::lookupObjectAddress(uint64_t Address) const {
  auto Mapping = AddressToMapping.find(Address);
  if (Mapping == AddressToMapping.end())
    return nullptr;
  return Mapping->getSecond();
}
Esempio n. 11
0
bool G::Interval::belongRectangleArea(const G::Point2f& pt)const
{
   G::Point2f first = getFirst();
   G::Point2f second = getSecond();
   G::Point2f low;
   G::Point2f up;
   M::maxMin(first.x, second.x, &(up.x), &(low.x));
   M::maxMin(first.y, second.y, &(up.y), &(low.y));
   /*
   std::cout << "up_x: "    << up.x
             << "; low.x: " << low.x
             << "; up_y: "  << up.y
             << "; low_y: " << low.y
             << std::endl;
   std::cout << first.x  << " " << first.y  << std::endl;
   std::cout << second.x  << " " << second.y  << std::endl;
   std::cout << pt.x  << " " << pt.y  << std::endl;
   */
   if (  (pt.x < up.x  || M::equal(pt.x, up.x))
      && (pt.y < up.y  || M::equal(pt.y, up.y))
      && (pt.x > low.x || M::equal(pt.x, low.x))
      && (pt.y > low.y || M::equal(pt.y, low.y)) )
   {
      //std::cout << "true\n";
      return true;
   }
   //std::cout << "false\n";
   return false;
}
Esempio n. 12
0
void Date::setDay(
		  int aDay
		  )
  throw( DateException )
{
  settm( aDay, getMonth(), getYear(), getSecond() );
} /* end Date::setDay() */
Esempio n. 13
0
void
AGTime::setSecond(int s) {
    if (0 <= s && s < 60) {
        sec -= getSecond();
        sec += s;
    }
}
Esempio n. 14
0
void Date::setYear(
		   int aYear
		   )
  throw( DateException )
{
  settm( getDay(), getMonth(), aYear, getSecond() );
} /* end Date::setYear() */
bool PerformanceIteratorTop::close(){
	printf("Total time: %5.5f seconds\n",getSecond(start));
	pthread_cancel(report_tid);
	free(tuple);
	state.child->close();
	return true;
}
Esempio n. 16
0
float G::Interval::getDistance(const G::Point2f& pt, G::Point2f* close_pt)const
{
   G::Line_2d interline(*this);
   G::Point2f line_close_pt;
   float lineDist = interline.getDistance(pt, &line_close_pt);
   if ( !belongRectangleArea(line_close_pt) )
   {
      G::Point2f first = getFirst();
      G::Point2f second = getSecond();
      float first_dist = G::distance(pt, first);
      float second_dist = G::distance(pt, second);
      if (first_dist < second_dist)
      {
         lineDist = first_dist;
         *close_pt = first;
      }
      else
      {
         lineDist = second_dist;
         *close_pt = second;
      }
   }
   else
   {
      *close_pt = line_close_pt;
   }
   return lineDist;
}
Esempio n. 17
0
    void run()
    {
        std::string msg;
        ServiceMessage sm;
        do
        {
            doLog("receive thread reading line");
            msg = s_.readLine();
            if (msg == "")
                break;
            // new added
            // if is a file msg, do something
            if (msg == "\n")
            {
                msg = s_.readLine(); // ???
                std::string filepath = sm.GetAttribute("filename");
                // save to file
                FileSystem::File f(filepath);
                f.open(FileSystem::File::out);
                f.putLine(msg);
                q_.enQ(sm);
                isFile = true; // static ???
            }
            else
            {
                std::string name = getFirst(msg);
                std::string value = getSecond(msg);
                sm.AddAttrbutes(name, value);
            }
            //q_.enQ(msg);


        } while(msg != "quit");
    }
static void test_scan_filter_performance(int value)
{
	unsigned long long int start=curtick();
	TableDescriptor* table=Catalog::getInstance()->getTable("cj");
	LogicalOperator* cj_scan=new LogicalScan(table->getProjectoin(0));

	Filter::Condition filter_condition_1;
	filter_condition_1.add(table->getAttribute(3),AttributeComparator::GEQ,std::string("10107"));
	filter_condition_1.add(table->getAttribute(3),AttributeComparator::L,(void*)&value);
	LogicalOperator* filter_1=new Filter(filter_condition_1,cj_scan);

	const NodeID collector_node_id=0;
	LogicalOperator* root=new LogicalQueryPlanRoot(collector_node_id,filter_1,LogicalQueryPlanRoot::PERFORMANCE);

	BlockStreamPerformanceMonitorTop* executable_query_plan=(BlockStreamPerformanceMonitorTop*)root->getIteratorTree(1024*64);
//	executable_query_plan->print();
	executable_query_plan->open();
	while(executable_query_plan->next(0));
	executable_query_plan->close();

//	ResultSet *result_set=executable_query_plan->getResultSet();

	const unsigned long int number_of_tuples=executable_query_plan->getNumberOfTuples();
	printf("execution time: %4.4f seconds.\n",getSecond(start));
	if(!print_test_name_result(number_of_tuples==26820,"Low selectivity filter")){
		printf("\tExpected:26695 actual: %d\n",number_of_tuples);
	}
//	result_set->~ResultSet();
	executable_query_plan->~BlockStreamIteratorBase();
	root->~LogicalOperator();
}
Esempio n. 19
0
void* ResultCollector::CollectResult(void* arg) {
  ResultCollector* Pthis = (ResultCollector*)arg;
  Pthis->state_.child_->Open(Pthis->state_.partition_offset_);
  BlockStreamBase* block_for_asking;
  if (false == Pthis->CreateBlockStream(block_for_asking)) {
    assert(false);
    return 0;
  }
  Pthis->block_buffer_->column_header_list_ = Pthis->state_.column_header_;

  unsigned long long start = 0;
  start = curtick();

  while (Pthis->state_.child_->Next(block_for_asking)) {
    Pthis->block_buffer_->atomicAppendNewBlock(block_for_asking);
    if (false == Pthis->CreateBlockStream(block_for_asking)) {
      assert(false);
      return 0;
    }
  }
  Pthis->sema_input_complete_.post();
  double eclipsed_seconds = getSecond(start);
  Pthis->block_buffer_->query_time_ = eclipsed_seconds;
  Pthis->block_buffer_->schema_ = Pthis->state_.input_->duplicateSchema();
  Pthis->finished_thread_count_++;

  return 0;
}
Esempio n. 20
0
void Listener::brokerDisconnected(const Broker& broker){
	STDCOUT1("brokerDisconnected: " << broker << endl);

	STDCOUT2("broker disconnection event at " << getSecond() << endl);
	ListenerEvent *le = new BrokerDisconnectionEvent(broker.getUrl());
	int ret = ListenerEvent::sendEventPtr(this->eventfd, le);
	STDCOUT2("passing event: return " << ret << endl);
}
int mainasdfaf234(int argc,const char** argv){

	std::vector<column_type> column_list,column_list_;
	column_list.push_back(column_type(t_int));

	Schema* input=new SchemaFix(column_list);

	BlockStreamSingleColumnScan::State bsscs_state("/home/claims/temp/Uniform_0_99.column",input);
	PhysicalOperatorBase* bsscs1=new BlockStreamSingleColumnScan(bsscs_state);
	PhysicalOperatorBase* bsscs2=new BlockStreamSingleColumnScan(bsscs_state);

	int f=atoi(argv[2]);



	AttributeComparator fA(column_type(t_int),Comparator::L,0,&f);
	std::vector<AttributeComparator> ComparatorList;
	ComparatorList.push_back(fA);
	BlockStreamFilter::State bsf_state(input,bsscs1,ComparatorList,4096);
	PhysicalOperatorBase* bsf=new BlockStreamFilter(bsf_state);

//
	BlockStreamBase *block=new BlockStreamFix(4096,4);
	int choice=0;

	while(choice==0){


//		bsf->open();
		bsf->Open();
		unsigned long long int start=curtick();

		while(bsf->Next(block)){
			block->setEmpty();
		}
		printf("Time=%f Throughput=%f.\n",getSecond(start),1024/getSecond(start));
		bsf->Close();
		printf("Continue(0) or Not(1) ?\n");

		scanf("%d",&choice);

	}

}
void* PerformanceIteratorTop::report(void* arg){
	PerformanceIteratorTop* Pthis=(PerformanceIteratorTop*)arg;
	while(true){
		usleep(Pthis->state.report_cycles*1000);

		double eclipsed_seconds=getSecond(Pthis->start);
		double processed_data_in_bytes=Pthis->tuplecount*Pthis->state.schema->getTupleMaxSize();
		printf("[Performace reporting:] %8.3f M/s.   %5.2f M tuples received.\n",processed_data_in_bytes/eclipsed_seconds/1024/1024,(float)Pthis->tuplecount/2014/1024);
	}
}
Esempio n. 23
0
void logTime(const char *str){
	static FILE *logf = NULL;

	if(logf == NULL){
		//logf = fopen("/home/estinet/exp_recovery.log", "a");
		logf = fopen("/dev/null", "a");
	}
	fprintf(logf, "%.6lf %s %s\n", getSecond(), logname, str);
	fflush(logf);
}
Esempio n. 24
0
void Listener::objectProps(Broker& broker, Object& object){
	STDCOUT1("objectProps: broker=" << broker << " object=" << object << endl);
	STDCOUT2("object property event at " << getSecond() << endl);
	ListenerEvent *le = new ObjectPropertyEvent(object);
	if(((ObjectPropertyEvent*)le)->objinfo == NULL){
		delete le;
		return;
	}
	int ret = ListenerEvent::sendEventPtr(this->eventfd, le);
	STDCOUT2("send event: return " << ret << endl);
}
Esempio n. 25
0
	int priority(const intTriple& givenTag,sorContext& graph) const
	{
		int row = getFirst(givenTag);
		int column = getSecond(givenTag);
		int iteration = getThird(givenTag);
        //calculate width of wavefronts of diagonals, so that there would only be 20 wavefronts
#if 0
		static int diagonalWidth = (nRowsOfTiles+nColumnsOfTiles+nIterations-3)/20+1;
		return  (((row+column+iteration)/diagonalWidth)%20);
#endif
		return row + column + iteration + iteration;
	}
Esempio n. 26
0
/*!
 * \brief  日付時間をミリ秒に変換
 */
int64_t DateTime::toMilliSeconds() const
{
    enum
    {
        January =                0,
        February =  January +   31,
        March =     February +  28,
        April =     March +     31,
        May =       April +     30,
        June =      May +       31,
        July =      June +      30,
        August =    July +      31,
        September = August +    31,
        October =   September + 30,
        November =  October +   31,
        December =  November +  30,
    };

    static const int64_t daySpan[] =
    {
        January,
        February,
        March,
        April,
        May,
        June,
        July,
        August,
        September,
        October,
        November,
        December,
    };

    int64_t y = getYear();
    int64_t m = getMonth();
    int64_t d = getDay();

    int64_t dy = (y - 1) * 365;                     // 年数分の日数
    int64_t dl = (y / 4) - (y / 100) + (y / 400);   // 閏年分の日数
    int64_t dm = daySpan[m - 1];                    // 1月1日からm月1日までの日数
    int64_t result = dy + dl + dm + d - 1;

    result =
        (result * 24 * 60 * 60 * 1000) +
        (getHour()   * 60 * 60 * 1000) +
        (getMinute()      * 60 * 1000) +
        (getSecond()           * 1000) +
         getMilliSecond();

    return result;
}
Esempio n. 27
0
void Date::adjustSeconds(
		   int aAmount
		   )
  throw( DateException )
{
  int addSeconds = getSecond() + aAmount;
  if( addSeconds > 86400 )
    {
      adjustDay( addSeconds / 86400 );
      addSeconds = addSeconds % 86400;
    }
  setSeconds( addSeconds );
} /* end Date::adjustSeconds() */
void* BlockStreamPerformanceMonitorTop::report(void* arg){
	BlockStreamPerformanceMonitorTop* Pthis=(BlockStreamPerformanceMonitorTop*)arg;

	while(true){
		const unsigned long last_tuple_count=Pthis->tuplecount_;
		usleep(Pthis->state_.report_cycles_*1000);

		double eclipsed_seconds=getSecond(Pthis->start_);
		double processed_data_in_bytes=Pthis->tuplecount_*Pthis->state_.schema_->getTupleMaxSize();
		double processed_data_in_bytes_during_last_cycle=(Pthis->tuplecount_-last_tuple_count)*Pthis->state_.schema_->getTupleMaxSize();
		Pthis->logging_->log("[%2.3f s] Real Time: %5.3f M/s\tAVG: %5.3f M/s.\t%5.2f M tuples received.\n",eclipsed_seconds,processed_data_in_bytes_during_last_cycle/(Pthis->state_.report_cycles_/1000)/1024/1024,processed_data_in_bytes/eclipsed_seconds/1024/1024,(float)Pthis->tuplecount_/1024/1024);
	}
}
Esempio n. 29
0
/**********************************************************************************************************************
*Description: Function for getting time (hours, minutes and seconds). This function fills a structure called local_time
			  accessible in the class RTCInt.	
*Input Parameters: None
*Return Parameter: None
***********************************************************************************************************************/
void RTCInt::getTime(void)
{
	unsigned int hour=0, h=0;
	
	local_time.hour = getHour();
	if(time_Mode == TIME_H12)
	{
		h=RTC->MODE2.CLOCK.bit.HOUR;
		while (RTCSync());
		local_time.Tmode = h & 0x10;
	}	
	local_time.minute = getMinute();
	local_time.second = getSecond();
}
        const string TimeStamp::getYYYYMMDD_HHMMSS() const {
            const uint32_t MONTH = getMonth();
            const uint32_t DAY = getDay();
            const uint32_t HOUR = getHour();
            const uint32_t MINUTE = getMinute();
            const uint32_t SECOND = getSecond();

            stringstream s;
            s << getYear() << "-" << ( (MONTH < 10) ? "0" : "" ) << MONTH << "-" << ( (DAY < 10) ? "0" : "" ) << DAY
                           << " " << ( (HOUR < 10) ? "0" : "" ) << HOUR
                           << ":" << ( (MINUTE < 10) ? "0" : "" ) << MINUTE
                           << ":" << ( (SECOND < 10) ? "0" : "" ) << SECOND;
            return s.str();
        }