Exemple #1
0
NodeRecorder* createNodeRecorder(VTDNav *vn){
	exception e;
	NodeRecorder *nr;
	if (vn==NULL){
		throwException2(invalid_argument,
			"NodeRecorder allocation failed ");
		return NULL;
	}
	nr = (NodeRecorder*) malloc(sizeof(NodeRecorder));
	if (nr==NULL) {
		throwException2(out_of_mem,
			"NodeRecorder allocation failed ");
		return NULL;
	}
	nr->vn = vn;
	Try{
		nr->fib = createFastIntBuffer2(BUF_SZ_EXPO);
	}Catch(e){
		free(nr);
		throwException2(out_of_mem,
			"NodeRecorder allocation failed ");
		return NULL;
	}

	nr->count = nr->size = nr->position = 0;
	return nr;
}
Exemple #2
0
int	evalNodeSet_ce (cachedExpr *ce,VTDNav *vn){
			int i=-1;
		if (ce->cached){
			if (ce->count<ce->ens->size){
				i=intAt(ce->ens,ce->count);
				recoverNode(vn,i);
				ce->count++;
				return i;
			}else
				return -1;

		}else{
			ce->cached = TRUE;
			
			if (ce->ens==NULL){
				ce->ens = createFastIntBuffer2(8);//page size 64
			}
			//record node set
			while((i=ce->e->evalNodeSet(ce->e,vn))!=-1){
				appendInt(ce->ens,i);
			}
			ce->e->reset(ce->e,vn);
			if(ce->ens->size>0){
				i=intAt(ce->ens,ce->count);//count should be zero
				recoverNode(vn,i);
				vn->count++;
				return i;
			}else
				return -1;
		}
	
}
Exemple #3
0
static Boolean compNodeSetNodeSet(binaryExpr *be, expr* left, expr* right, VTDNav *vn, opType op){
	exception e;
	int i,i1,k,s1,stackSize;
	Try {
		if (be->fib1 == NULL)
			be->fib1 = createFastIntBuffer2(BUF_SZ_EXP);

	          push2(vn);
	          stackSize = vn->contextBuf2->size;
	          while ((i = be->left->evalNodeSet(be->left,vn)) != -1) {
	              i1 = getStringVal(vn,i);
	              if (i1 != -1)
	              appendInt(be->fib1,i1);
	          }
			  be->left->reset(be->left,vn);
	          vn->contextBuf2->size = stackSize;
	          pop2(vn);
	          push2(vn);
	          stackSize = vn->contextBuf2->size;
	          while ((i = be->right->evalNodeSet(be->right,vn)) != -1) {
	              i1 = getStringVal(vn,i);
	              if (i1 != -1){
	                  s1 = be->fib1->size;
	                  for (k = 0; k < s1; k++) {
		                  Boolean b = compareVV(be,intAt(be->fib1,k),vn,i1,op);
		                  if (b){
		                      clearFastIntBuffer(be->fib1);
		                      vn->contextBuf2->size = stackSize;
		        	          pop2(vn);
		        	          be->right->reset(be->right,vn);
		                      return TRUE;
		                  }
		              }
	              }
	          }
	          vn->contextBuf2->size = stackSize;
	          pop2(vn);
	          be->right->reset(be->right,vn);
	          clearFastIntBuffer(be->fib1);
	          return FALSE;

	} Catch (e) {
		if (e.et == out_of_mem){
			Throw e;
		}
		if(be->fib1!=NULL)
			clearFastIntBuffer(be->fib1);

		e.et = other_exception;
		e.msg = "undefined run time behavior in computerEQNE";
		Throw e;
	}
	return FALSE;
}