Example #1
0
Tuple *Ast::CreateTuple(const location& loc, ExprContext ctx, AstNode *seq, AstNode *item)
{
    Tuple *tuple = NULL;
	if (seq)
	{
		tuple = dynamic_cast<Tuple*>(seq);
        
        if(!tuple)
        {
            tuple = CreateTuple(loc, ctx);
            tuple->items.push_back(seq);
        }
	}
	else
	{
		tuple = CreateTuple(loc, ctx);
	}

    if(item)
    {
        tuple->items.push_back(item);
    }

    return tuple;
}
Example #2
0
Tuple* Ast::CreateArgList(const location& loc, AstNode* args,
		AstNode* starredArg, AstNode* dblStarredArg)
{
	Tuple *seq = NULL;


	if (args) {
		seq = dynamic_cast<Tuple*>(args);
		assert(seq);
	} else {
		seq = CreateTuple(loc, NULL, NULL);
	}

	if (starredArg) {
		AstNode *sa = this->CreateStarred(starredArg->loc, starredArg);
		seq->items.push_back(sa);
	}

	if (dblStarredArg) {
		AstNode *dbls = this->CreateDblStarred(dblStarredArg->loc, dblStarredArg);
		seq->items.push_back(dbls);
	}

	return seq;
}
Example #3
0
HeapTuple ComputeNextTuple(HeapScanDesc scan) {
	DModel * m=&(models[0]);
	int i;
	double y=0;
	double o=0;
	int x;
	int len=0;
	int cnt=0;
	int length=m->len;

	// prepare the cache
	int   a=Prepare(scan);
       	if(a==2) {
		return NULL;
        }
	//if(a==1) return NULL;
	if (grp_fnc=='M') o=DBL_MAX;
	x=scan->index+1;
	for(;;){
		scan->index++;
		if(a==1) {
	//		elog(WARNING," item %d %d",scan->index-length,newpoints );
			//check to use the extra or the points
			if(extra==NULL)
			 y=points[scan->index-length-1];
			else {
			int yy=scan->index-length-1;
			if(yy>=extra->len)
			   y=points[yy-extra->len];
			else
			  y=EvalB(extra,yy);
			}	  	
			
			}
		else {
		if(m_layers==-1)
			y=GetValue(scan->index);
		else	
			y=GetValueL(scan->index);
		}
		if ((grp_fnc=='s')||(grp_fnc=='a')) { o=o+y; cnt++;}
		else if ((grp_fnc=='m') && (o<y)) o =y;
		else if ((grp_fnc=='M') && (o>y)) o=y;
		else if ((grp_fnc=='\0')||(grp_fnc=='n')) o=y;
		len++;
		if((len>=grp_len)&&(grp_len!=-1)) {
			if (grp_fnc=='a') o=o/cnt;
			break;	
		}
		if( m_fend==-1) {
			if ((scan->index>length)&&(grp_len==-1))  return NULL;
			if (scan->index>length) break;
		} 
	}

//	elog(WARNING,"x %d, o%f",x,o);
	if ((grp_len!=-1)||(grp_len!=0)) x=x/grp_len;
	return CreateTuple(scan->rs_rd,x, (int)o);

}
Example #4
0
Tuple* Ast::CreateTuple(const location& loc, AstNode* seq, AstNode* item)
{
	return CreateTuple(loc, UnknownCtx, seq, item);
}