NCerror mapconstraints3(DCEconstraint* constraint, CDFnode* root) { int i; NCerror ncstat = NC_NOERR; NClist* nodes = root->tree->nodes; NClist* dceprojections; NClist* dceselections; dceprojections = constraint->projections; dceselections = constraint->selections; /* Convert the projection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceprojections);i++) { DCEprojection* proj = (DCEprojection*)nclistget(dceprojections,i); if(proj->discrim != CES_VAR) continue; // ignore functions ncstat = matchpartialname3(nodes,proj->var->segments, (CDFnode**)&proj->var->annotation); if(ncstat) goto done; } #ifdef IGNORE Only care about projections /* Convert the selection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { DCEselection* sel = (DCEselection*)nclistget(dceselections,i); if(sel->lhs->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,sel->lhs->var->segments, (CDFnode**)&sel->lhs->var->annotation); if(ncstat) goto done; } /* Convert the selection path values to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { int j; DCEselection* sel = (DCEselection*)nclistget(dceselections,i); for(j=0;j<nclistlength(sel->rhs);j++) { DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,j); if(value->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,value->var->segments, (CDFnode**)&value->var->annotation); if(ncstat) goto done; } } #endif #ifdef DEBUG fprintf(stderr,"mapconstraint.projections: %s\n", dumpprojections(dceprojections)); fprintf(stderr,"mapconstraint.selections: %s\n", dumpselections(dceselections)); #endif done: return THROW(ncstat); }
NCerror mapconstraints3(NCDAPCOMMON* dapcomm) { int i; NCerror ncstat = NC_NOERR; CDFnode* root = dapcomm->cdf.ddsroot; NClist* nodes = root->tree->nodes; NClist* dceprojections; NClist* dceselections; dceprojections = dapcomm->oc.dapconstraint->projections; dceselections = dapcomm->oc.dapconstraint->selections; /* Convert the projection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceprojections);i++) { DCEprojection* proj = (DCEprojection*)nclistget(dceprojections,i); if(proj->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,proj->var->segments, &proj->var->cdfleaf); if(ncstat) goto done; } /* Convert the selection paths to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { DCEselection* sel = (DCEselection*)nclistget(dceselections,i); if(sel->lhs->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,sel->lhs->var->segments,&sel->lhs->var->cdfleaf); if(ncstat) goto done; } /* Convert the selection path values to leaves in the dds tree */ for(i=0;i<nclistlength(dceselections);i++) { int j; DCEselection* sel = (DCEselection*)nclistget(dceselections,i); for(j=0;j<nclistlength(sel->rhs);j++) { DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,j); if(value->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,value->var->segments,&value->var->cdfnode); if(ncstat) goto done; } } /* Fill in segment information */ ncstat = qualifyconstraints3(dapcomm->oc.dapconstraint); if(ncstat != NC_NOERR) goto done; #ifdef DEBUG fprintf(stderr,"mapconstraint.projections: %s\n", dumpprojections(dceprojections)); fprintf(stderr,"mapconstraint.selections: %s\n", dumpselections(dceselections)); #endif done: return THROW(ncstat); }
static NCerror fillsegmentpath(DCEprojection* p, NClist* nodes) { int i; NCerror ncstat = NC_NOERR; NClist* path = nclistnew(); ASSERT(p->discrim == CES_VAR); collectsegmentnames3(p->var->segments,path); ncstat = matchpartialname3(nodes,path,&p->var->cdfleaf); if(ncstat) goto done; /* Now complete the segment path */ nclistclear(path); collectnodepath3(p->var->cdfleaf,path,!WITHDATASET); if(nclistlength(path) != nclistlength(p->var->segments)) { ncstat = NC_EINVAL; goto done; } for(i=0;i<nclistlength(p->var->segments);i++) { DCEsegment* seg = (DCEsegment*)nclistget(p->var->segments,i); CDFnode* node = (CDFnode*)nclistget(path,i); seg->cdfnode = node; #ifdef DEBUG fprintf(stderr,"reref: %s -> %s\n",seg->name,node->name); #endif } done: nclistfree(path); return ncstat; }
static NCerror fillselectionpath(DCEselection* s, NClist* nodes) { int i; NCerror ncstat = NC_NOERR; NClist* path = nclistnew(); DCEvar* var; ASSERT(s->lhs->discrim == CES_VAR); var = s->lhs->var; ncstat = matchpartialname3(nodes,var->segments,&var->cdfleaf); if(ncstat) goto done; /* Now find the value paths */ for(i=0;i<nclistlength(s->rhs);i++) { DCEvalue* v = (DCEvalue*)nclistget(s->rhs,i); if(v->discrim != CES_VAR) continue; ncstat = matchpartialname3(nodes,v->var->segments,&v->var->cdfnode); if(ncstat) goto done; } done: nclistfree(path); return ncstat; }