//processes native helices if necessary; called by process_input //returns id for i,j,k helix int* process_native(int i, int j, int k) { int *id = NULL,l; char *key,tmp[ARRAYSIZE]; for (l=1; l < k; l++) { sprintf(tmp,"%d %d",i+l,j-l); id = hashtbl_get(bp,tmp); if (id) { for (l-- ; l >= 0; l--) { sprintf(tmp,"%d %d",i+l,j+l); hashtbl_insert(bp,tmp,id); } return id; } } //printf("helix %d %d %d doesn't exist in sfold sample\n",i,j,k); id = malloc(sizeof(int)); *id = hashtbl_numkeys(idhash)+1; hashtbl_insert(bp,tmp,id); sprintf(tmp,"%d",*id); key = malloc(sizeof(char)*ARRAYSIZE); sprintf(key,"%d %d %d",i,j,k); hashtbl_insert(idhash,tmp,key); return id; }
/* Store user defined numerical formats ie. FORMAT records */ void wbook_store_all_num_formats(struct wbookctx *wbook) { int index = 164; /* Start from 0xA4 */ struct htbl *num_formats; int key; int i; num_formats = hashtbl_new(1); /* User defined formats */ for (i = 0; i < wbook->formatcount; i++) { int data; if (wbook->formats[i]->num_format_str == NULL) continue; key = fmt_gethash(wbook->formats[i]); data = hashtbl_get(num_formats, key); if (data >= 0) { /* FONT has already been used */ wbook->formats[i]->num_format = data; } else { /* Add a new FONT record */ hashtbl_insert(num_formats, key, index); wbook->formats[i]->num_format = index; wbook_store_num_format(wbook, wbook->formats[i]->num_format_str, index); index++; } } hashtbl_destroy(num_formats); }
//finds helical difference between profile -> origprof //k1 and k2 are num of helices in profile and origprof //return difference with triplets char* find_diff(HASHTBL *hash,char *profile, char *origprof, int *k1, int *k2) { int size = INIT_SIZE,b1,b2,xor,i; char *diff,*id; diff = malloc(sizeof(char)*ARRAYSIZE*size); diff[0] = '\0'; b1 = make_binary(profile,k1); b2 = make_binary(origprof,k2); xor = b1 ^ b2; //printf("b1 is %d, b2 is %d, and xor is %d\n",b1,b2,xor); for (i = 0; xor > 0; xor>>=1,i++) { if ((xor & 1)==1) { hashtbl_insert(hash,table[i],"1"); id = hashtbl_get(idhash,table[i]); if (strlen(diff)+strlen(table[i])+strlen(id)+6 > ARRAYSIZE*size) diff = resize(&size,strlen(diff)+strlen(table[i])+strlen(id)+6,diff); if (strlen(diff)>1) strcat(diff,"\\n"); sprintf(diff,"%s%s: %s",diff,table[i],id); } } //printf("diff is %s between %s and %s\n",diff,origprof,profile); return diff; }
//inserts key into graph and converts from rep struct to binary notation long insert_and_binary(char *key,char *profile,int freq) { char *blank = " ",*helix,*copy = strdup(key); unsigned long sum = 0; int i,length = atoi(strtok(copy,blank)),*val; HASHTBL *hash = graph[length-1]; profile[0] = '\0'; for (i = 0; i < length; i++) { helix = strtok(NULL,blank); strcat(profile,helix); strcat(profile," "); sum += *((long*) hashtbl_get(binary,helix)); //printf("sum is now %d\n",sum); } //printf("profile is %s\n",profile); if (!hash) { if (!(hash = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } graph[length-1] = hash; } val = malloc(sizeof(int)); *val = freq; hashtbl_insert(hash,profile,val); //printf("profile %sinserted with length %d and freq %d\n",profile,length,*val); return sum; }
//inserts profile into graph, updates freq if already exists //saves LCA into linked list with num = binary rep //s = number of helices in profile struct hashnode_s* insert_LCA(char *profile,int num,int s,int frq) { int size,*val,*data; char *key; HASHTBL *hash = NULL; struct hashnode_s *temp = NULL; //KEY *node; hash = graph[s-1]; if (!hash) { if (!(hash = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } graph[s-1] = hash; } val = hashtbl_get(hash,profile); if (!val) { val = malloc(sizeof(int)); *val = frq; hashtbl_insert(hash,profile,val); //printf("inserted %s into graph\n",profile); //if LCA isn't an original, save; will have to compare them later //below assumes s is double digits or less for (size = 1; size < strlen(profile)+3; size++) ; key = malloc(sizeof(char)*ARRAYSIZE*size); sprintf(key,"%d %s",s,profile); if (!hashtbl_get(cluster,key)) { //printf("%s as new vertex with bit %d\n",profile,num);print_vertices(fp temp = malloc(sizeof(struct hashnode_s)); data = malloc(sizeof(int)); *data = num; temp->key = profile; temp->data = data; //for (;temp;temp = temp->next) //printf("node is %s with bit %d\n",temp->key,*((int*)temp->data)); } free(key); } else if (*val < frq) { //printf("profile %s inserted with freq %d, old freq %d\n",profile,frq,*val); *val = frq; } return temp; }
int main() { HASHTBL *hashtbl; char *spain, *italy; char str[] = "GfG"; printf("%p \n",str); printf("str= %s \n",str); change(str); if (!(hashtbl = hashtbl_create(16, NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed\n"); exit(EXIT_FAILURE); } hashtbl_insert(hashtbl, "France", "Paris"); hashtbl_insert(hashtbl, "England", "London"); hashtbl_insert(hashtbl, "Sweden", "Stockholm"); hashtbl_insert(hashtbl, "Germany", "Berlin"); hashtbl_insert(hashtbl, "Norway", "Oslo"); hashtbl_insert(hashtbl, "Italy", "Rome"); hashtbl_insert(hashtbl, "Spain", "Madrid"); hashtbl_insert(hashtbl, "Estonia", "Tallinn"); hashtbl_insert(hashtbl, "Netherlands", "Amsterdam"); hashtbl_insert(hashtbl, "Ireland", "Dublin"); printf("After insert:\n"); italy = hashtbl_get(hashtbl, "Italy"); printf("Italy: %s\n", italy ? italy : "-"); spain = hashtbl_get(hashtbl, "Spain"); printf("Spain: %s\n", spain ? spain : "-"); hashtbl_remove(hashtbl, "Spain"); printf("After remove:\n"); spain = hashtbl_get(hashtbl, "Spain"); printf("Spain: %s\n", spain ? spain : "-"); hashtbl_resize(hashtbl, 8); printf("After resize:\n"); italy = hashtbl_get(hashtbl, "Italy"); printf("Italy: %s\n", italy ? italy : "-"); hashtbl_destroy(hashtbl); return 0; }
//finds the LCA of powerset of set of profiles and insert if necessary //graph holds the final graph, table[freq ID] = ID, profileID[profileID] = profile //sums[profileID] = binary rep, k = number of profiles //returns beginning of linked list containing all unique LCA's found struct hashnode_s* insert_LCAs(FILE *fp,int k) { int count,frq,*val,bit,s=0,j,*found,size = INIT_SIZE; unsigned long num; unsigned int i; char *profile; struct hashnode_s *node = NULL,*temp = NULL; KEY *top; found = malloc(sizeof(int)*k); //for every subset of minimal elements... //checking i = 1,2 is redundant (only 1 element in bin rep), so skip //printf("k is %d\n",k); for (i = 3; i < (1<<k); i++) { count = 0; frq = 0; j = hashtbl_numkeys(binary); //printf("number of freq helices %d\n",j); num = (1<<j)-1; //printf("original num is %d with j %d\n",num,j); //...take their LCA... for (bit = 0, j = i; j > 0 && bit < k ; j >>= 1, bit++) if ((1 & j) == 1) { found[count++] = bit; //printf("found profile %s for bit %d\n",profileID[bit],bit); //sprintf(key,"%s",table[bit]); if (!(val = hashtbl_get(cluster,profileID[bit]))) fprintf(stderr, "No such %s in cluster with bit %d\n",profileID[bit],bit); frq += *val; num &= sums[bit]; //printf("num is %d after & with %d from bit %d: %s\n",num,sums[bit],bit,profileID[bit]); } //printf("binary profile is %d, k is %d,frq is %d, and binary helices is %d\n",i,k,frq,num); //...and insert if (num != 0) { profile = malloc(sizeof(char)*ARRAYSIZE*size); profile = convert_binary(profile,num,&s); find_edges(fp,profile,found,count); temp = insert_LCA(profile,num,s,frq); if (temp) { //printf("LCA profile %s and i %d\n",profile,i); temp->next = node; node = temp; } else free(profile); } } //add final connection from root to smallest element in graph for (i = 0; !graph[i]; i++) ; for (top = hashtbl_getkeys(graph[i]); top; top = top->next) check_insert_edge(fp,"",top->data); free(found); return node; }
int _oph_query_check_query_params(HASHTBL *hashtbl) { if (!hashtbl){ pmesg(LOG_ERROR, __FILE__, __LINE__, OPH_QUERY_ENGINE_LOG_NULL_INPUT_PARAM); logging(LOG_ERROR, __FILE__, __LINE__,OPH_QUERY_ENGINE_LOG_NULL_INPUT_PARAM); return OPH_QUERY_ENGINE_NULL_PARAM; } if( hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_FROM_ALIAS) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_WHEREL) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_WHEREC) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_WHERER) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_GROUP) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_WHERE) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_FUNC) || hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_ARG)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Query not valid: keyword not supported.\n"); logging(LOG_ERROR, __FILE__, __LINE__, "Query not valid: keyword not supported.\n"); return OPH_QUERY_ENGINE_PARSE_ERROR; } char* tmp = hashtbl_get(hashtbl, OPH_QUERY_ENGINE_LANG_ARG_ORDER_DIR); if ( tmp && strcasecmp(tmp,"ASC") ) { pmesg(LOG_WARNING, __FILE__, __LINE__, "Keyword '%s' skipped.\n", OPH_QUERY_ENGINE_LANG_ARG_ORDER_DIR); logging(LOG_WARNING, __FILE__, __LINE__, "Keyword '%s' skipped.\n", OPH_QUERY_ENGINE_LANG_ARG_ORDER_DIR); } return OPH_QUERY_ENGINE_SUCCESS; }
//inserts centroids into graph //finds and prints edges between them void find_centroid_edges(FILE *fp) { int *i,*zero; KEY *node; HASHTBL *hash = NULL; zero = malloc(sizeof(int)); *zero = 0; for (node = hashtbl_getkeys(input); node; node = node->next) { i = hashtbl_get(input,node->data); if (*i-1 > graphsize) *i = graphsize+1; //printf("inserting %s into graph[%d]\n",node->data,*i-1); if (!(hash = graph[*i-1])) { if (!(hash = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() for input failed"); exit(EXIT_FAILURE); } graph[*i-1] = hash; } if (!hashtbl_get(hash,node->data)) hashtbl_insert(hash,node->data,zero); } }
int make_binary(char *profile,int *k) { int sum=0,*bin = NULL; char *blank = " "; char *copy = strdup(profile); char *helix; for (helix = strtok(copy,blank); helix; helix = strtok(NULL,blank)) { bin = hashtbl_get(binary,helix); (*k)++; if (!bin) continue; sum += *bin; } free(copy); return sum; }
int oph_server_conf_get_param(HASHTBL *hashtbl, const char *param, char **value) { if(!hashtbl || !param){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Null input parameter\n"); return OPH_SERVER_CONF_NULL_PARAM; } *value = hashtbl_get(hashtbl, param); if (!*value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to get parameter '%s'\n", param); return OPH_SERVER_CONF_ERROR; } return OPH_SERVER_CONF_SUCCESS; }
char* print_edge(KEY *node,char **table,int v,int* sum) { int count = 0,val; char *v1 = malloc(sizeof(char)*30); v1[0] = '\0'; if (v == 0) { printf("%s-- %s\n",node->data,"E "); return v1; } for (val = (v & 1); v > 0; v >>= 1, count++, val = (v & 1)) if (val == 1) { *sum += *((int*) hashtbl_get(binary,table[count])); strcat(v1,table[count]); strcat(v1," "); } printf("%s-- %s\n",node->data,v1); return v1; }
//diff contains helix nums that are inserted into a hash //to be used before edge_label //add triplet info to diff char* insert_diff(HASHTBL *temp,char *diff) { int size = INIT_SIZE; char *blank = " ", *copy,*k,*val; if (strlen(diff) == 0) return ""; copy = malloc(sizeof(char)*ARRAYSIZE*size); copy[0] = '\0'; for (k = strtok(diff,blank); k; k = strtok(NULL,blank)) { hashtbl_insert(temp,k,"1"); //printf("insert_diff: inserting %s into hash\n",k); val = hashtbl_get(idhash,k); if (strlen(copy)+strlen(k)+strlen(val)+5 > ARRAYSIZE*size) copy = resize(&size,strlen(copy)+strlen(k)+strlen(val)+5,copy); if (strlen(copy)> 0) strcat(copy,"\\n"); sprintf(copy,"%s%s: %s",copy,k,val); } //free(diff); return copy; }
/* Write all FONT records. */ void wbook_store_all_fonts(struct wbookctx *wbook) { int i; struct pkt *font; struct htbl *fonts; int key; int index; font = fmt_get_font(wbook->tmp_format); for (i = 1; i < 6; i++) { bw_append(wbook->biff, font->data, font->len); } pkt_free(font); fonts = hashtbl_new(wbook->formatcount + 1); /* For tmp_format */ index = 6; /* First user defined FONT */ key = fmt_gethash(wbook->tmp_format); hashtbl_insert(fonts, key, 0); /* Index of the default font */ /* User defined fonts */ for (i = 0; i < wbook->formatcount; i++) { int data; key = fmt_gethash(wbook->formats[i]); data = hashtbl_get(fonts, key); if (data >= 0) { /* FONT has already been used */ wbook->formats[i]->font_index = data; } else { /* Add a new FONT record */ hashtbl_insert(fonts, key, index); wbook->formats[i]->font_index = index; index++; font = fmt_get_font(wbook->formats[i]); bw_append(wbook->biff, font->data, font->len); pkt_free(font); } } hashtbl_destroy(fonts); }
//checks whether edge exists and inserts if not //ie insert if profile -> origprof doesn't exist yet void check_insert_edge(FILE *fp,char *profile,char *origprof) { int k1=0,k2=0; //*f1,*f2; //double ratio; char *diff,*copy,*brac; HASHTBL *hash = NULL; /* hash = graph[k1-1]; f1 = hashtbl_get(hash,profile); hash = graph[k2-1]; f2 = hashtbl_get(hash,origprof); ratio = ((double)*f2)/((double)*f1); // printf("ratio for %s and %s is %d/%d = %.2f\n",origprof,profile,*f2,*f1,ratio); */ copy = malloc(sizeof(char)*(strlen(profile)+strlen(origprof)+4)); // if (strlen(profile)+strlen(origprof) > (ARRAYSIZE*size-4)) //copy = resize(&size,strlen(profile)+strlen(origprof)+4,copy); sprintf(copy,"%s-> %s",profile,origprof); if (hashtbl_get(edges,copy)) return; hashtbl_insert(edges,copy,"1"); if (!(hash = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } diff = find_diff(hash,profile,origprof,&k1,&k2); brac = edge_label(hash,profile,origprof,k2); //color=gray%.0f,100-(ratio*100); if (strlen(brac) > 1) fprintf(fp,"\"%s\"-> \"%s\" [label=\" %s\\n%s \",fontsize=8];\n",profile,origprof,brac,diff); //if (VERBOSE) //printf("inserting edge %s\n",copy); free(copy); free(diff); free(brac); hashtbl_destroy(hash); }
int parser_eval(const expr_t *e, long double *r, hashtbl_t *vars) { if (!e || !r) { fprintf(stderr, "eval error: null expression or result var\n"); return 1; } /* load known functions */ static hashtbl_t *functions = NULL; if (unlikely(functions == NULL)) { functions = hashtbl_init(NULL, NULL); register_functions(functions); } /* stash constants into whatever symtab we get */ if (unlikely(vars && !hashtbl_get(vars, "_stashed"))) { register_constants(vars); } const list_t *l = (const list_t*)e; const list_node_t *n = list_last(l); list_t *args = list_init(free, NULL); const symbol_t *s; while (n && (s = (const symbol_t*)list_data(n))) { long double *d = NULL, *v = NULL; long double (*f)(list_t*, size_t); switch (s->type) { case stNumber: d = (long double*)zmalloc(sizeof(long double)); *d = s->number; list_push(args, d); break; case stVariable: if (!vars) { fprintf(stderr, "eval error: no symbol table\n"); list_destroy(args); return 1; } if (!(v = (long double*)hashtbl_get(vars, s->variable))) { fprintf(stderr, "eval error: uninitialized variable [%s]\n", s->variable); list_destroy(args); return 1; } d = (long double*)zmalloc(sizeof(long double)); *d = *v; list_push(args, d); break; case stBinOperator: /* rhs operand */ if (!(v = (long double*)list_pop(args))) { fprintf(stderr, "eval error: missing rhs operand\n"); list_destroy(args); return 1; } case stUniOperator: /* lhs operand, don't pop it... use it to store the result too */ if (!(d = (long double*)list_peek_head(args))) { fprintf(stderr, "eval error: missing lhs operand\n"); list_destroy(args); return 1; } *d = semanter_operator(s->operator, *d, s->type == stBinOperator ? *v : 0.0); free(v); break; case stFunction: if (!(f = (long double(*)(list_t*, size_t))hashtbl_get(functions, s->func.name))) { fprintf(stderr, "eval error: unknown function [%s]\n", s->func.name); list_destroy(args); return 1; } d = (long double*)zmalloc(sizeof(long double)); *d = f(args, s->func.nargs); list_push(args, d); break; } n = list_prev(n); } if (list_size(args) != 1) { fprintf(stderr, "eval error: corrupt args stack\n"); list_destroy(args); return 1; } long double *d = (long double*)list_peek_head(args); *r = *d; list_destroy(args); return 0; }
//finds the bracket notation for profile->origprof based on originating profile of size k //difference between profile and origprof is in hash //make sure origprof has a bracket rep (should be done in make_bracket_rep) char* edge_label(HASHTBL *hash,char *profile, char *origprof,int k) { int i=0,count = 0,j=0,num=0,*diff,*save,ind=0,m=0; char *origbrac,*brac,*blank = "[]",*copy,*val; char **array; if (!(origbrac = hashtbl_get(bracket,origprof))) { fprintf(stderr,"Error: origprof %s has no bracket representation in bracket: edge_label()\n",origprof); return ""; } // if (strlen(profile) == 0) copy = mystrdup(origbrac); brac = malloc(strlen(origbrac)); //printf("finding edge label between %s and %s\n",origbrac,profile); array = malloc(sizeof(char*)*k); diff = malloc(sizeof(int)*hashtbl_numkeys(hash)); save = malloc(sizeof(int)*hashtbl_numkeys(hash)); //put helices of origprof into array; array in chron order for (val = strtok(copy,blank); val; val = strtok(NULL,blank)) { //printf("val is %s\n",val); if (i >= k) fprintf(stderr,"mismatch between k=%d and number of helices %d for %s: edge_label\n",k,i,origprof); array[i++] = val; //printf("val %s is at %d\n",val,i-1); } //save index in origprof of all diff helices; in ascending order for (count = 0; count < i; count++) { if (hashtbl_get(hash,array[count])) { //printf("saving %s at %d to index %d\n",array[count],count,j); diff[j++] = count; } } copy[0] = '\0'; brac[0] = '\0'; count = 0; j = -1; //i is index for origbrac, j is index for what level we need to match ']' //ind is index for level that increases for '[' and decreases for ']' //num is number of '[' encountered //count is index of different helix being proecessed //m is index for array of origprof helices, to print out ones not in diff for (i = 0; origbrac[i] != '\0'; i++) { //keep track of how many '['s if (origbrac[i] == '[') { ind++; val = mystrdup(array[m]); if (diff[count] == num++) { count++; save[++j] = ind; //printf("\nsaving %d to j=%d\n",ind,j); strcat(copy,"{"); } else { //strcat(brac,"["); //strcat(brac,array[m]); sprintf(brac,"%s[%s",brac,array[m]); strcat(copy,"["); } strcat(copy,val); free(val); m++; } //keep track of which level brackets are at else if (origbrac[i] == ']') { //printf("\nchecking ind %d against %d at %d\n",ind,save[j] puts("after check insert edge");,j); if (j >= 0 && save[j] == ind--) { j--; strcat(copy,"}"); } else { strcat(brac,"]"); strcat(copy,"]"); } } } if (!(hashtbl_get(bracket,profile))) { hashtbl_insert(bracket,profile,brac); //printf("new brac is %s for (%s ->) %s with copy %s\n",brac,origprof,profile,copy); } free(array); free(diff); free(save); return copy; }
int env_set(HASHTBL * task_tbl, oph_operator_struct * handle) { if (!handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_SPLIT_operator_handle *) calloc(1, sizeof(OPH_SPLIT_operator_handle)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SPLIT_MEMORY_ERROR_HANDLE); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_datacube = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_job = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->fragment_ids = NULL; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys = NULL; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys_num = -1; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->server = NULL; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->sessionid = NULL; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_user = 0; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->description = NULL; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->execute_error = 0; char *datacube_in; char *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param(value, &((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys, &((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } // retrieve sessionid value = hashtbl_get(task_tbl, OPH_ARG_SESSIONID); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_SESSIONID); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_ARG_SESSIONID); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SPLIT_operator_handle *) handle->operator_handle)->sessionid = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_GENERIC_MEMORY_ERROR_INPUT, "sessionid"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //3 - Fill struct with the correct data value = hashtbl_get(task_tbl, OPH_IN_PARAM_DATACUBE_INPUT); datacube_in = value; if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_DATACUBE_INPUT); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SPLIT_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_DATACUBE_INPUT); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } //For error checking int id_datacube_in[3] = { 0, 0, 0 }; value = hashtbl_get(task_tbl, OPH_ARG_USERNAME); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_USERNAME); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SPLIT_MISSING_INPUT_PARAMETER, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } char *username = value; if (handle->proc_rank == 0) { //Only master process has to initialize and open connection to management OphidiaDB ophidiadb *oDB = &((OPH_SPLIT_operator_handle *) handle->operator_handle)->oDB; oph_odb_init_ophidiadb(oDB); if (oph_odb_read_ophidiadb_config_file(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to read OphidiaDB configuration\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SPLIT_OPHIDIADB_CONFIGURATION_FILE); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if (oph_odb_connect_to_ophidiadb(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to connect to OphidiaDB. Check access parameters.\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SPLIT_OPHIDIADB_CONNECTION_ERROR); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } //Check if datacube exists (by ID container and datacube) int exists = 0; int status = 0; char *uri = NULL; int folder_id = 0; int permission = 0; if (oph_pid_parse_pid(datacube_in, &id_datacube_in[1], &id_datacube_in[0], &uri)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to parse the PID string\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_PID_ERROR, datacube_in); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } else if ((oph_odb_cube_check_if_datacube_not_present_by_pid(oDB, uri, id_datacube_in[1], id_datacube_in[0], &exists)) || !exists) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unknown input container - datacube combination\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_NO_INPUT_DATACUBE, datacube_in); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } else if ((oph_odb_cube_check_datacube_availability(oDB, id_datacube_in[0], 0, &status)) || !status) { pmesg(LOG_ERROR, __FILE__, __LINE__, "I/O nodes storing datacube aren't available\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_DATACUBE_AVAILABILITY_ERROR, datacube_in); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } else if ((oph_odb_fs_retrive_container_folder_id(oDB, id_datacube_in[1], 1, &folder_id))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to retrieve folder of specified datacube or container is hidden\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_DATACUBE_FOLDER_ERROR, datacube_in); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } else if ((oph_odb_fs_check_folder_session(folder_id, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->sessionid, oDB, &permission)) || !permission) { //Check if user can work on datacube pmesg(LOG_ERROR, __FILE__, __LINE__, "User %s is not allowed to work on this datacube\n", username); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_DATACUBE_PERMISSION_ERROR, username); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } if (uri) free(uri); uri = NULL; if (oph_odb_user_retrieve_user_id(oDB, username, &(((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_user))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to extract userid.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_USER_ID_ERROR); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } id_datacube_in[2] = id_datacube_in[1]; if (id_datacube_in[1]) { value = hashtbl_get(task_tbl, OPH_IN_PARAM_CONTAINER_INPUT); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_CONTAINER_INPUT); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_CONTAINER_INPUT); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strncmp(value, OPH_COMMON_DEFAULT_EMPTY_VALUE, OPH_TP_TASKLEN)) { if (oph_odb_fs_retrieve_container_id_from_container_name(oDB, folder_id, value, 0, &id_datacube_in[2])) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to retrieve folder of specified container or it is hidden\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_GENERIC_DATACUBE_FOLDER_ERROR, value); id_datacube_in[0] = 0; id_datacube_in[1] = 0; } } } } //Broadcast to all other processes the fragment relative index MPI_Bcast(id_datacube_in, 3, MPI_INT, 0, MPI_COMM_WORLD); //Check if sequential part has been completed if (id_datacube_in[0] == 0) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Master procedure or broadcasting has failed\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_NO_INPUT_DATACUBE, datacube_in); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_datacube = id_datacube_in[0]; if (id_datacube_in[1] == 0) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Master procedure or broadcasting has failed\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_NO_INPUT_CONTAINER, datacube_in); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container = id_datacube_in[1]; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container = id_datacube_in[2]; value = hashtbl_get(task_tbl, OPH_IN_PARAM_SCHEDULE_ALGORITHM); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_SCHEDULE_ALGORITHM); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_SCHEDULE_ALGORITHM); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } ((OPH_SPLIT_operator_handle *) handle->operator_handle)->schedule_algo = (int) strtol(value, NULL, 10); value = hashtbl_get(task_tbl, OPH_IN_PARAM_SPLIT_IN_FRAGMENTS); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_SPLIT_IN_FRAGMENTS); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_SPLIT_IN_FRAGMENTS); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number = (int) strtol(value, NULL, 10); value = hashtbl_get(task_tbl, OPH_ARG_IDJOB); if (!value) ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_job = 0; else ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_job = (int) strtol(value, NULL, 10); value = hashtbl_get(task_tbl, OPH_IN_PARAM_DESCRIPTION); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_DESCRIPTION); logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_DESCRIPTION); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strncmp(value, OPH_COMMON_DEFAULT_EMPTY_VALUE, OPH_TP_TASKLEN)) { if (!(((OPH_SPLIT_operator_handle *) handle->operator_handle)->description = (char *) strndup(value, OPH_TP_TASKLEN))) { logging(LOG_ERROR, __FILE__, __LINE__, id_datacube_in[1], OPH_LOG_OPH_SPLIT_MEMORY_ERROR_INPUT, "description"); pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } } return OPH_ANALYTICS_OPERATOR_SUCCESS; }
int print_vertices(FILE *fp) { int i,*val,size = 5,total = 0,size2=INIT_SIZE,*frq = NULL,zero = 0,start,end; char *rank,*v;; HASHTBL *hash; KEY *node = NULL; rank = malloc(sizeof(char)*ARRAYSIZE*size); v = malloc(sizeof(char)*ARRAYSIZE*size2); for (i = 0; !graph[i]; i++) ; start = i; //for (node = hashtbl_getkeys(graph[i]); node; node = node->next) //check_insert_edge(fp,"",node->data); //print ranks fputs("{ node [shape = plaintext]; ",fp); if (graph[graphsize]) end = graphsize; else end = graphsize-1; for ( ; i <= end; i++) { if (!graph[i]) continue; fprintf(fp,"%d",i+1); if (i == end) fprintf(fp,"; }\n"); else fprintf(fp,"->"); } for (i = start; i <= end; i++) { if (!(hash = graph[i])) continue; //printf("printing level %d\n",i+1); node = hashtbl_getkeys(hash); sprintf(rank,"{ rank = same; %d;",i+1); for (; node; node = node->next) { if (strlen(node->data)+ 4 > ARRAYSIZE*size2-1) { v = resize(&size2,strlen(node->data)+5,v); //printf("resizing v of size %d to %d\n",strlen(v),size2); } sprintf(v,"%d %s",i+1,node->data); frq = hashtbl_get(cluster,v); if (!frq) frq = &zero; sprintf(v," \"%s\";",node->data); val = hashtbl_get(hash,node->data); // printf("found %s for %s\n",hashtbl_get(bracket,node->data),node->data); if (VERBOSE) printf("Vertex %swith frequency %d, originally %d\n",node->data,*val,*frq); if (strlen(rank)+strlen(v) > ARRAYSIZE*size-1) { // printf("resizing rank %s and v %s of size %d to %d\n",rank,v,strlen(rank)+strlen(v),size); rank = resize(&size,strlen(rank)+strlen(v)+1,rank); } strcat(rank,v); //fprintf(fp,"\"%s\" [label = \"%s ",node->data,hashtbl_get(bracket,node->data)); fprintf(fp,"\"%s\" [label = \"(%d/%d)\"];",node->data,*frq,*val); /* if (*frq == most) fprintf(fp,"**"); fprintf(fp,"%s",hashtbl_get(bracket,node->data)); fprintf(fp,"(%d/%d)",*frq,*val); if (*frq == most) fprintf(fp,"**"); if (INPUT && (val = hashtbl_get(input,node->data))) fprintf(fp,"\\n(%d)",val[1]); fprintf(fp,"\",shape = box,style=filled,color=black,fillcolor=grey%d];",(1000-*frq)/20+49); fprintf(fp,"\"%s\" [shape = box, label = \"%s (%d)\",style=filled,color=black,fillcolor=grey%d];\n",node->data,*val,(1000-*frq)/20+49); */ } fprintf(fp,"%s }\n",rank); total += hashtbl_numkeys(hash); //v]0] = '\0'; } return total; }
int env_set(HASHTBL * task_tbl, oph_operator_struct * handle) { if (!handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_SCRIPT_operator_handle *) calloc(1, sizeof(OPH_SCRIPT_operator_handle)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_HANDLE); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->script = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args_num = -1; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->out_redir = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->err_redir = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys_num = -1; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->session_path = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->session_url = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->workflow_id = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->marker_id = NULL; ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->list = 0; //3 - Fill struct with the correct data char *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param(value, &((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys, &((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys, ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_SCRIPT); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_SCRIPT); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_SCRIPT); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->script = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "script"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_ARGS); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_ARGS); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_ARGS); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param(value, &((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args, &((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args, ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->args_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_STDOUT); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_STDOUT); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_STDOUT); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->out_redir = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "stdout"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_STDERR); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_STDERR); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_STDERR); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->err_redir = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "stderr"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_LIST); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_LIST); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_LIST); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strncmp(value, OPH_COMMON_YES_VALUE, OPH_TP_TASKLEN) == 0) { ((OPH_SCRIPT_operator_handle *) handle->operator_handle)->list = 1; } char session_code[OPH_COMMON_BUFFER_LEN]; oph_pid_get_session_code(hashtbl_get(task_tbl, OPH_ARG_SESSIONID), session_code); if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->session_code = (char *) strdup(session_code))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "session code"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } char buff[OPH_COMMON_BUFFER_LEN]; snprintf(buff, OPH_COMMON_BUFFER_LEN, OPH_FRAMEWORK_MISCELLANEA_FILES_PATH, oph_pid_path()? oph_pid_path() : OPH_PREFIX_CLUSTER, session_code); if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->session_path = (char *) strdup(buff))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "session path"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } snprintf(buff, OPH_COMMON_BUFFER_LEN, OPH_FRAMEWORK_MISCELLANEA_FILES_PATH, oph_pid_uri(), session_code); if (!(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->session_url = (char *) strdup(buff))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, "session url"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_ARG_WORKFLOWID); if (value && !(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->workflow_id = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, OPH_ARG_WORKFLOWID); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_ARG_MARKERID); if (value && !(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->marker_id = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, OPH_ARG_MARKERID); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_ARG_USERNAME); if (value && !(((OPH_SCRIPT_operator_handle *) handle->operator_handle)->user = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SCRIPT_MEMORY_ERROR_INPUT, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } return OPH_ANALYTICS_OPERATOR_SUCCESS; }
int env_set(HASHTBL * task_tbl, oph_operator_struct * handle) { if (!handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_UNPUBLISH_operator_handle *) calloc(1, sizeof(OPH_UNPUBLISH_operator_handle)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_MEMORY_ERROR_HANDLE); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->datacube_path = NULL; ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys = NULL; ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys_num = -1; ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->sessionid = NULL; //Only master process has to continue if (handle->proc_rank != 0) return OPH_ANALYTICS_OPERATOR_SUCCESS; ophidiadb *oDB = &((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->oDB; oph_odb_init_ophidiadb(oDB); char *datacube_name; int id_container = 0; char *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param(value, &((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys, &((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } // retrieve sessionid value = hashtbl_get(task_tbl, OPH_ARG_SESSIONID); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_SESSIONID); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_ARG_SESSIONID); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->sessionid = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_GENERIC_MEMORY_ERROR_INPUT, "sessionid"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //3 - Fill struct with the correct data char *tmp_username = NULL; value = hashtbl_get(task_tbl, OPH_ARG_USERNAME); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_USERNAME); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_MISSING_INPUT_PARAMETER, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(tmp_username = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_MEMORY_ERROR_INPUT, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_DATACUBE_INPUT); datacube_name = value; if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_DATACUBE_INPUT); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_DATACUBE_INPUT); free(tmp_username); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_odb_read_ophidiadb_config_file(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to read OphidiaDB configuration\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_OPHIDIADB_CONFIGURATION_FILE); free(tmp_username); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if (oph_odb_connect_to_ophidiadb(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to connect to OphidiaDB. Check access parameters.\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_UNPUBLISH_OPHIDIADB_CONNECTION_ERROR); free(tmp_username); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } int id_datacube = 0; //Check if datacube exists (by ID container and datacube) int exists = 0; char *uri = NULL; int folder_id = 0; int permission = 0; if (oph_pid_parse_pid(value, &id_container, &id_datacube, &uri)) { if (uri) free(uri); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to parse the PID string\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_UNPUBLISH_PID_ERROR, datacube_name); free(tmp_username); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if ((oph_odb_cube_check_if_datacube_not_present_by_pid(oDB, uri, id_container, id_datacube, &exists)) || !exists) { free(uri); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unknown input container - datacube combination\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_UNPUBLISH_NO_INPUT_DATACUBE, datacube_name); free(tmp_username); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } if ((oph_odb_fs_retrive_container_folder_id(oDB, id_container, 1, &folder_id))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to retrieve folder of specified datacube or container is hidden\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_UNPUBLISH_DATACUBE_FOLDER_ERROR, datacube_name); free(uri); free(tmp_username); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } if ((oph_odb_fs_check_folder_session(folder_id, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->sessionid, oDB, &permission)) || !permission) { //Check if user can work on datacube pmesg(LOG_ERROR, __FILE__, __LINE__, "User %s is not allowed to work on this datacube\n", tmp_username); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_UNPUBLISH_DATACUBE_PERMISSION_ERROR, tmp_username); free(uri); free(tmp_username); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } free(tmp_username); free(uri); ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->id_input_container = id_container; char session_code[OPH_COMMON_BUFFER_LEN]; oph_pid_get_session_code(hashtbl_get(task_tbl, OPH_ARG_SESSIONID), session_code); int n = snprintf(NULL, 0, OPH_FRAMEWORK_HTML_FILES_PATH, oph_pid_path()? oph_pid_path() : OPH_PREFIX_CLUSTER, session_code, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->id_input_container, id_datacube) + 1; if (n >= OPH_TP_TASKLEN) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Size of path exceeded limit.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_UNPUBLISH_STRING_BUFFER_OVERFLOW, "path", OPH_FRAMEWORK_HTML_FILES_PATH); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } if (!(((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->datacube_path = (char *) malloc(n * sizeof(char)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_UNPUBLISH_MEMORY_ERROR_INPUT, "datacube path"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } snprintf(((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->datacube_path, n, OPH_FRAMEWORK_HTML_FILES_PATH, oph_pid_path()? oph_pid_path() : OPH_PREFIX_CLUSTER, session_code, ((OPH_UNPUBLISH_operator_handle *) handle->operator_handle)->id_input_container, id_datacube); return OPH_ANALYTICS_OPERATOR_SUCCESS; }
//processes input file containing structures of interest, in triplet form //similar code to make_cluster: converts triplet to profile, void process_input(FILE *fp) { HASHTBL *halfbrac; FILE *file; char temp[100],tmp[ARRAYSIZE],*profile,*fullprofile,*diff; int i,j,k,*id,last=0,lastprob; int numhelix = 0,fullnum = 0,size = INIT_SIZE,size2 = INIT_SIZE,size3 = INIT_SIZE; if (!(halfbrac = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() for halfbrac failed"); exit(EXIT_FAILURE); } if (!(input = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() for input failed"); exit(EXIT_FAILURE); } //longest = hashtbl_get(max,"longest"); profile = malloc(sizeof(char)*ARRAYSIZE*size); fullprofile = malloc(sizeof(char)*ARRAYSIZE*size2); diff = malloc(sizeof(char)*ARRAYSIZE*size3); profile[0] = '\0'; fullprofile[0] = '\0'; diff[0] = '\0'; if (!(file = fopen(INPUT,"r"))) fprintf(stderr,"Cannot open %s\n",INPUT); while (fgets(temp,100,file)) { if (sscanf(temp,"%d %d %d",&i,&j,&k) == 3) { sprintf(tmp,"%d %d",i,j); id = hashtbl_get(bp,tmp); //printf("id is %d for %d %d %d\n",id,i,j,k); if (!id) id = process_native(i,j,k); if (*id != last) { sprintf(tmp,"%d",*id); if (hashtbl_get(freq,tmp)) { //is a freq helix, save to profile numhelix++; if (strlen(profile)+strlen(tmp) > (ARRAYSIZE*size-2)) profile = resize(&size,strlen(profile)+strlen(tmp)+1,profile); //printf("adding %d to profile\n",*id); sprintf(profile,"%s%s ",profile,tmp); } else { if (strlen(diff)+strlen(tmp)+2 > ARRAYSIZE*size3) diff = resize(&size3,strlen(diff)+strlen(tmp)+2,diff); sprintf(diff,"%s%s ",diff,tmp); //printf("printing diff %s\n",diff); } fullnum++; if (strlen(fullprofile)+strlen(tmp) > (ARRAYSIZE*size-2)) fullprofile = resize(&size2,strlen(fullprofile)+strlen(tmp)+2,fullprofile); sprintf(fullprofile,"%s%s ",fullprofile,tmp); //printf("helix %d added is %s\n",fullnum,tmp); last = *id; make_brackets(halfbrac,i,j,*id); } else //if id == last printf("helix %d %d %d is duplicate with id %d: process_input()\n",i,j,k,*id); } else if (sscanf(temp,"Structure %d (%d)",&i,&j) == 2) { if (strlen(fullprofile) == 0) { lastprob = j; continue; } //printf("profile is %s, fullprofile %s with diff %s\n\n",profile,fullprofile,diff); halfbrac = process_input_profile(fp,halfbrac,fullprofile,fullnum,profile,numhelix,diff,lastprob); numhelix = 0; fullnum = 0; profile[0] = '\0'; fullprofile[0] = '\0'; diff[0] = '\0'; lastprob = j; } } //printf("input profile is %s with fullprofile %s and diff %s\n",profile,fullprofile,diff); halfbrac = process_input_profile(fp,halfbrac,fullprofile,fullnum,profile,numhelix,diff,lastprob); free(profile); hashtbl_destroy(halfbrac); //finds edges between centroids find_centroid_edges(fp); }
//takes input profile and checks if in graph //if so, changes node shape to hexagon //if not, insert new vertex HASHTBL* process_input_profile(FILE *fp,HASHTBL *brac,char *fullprofile, int fullnum,char *profile,int numhelix, char *diff, int prob) { HASHTBL *hash, *temp=NULL; char *diff1,*bracket,*difftrip; int *val,k1=0,k2=0; KEY *parent,*next; if (!(temp = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } make_bracket_rep(brac,fullprofile); hashtbl_destroy(brac); profile = sort_input(profile,numhelix); //printf("(sorted) profile is %s with fullprofile %s and diff %s\n",profile,fullprofile,diff); if ((hash = graph[numhelix-1]) && (hashtbl_get(hash,profile))) { if (numhelix == fullnum) { //printf("case 1: full profile found in graph\n"); fullprofile = sort_input(fullprofile,numhelix); } else { //cannot use find_diff because fullprofile has helices not in table[] //puts("case 2: profile found in graph"); diff = insert_diff(temp,diff); bracket = edge_label(temp,profile,fullprofile,fullnum); fprintf(fp,"\"%s\"-> \"%s\" [label =\" %s\\n%s \",fontsize=8,style = dotted];\n",profile,fullprofile,diff,bracket); } } else { /* if (numhelix == fullnum) puts("case 3: full profile not found"); else puts("case 4: profile not found"); */ for (parent = find_parents(profile); parent; parent = next) { diff1 = find_diff(temp,parent->data,profile,&k1,&k2); if (numhelix != fullnum) { difftrip = insert_diff(temp,diff); diff1 = realloc(diff1,strlen(diff1)+strlen(difftrip)+4); //printf("for parent %s, diff1 is now %s, diff is %s and difftrip is %s\n",parent->data,diff1,diff,difftrip); sprintf(diff1,"%s\\n%s",diff1,difftrip); //printf("Diff is %s for parent %s of profile %s; diff %s for %s\n",diff1,parent->data,profile,difftrip,fullprofile); } bracket = edge_label(temp,parent->data,fullprofile,fullnum); fprintf(fp,"\"%s\"-> \"%s\" [label =\" %s\\n%s \",fontsize=8,style = dotted];\n",parent->data,fullprofile,bracket,diff1); next = parent->next; free(parent); } } //printf("%s has size %d and prob %d\n",fullprofile,fullnum,prob); fprintf(fp,"\"%s\" [shape = hexagon];\n",fullprofile); val = malloc(sizeof(int)*2); val[0] = fullnum; val[1] = prob; hashtbl_insert(input,fullprofile,val); hashtbl_destroy(temp); if (!(brac = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } return brac; }
int oph_workflow_var_substitute(oph_workflow * workflow, int task_index, int light_task_index, char *submit_string, char **error) { unsigned int i, l = strlen(OPH_WORKFLOW_SEPARATORS), offset; char *p, *ep, firstc, lastc, lastcc, return_error, prefix, *key, *value = NULL; char replaced_value[OPH_WORKFLOW_MAX_STRING], target_value[OPH_WORKFLOW_MAX_STRING]; oph_workflow_var *var; int index; while (((p = strchr(submit_string, OPH_WORKFLOW_VARIABLE_PREFIX))) || ((p = strchr(submit_string, OPH_WORKFLOW_INDEX_PREFIX)))) { firstc = 1; lastc = lastcc = 0; for (ep = p + 1; *ep; ep++) // assuming compliance with IEEE Std 1003.1-2001 conventions { if (firstc) { firstc = 0; if (*ep == OPH_WORKFLOW_BRACKET[0]) { lastc = 1; continue; } } if (lastc && (*ep == OPH_WORKFLOW_BRACKET[1])) { lastcc = 1; break; } for (i = 0; i < l; ++i) if (*ep == OPH_WORKFLOW_SEPARATORS[i]) break; if (i < l) break; if (lastc || (*ep == '_') || ((*ep >= 'A') && (*ep <= 'Z')) || ((*ep >= 'a') && (*ep <= 'z')) || ((ep - p > 1) && (*ep >= '0') && (*ep <= '9'))) continue; break; } strncpy(target_value, p, ep - p); target_value[ep - p] = 0; if (lastcc) ep++; key = target_value + 1 + lastc; if (lastc != lastcc) return_error = 1; else if (workflow->tasks[task_index].vars && ((var = hashtbl_get(workflow->tasks[task_index].vars, key)))) return_error = 0; else if (workflow->vars && ((var = hashtbl_get(workflow->vars, key))) && oph_workflow_is_child_of(workflow, var->caller, task_index)) return_error = 0; else if (!oph_workflow_check_args(workflow, task_index, light_task_index, key, &value, &index)) return_error = -1; else return_error = 1; prefix = *target_value == OPH_WORKFLOW_INDEX_PREFIX; if ((return_error > 0) || (prefix && (return_error < 0) && (index < 0))) { char _error[OPH_WORKFLOW_MAX_STRING]; snprintf(_error, OPH_WORKFLOW_MAX_STRING, "Bad variable '%s' in task '%s'", target_value, workflow->tasks[task_index].name); pmesg(LOG_WARNING, __FILE__, __LINE__, "%s of workflow '%s'\n", _error, workflow->name); if (error) *error = strdup(_error); if (value) free(value); return OPH_WORKFLOW_EXIT_BAD_PARAM_ERROR; } offset = p - submit_string; *replaced_value = 0; strncpy(replaced_value, submit_string, offset); replaced_value[offset] = 0; if (prefix) snprintf(replaced_value + offset, OPH_WORKFLOW_MAX_STRING, "%d%s", return_error ? index : var->ivalue, ep); else snprintf(replaced_value + offset, OPH_WORKFLOW_MAX_STRING, "%s%s", return_error ? value : var->svalue, ep); strcpy(submit_string, replaced_value); if (value) { free(value); value = NULL; } } return OPH_WORKFLOW_EXIT_SUCCESS; }
//process input into three profiles Hs,Hu,Hn //s = selected profiles, u = unselected in sample,n=in native only //connects them, puts Hs in cluster with freq = 0 if not already there int process_one_input(FILE *fp) { HASHTBL *halfbrac; FILE *file; char temp[100],tmp[ARRAYSIZE],*profile,*fullprofile,*diff,*native,*diffn,*dup; int i,j,k,*id,last=0,insample; int numhelix = 0,fullnum = 0,natnum = 0; int size = INIT_SIZE,size2 = INIT_SIZE,size3 = INIT_SIZE,size4 = INIT_SIZE,size5 = INIT_SIZE; if (!(halfbrac = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() for halfbrac failed"); exit(EXIT_FAILURE); } if (!(input = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() for input failed"); exit(EXIT_FAILURE); } //longest = hashtbl_get(max,"longest"); profile = malloc(sizeof(char)*ARRAYSIZE*size); fullprofile = malloc(sizeof(char)*ARRAYSIZE*size2); diff = malloc(sizeof(char)*ARRAYSIZE*size3); native = malloc(sizeof(char)*ARRAYSIZE*size4); diffn = malloc(sizeof(char)*ARRAYSIZE*size5); profile[0] = '\0'; fullprofile[0] = '\0'; diff[0] = '\0'; native[0] = '\0'; diffn[0] = '\0'; if (!(file = fopen(INPUT,"r"))) fprintf(stderr,"Cannot open %s\n",INPUT); while (fgets(temp,100,file)) { // if (sscanf(temp,"Structure %d (%d)",&i,&prob) == 2) if (sscanf(temp,"%d %d %d",&i,&j,&k) == 3) { insample = 1; sprintf(tmp,"%d %d",i,j); id = hashtbl_get(bp,tmp); if (!id) { id = process_native(i,j,k); //printf("number in marginals %d\n",hashtbl_numkeys(marginals)); if (*id > hashtbl_numkeys(marginals)) insample = 0; } if (*id != last) { sprintf(tmp,"%d",*id); if (strlen(native)+strlen(tmp) > (ARRAYSIZE*size4-2)) native = realloc(native,ARRAYSIZE*(++size4)); sprintf(native,"%s%s ",native,tmp); natnum++; if (insample) { fullnum++; if (strlen(fullprofile)+strlen(tmp) > (ARRAYSIZE*size2-2)) fullprofile = realloc(fullprofile,ARRAYSIZE*(++size2)); sprintf(fullprofile,"%s%s ",fullprofile,tmp); if (hashtbl_get(freq,tmp)) { //is a freq helix, save to profile numhelix++; if (strlen(profile)+strlen(tmp) > (ARRAYSIZE*size-2)) profile = realloc(profile,ARRAYSIZE*(++size)); //printf("adding %d to profile\n",*id); sprintf(profile,"%s%s ",profile,tmp); } else { //if not freq record diff if (strlen(diff)+strlen(tmp)+2 > ARRAYSIZE*size3) diff = realloc(diff,ARRAYSIZE*(++size3)); sprintf(diff,"%s%s ",diff,tmp); //printf("printing diff %s\n",diff); } } else { if (strlen(diffn)+strlen(tmp)+2 > ARRAYSIZE*size5) diffn = realloc(diffn,ARRAYSIZE*(++size5)); sprintf(diffn,"%s%s ",diffn,tmp); } last = *id; make_brackets(halfbrac,i,j,*id); } else if (VERBOSE) printf("helix %d %d %d is duplicate with id %d: process_input()\n",i,j,k,*id); } } native = sort_input(native,natnum); //printf("native is now %s\n",native); make_bracket_rep(halfbrac,native); hashtbl_destroy(halfbrac); fullprofile = sort_input(fullprofile,fullnum); profile = sort_input(profile,numhelix); //printf("native %s, fullprofile %s, profile %s, diff %s, diffn %s\n",native,fullprofile,profile,diff,diffn); if (fullnum != natnum) make_edge_and_node(fp,fullprofile,native,diffn,natnum); if (numhelix != fullnum) make_edge_and_node(fp,profile,fullprofile,diff,fullnum); fprintf(fp,"\"%s\" [style = filled, fillcolor = gray60];\n",profile); sprintf(tmp,"%d ",numhelix); if (strlen(tmp)+strlen(profile) > ARRAYSIZE*size+1) profile = realloc(profile,ARRAYSIZE*(++size)); dup = mystrdup(profile); sprintf(profile,"%s%s",tmp,dup); id = hashtbl_get(cluster,profile); free(dup); if (!id) { id = malloc(sizeof(int)); *id = 0; hashtbl_insert(cluster,profile,id); //printf("inserting input %s into cluster\n",profile); } free(profile); return numhelix; }
//adds infreq profiles to general and specific frequency when applicable //begin is the list of LCA's generated void add_infreq(struct hashnode_s *begin) { //general freq lives in graph with all vertices int length,sum,k,*val,bin,selected; char *blank = " ",*helix,*orig,*fprof,*copy; struct hashnode_s *listnode; KEY *node; HASHTBL *hash; selected = hashtbl_numkeys(cluster); //for every infreq node, add to appropriate gen/spec freq for (node = hashtbl_getkeys(infreq); node; node = node->next) { //prof = malloc(strlen(node->data)); //printf("processing infreq %s\n",node->data); orig = mystrdup(node->data); length = atoi(strtok(node->data,blank)); //prof[0] = '\0'; sum = 0; //find its binary rep for (k = 0; k < length; k++) { helix = strtok(NULL,blank); //all helices are freq helices in binary hash sum += *((int*) hashtbl_get(binary,helix)); } node->data = orig; //check all oval LCA for parentage/identity for (listnode = begin; listnode; listnode = listnode->next) { //key is mod profile, data is bin rep of profile //if identity, change sfreq in cluster bin = *((int*)listnode->data); if (bin == sum) hashtbl_insert(cluster,orig,hashtbl_get(infreq,node->data)); //if parent, change gfreq in graph else if ((bin & sum) == bin) { //printf("found oval parent %s of %s\n",listnode->key,orig); for (length = 0; bin > 0; bin >>= 1) if (bin & 1) length++; hash = graph[length-1]; if (hash) { val = hashtbl_get(hash,listnode->key); *val += *((int*)hashtbl_get(infreq,node->data)); } else fprintf(stderr,"error:didn't find hash at level %d in add_infreq()\n",length-1); } } //check all selected nodes for parentage for (k = 0; k < selected; k++) { fprof = profileID[k]; //if intersection (ie parent), add to gfreq if ((sum & sums[k]) == sums[k]) { //printf("found parent %s of %s\n",fprof,orig); copy = mystrdup(fprof); length = atoi(strtok(copy,blank)); hash = graph[length-1]; fprof = modprofileID[k]; val = hashtbl_get(hash,fprof); if (val) *val += *((int*)hashtbl_get(infreq,node->data)); else fprintf(stderr,"error:val not found in add_infreq()\n"); free(copy); } } //free(orig); } }
//runs through nodes in cluster, finding their LCA's int insert_graph(FILE *fp,char *file,int gsize) { int i,*freq,k = 0,numkeys,total; char *profile; KEY *node; struct hashnode_s *begin; if (!(edges = hashtbl_create(HASHSIZE,NULL))) { fprintf(stderr, "ERROR: hashtbl_create() failed"); exit(EXIT_FAILURE); } fputs("digraph G {\n",fp); fprintf(fp,"\tlabel = \"%s\";\n",file); fprintf(fp,"\tpad = 0.5;\n"); fprintf(fp,"\tnodesep = 0.5;\n"); fprintf(fp,"\"\" [label=\"(0/%d)\"]\n",NUMSTRUCTS); //fputs("{ node [shape = plaintext]; ",fp); graphsize = gsize; if (INPUT) { i = process_one_input(fp); if (i > gsize) graphsize = i; } //printf("graphsize is %d for %s\n",*count,node->data); graph = malloc(sizeof(HASHTBL*)*(graphsize+1)); for (i = 0; i <= graphsize; i++) graph[i] = NULL; /*print ranks for (i = 0; i < *count; i++) { fprintf(fp,"%d",i+1); if (i == *count-1) fprintf(fp,"; }\n"); else fprintf(fp,"->"); } */ numkeys = hashtbl_numkeys(cluster); sums = malloc(sizeof(long)*numkeys); k = numkeys-1; profileID = malloc(sizeof(char*)*numkeys); modprofileID = malloc(sizeof(char*)*numkeys); most = 0; //for each profile, insert with freq for (node = hashtbl_getkeys(cluster); node; node = node->next) { //printf("node data is %s with k = %d\n",node->data,k); freq = hashtbl_get(cluster,node->data); //need to insert into graph if (freq) { if (most < *freq) most = *freq; profile = malloc(strlen(node->data)+1); sums[k] = insert_and_binary(node->data,profile,*freq); profileID[k] = node->data; modprofileID[k--] = profile; if (*freq > 0) fprintf(fp,"\"%s\" [shape = box];\n",profile); } else fprintf(stderr,"No entry for %s\n",node->data); //printf("for profile %s binary rep is %d with ID %d\n",node->data,sums[k+1],k+1); } make_key(); begin = insert_LCAs(fp,numkeys); //printf("inserted LCA's with numkeys %d\n",numkeys); add_infreq(begin); find_LCA_edges(fp,begin,numkeys); total = print_vertices(fp); printf("Total number of vertices: %d\n",total); if (INPUT) hashtbl_destroy(input); for (i = 0; i < graphsize; i++) { if (graph[i]) hashtbl_destroy(graph[i]); } free(sums); free(table); free(profileID); free(modprofileID); hashtbl_destroy(edges); return 0; }
int env_set(HASHTBL * task_tbl, oph_operator_struct * handle) { if (!handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_NULL_OPERATOR_HANDLE); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_NULL_TASK_TABLE); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_HANDLE_ALREADY_INITIALIZED); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_SEARCH_operator_handle *) calloc(1, sizeof(OPH_SEARCH_operator_handle)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MEMORY_ERROR_HANDLE); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter_num = 0; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->cwd = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter_num = 0; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter_num = 0; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->path = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->user = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys = NULL; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys_num = -1; ((OPH_SEARCH_operator_handle *) handle->operator_handle)->sessionid = NULL; ophidiadb *oDB = &((OPH_SEARCH_operator_handle *) handle->operator_handle)->oDB; //Only master process has to continue if (handle->proc_rank != 0) return OPH_ANALYTICS_OPERATOR_SUCCESS; oph_odb_init_ophidiadb(oDB); if (oph_odb_read_ophidiadb_config_file(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to read OphidiaDB configuration\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_OPHIDIADB_CONFIGURATION_FILE_NO_CONTAINER); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if (oph_odb_connect_to_ophidiadb(oDB)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to connect to OphidiaDB. Check access parameters.\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_OPHIDIADB_CONNECTION_ERROR_NO_CONTAINER); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } //3 - Fill struct with the correct data char *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param(value, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys, ((OPH_SEARCH_operator_handle *) handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } // retrieve sessionid value = hashtbl_get(task_tbl, OPH_ARG_SESSIONID); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_SESSIONID); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_ARG_SESSIONID); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SEARCH_operator_handle *) handle->operator_handle)->sessionid = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_GENERIC_MEMORY_ERROR_INPUT, "sessionid"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_PATH); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_PATH); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_PATH); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SEARCH_operator_handle *) handle->operator_handle)->path = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MEMORY_ERROR_INPUT, OPH_IN_PARAM_PATH); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_CWD); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_CWD); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_CWD); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SEARCH_operator_handle *) handle->operator_handle)->cwd = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MEMORY_ERROR_INPUT, OPH_IN_PARAM_CWD); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_CONTAINER_NAME_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_CONTAINER_NAME_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_CONTAINER_NAME_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param (value, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_INVALID_INPUT_STRING); oph_tp_free_multiple_value_param_list(((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter, ((OPH_SEARCH_operator_handle *) handle->operator_handle)->container_filter_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_METADATA_KEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_METADATA_KEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_METADATA_KEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param (value, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_INVALID_INPUT_STRING); oph_tp_free_multiple_value_param_list(((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter, ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_key_filter_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_METADATA_VALUE_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_METADATA_VALUE_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_METADATA_VALUE_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param (value, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter, &((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_INVALID_INPUT_STRING); oph_tp_free_multiple_value_param_list(((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter, ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } int i; for (i = 0; i < ((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter_num; ++i) if (strstr(((OPH_SEARCH_operator_handle *) handle->operator_handle)->metadata_value_filter[i], OPH_SEARCH_AND_SEPARATOR)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Separator '%s' cannot be used in filter for values: use it in filter for keys as 'AND'\n", OPH_SEARCH_AND_SEPARATOR); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Separator '%s' cannot be used in filter for values: use it in filter for keys as 'AND'\n", OPH_SEARCH_AND_SEPARATOR); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_ARG_USERNAME); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_USERNAME); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MISSING_INPUT_PARAMETER, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_SEARCH_operator_handle *) handle->operator_handle)->user = (char *) strdup(value))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_SEARCH_MEMORY_ERROR_INPUT, OPH_ARG_USERNAME); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } return OPH_ANALYTICS_OPERATOR_SUCCESS; }
int env_set (HASHTBL *task_tbl, oph_operator_struct *handle) { if (!handle){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_DELETECONTAINER_operator_handle *) calloc (1, sizeof (OPH_DELETECONTAINER_operator_handle)))){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MEMORY_ERROR_HANDLE ); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container = 0; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->container_input = NULL; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->cwd = NULL; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->user = NULL; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->hidden = 0; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->delete_type = 0; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys = NULL; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys_num = -1; ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->sessionid = NULL; ophidiadb *oDB = &((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->oDB; oph_odb_init_ophidiadb(oDB); //Only master process has to continue if (handle->proc_rank != 0) return OPH_ANALYTICS_OPERATOR_SUCCESS; //3 - Fill struct with the correct data char *container_name, *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if(oph_tp_parse_multiple_value_param(value, &((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys, &((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys_num)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } // retrieve sessionid value = hashtbl_get(task_tbl, OPH_ARG_SESSIONID); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_SESSIONID); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_ARG_SESSIONID); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if(!(((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->sessionid = (char *) strndup (value, OPH_TP_TASKLEN))){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_GENERIC_MEMORY_ERROR_INPUT, "sessionid" ); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } container_name = (!hashtbl_get(task_tbl, OPH_IN_PARAM_CONTAINER_INPUT) ? "NO-CONTAINER" : hashtbl_get(task_tbl, OPH_IN_PARAM_CONTAINER_INPUT)); value = hashtbl_get(task_tbl, OPH_IN_PARAM_CONTAINER_INPUT); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_CONTAINER_INPUT); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MISSING_INPUT_PARAMETER, container_name, OPH_IN_PARAM_CONTAINER_INPUT ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if(!(((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->container_input = (char *) strndup (value, OPH_TP_TASKLEN))){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MEMORY_ERROR_INPUT_NO_CONTAINER, container_name, "container output name" ); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_CWD); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_CWD); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MISSING_INPUT_PARAMETER, container_name, OPH_IN_PARAM_CWD ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if(!(((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->cwd = (char *) strndup (value, OPH_TP_TASKLEN))){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MEMORY_ERROR_INPUT_NO_CONTAINER, container_name, "input path" ); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_ARG_USERNAME); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_ARG_USERNAME); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MISSING_INPUT_PARAMETER, container_name, OPH_ARG_USERNAME ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if(!(((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->user = (char *) strndup (value, OPH_TP_TASKLEN))){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MEMORY_ERROR_INPUT_NO_CONTAINER, container_name, "username" ); } value = hashtbl_get(task_tbl, OPH_IN_PARAM_DELETE_TYPE); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_DELETE_TYPE); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MISSING_INPUT_PARAMETER, container_name, OPH_IN_PARAM_DELETE_TYPE ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if( !strcmp(value, OPH_DELETE_PHYSIC_TYPE) ){ ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->delete_type = OPH_DELETE_PHYSIC_CODE; } else{ ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->delete_type = OPH_DELETE_LOGIC_CODE; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_HIDDEN); if(!value){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_HIDDEN); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_MISSING_INPUT_PARAMETER, container_name, OPH_IN_PARAM_HIDDEN ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if( !strcmp(value, OPH_COMMON_NO_VALUE) ){ ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->hidden = 0; } else{ ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->hidden = 1; } if(oph_odb_read_ophidiadb_config_file(oDB)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to read OphidiaDB configuration\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_OPHIDIADB_CONFIGURATION_FILE, container_name ); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if( oph_odb_connect_to_ophidiadb(oDB)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to connect to OphidiaDB. Check access parameters.\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_OPHIDIADB_CONNECTION_ERROR, container_name ); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } return OPH_ANALYTICS_OPERATOR_SUCCESS; }
int env_set(HASHTBL * task_tbl, oph_operator_struct * handle) { if (!handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_NULL_OPERATOR_HANDLE); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } if (!task_tbl) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null operator string\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_NULL_TASK_TABLE); return OPH_ANALYTICS_OPERATOR_BAD_PARAMETER; } if (handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator handle already initialized\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_HANDLE_ALREADY_INITIALIZED); return OPH_ANALYTICS_OPERATOR_NOT_NULL_OPERATOR_HANDLE; } if (!(handle->operator_handle = (OPH_PRIMITIVES_LIST_operator_handle *) calloc(1, sizeof(OPH_PRIMITIVES_LIST_operator_handle)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MEMORY_ERROR_HANDLE); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } //1 - Set up struct to empty values ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->level = 0; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->func_ret = NULL; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->func_type = NULL; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->name_filter = NULL; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->limit = 0; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->id_dbms = 0; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->server = NULL; ophidiadb *oDB = &((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->oDB; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys = NULL; ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys_num = -1; //Only master process has to continue if (handle->proc_rank != 0) return OPH_ANALYTICS_OPERATOR_SUCCESS; oph_odb_init_ophidiadb(oDB); //3 - Fill struct with the correct data char *value; // retrieve objkeys value = hashtbl_get(task_tbl, OPH_IN_PARAM_OBJKEY_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_OBJKEY_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_FRAMEWORK_MISSING_INPUT_PARAMETER, OPH_IN_PARAM_OBJKEY_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (oph_tp_parse_multiple_value_param (value, &((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys, &((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys_num)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Operator string not valid\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, "Operator string not valid\n"); oph_tp_free_multiple_value_param_list(((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys, ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->objkeys_num); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_PRIMITIVE_NAME_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_PRIMITIVE_NAME_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_PRIMITIVE_NAME_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (!(((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->name_filter = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MEMORY_ERROR_INPUT, "name_filter"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_LIMIT_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_LIMIT_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_LIMIT_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->limit = (int) strtol(value, NULL, 10); if (((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->limit < 0) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Limit must be positive\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_BAD_LIMIT, OPH_IN_PARAM_LIMIT_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_VISUALIZZATION_LEVEL); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_VISUALIZZATION_LEVEL); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_VISUALIZZATION_LEVEL); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->level = (int) strtol(value, NULL, 10); if (((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->level < 1 || ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->level > 5) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Level unrecognized\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_BAD_LEVEL); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } value = hashtbl_get(task_tbl, OPH_IN_PARAM_DBMS_ID_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_DBMS_ID_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_DBMS_ID_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strcmp(value, OPH_COMMON_DEFAULT_EMPTY_VALUE) == 0) { ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->id_dbms = 0; } else { ((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->id_dbms = (int) strtol(value, NULL, 10); if (((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->id_dbms < 1) { pmesg(LOG_ERROR, __FILE__, __LINE__, "id of dbms must be positive\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_BAD_LIMIT, OPH_IN_PARAM_DBMS_ID_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } } value = hashtbl_get(task_tbl, OPH_IN_PARAM_PRIMITIVE_RETURN_TYPE_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_PRIMITIVE_RETURN_TYPE_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_PRIMITIVE_RETURN_TYPE_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strcmp(value, OPH_COMMON_ALL_FILTER) != 0) { if (!(((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->func_ret = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MEMORY_ERROR_INPUT, "func_ret"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } } value = hashtbl_get(task_tbl, OPH_IN_PARAM_PRIMITIVE_TYPE_FILTER); if (!value) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Missing input parameter %s\n", OPH_IN_PARAM_PRIMITIVE_TYPE_FILTER); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MISSING_INPUT_PARAMETER, "NO-CONTAINER", OPH_IN_PARAM_PRIMITIVE_TYPE_FILTER); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } if (strcmp(value, OPH_COMMON_ALL_FILTER) != 0) { if (!(((OPH_PRIMITIVES_LIST_operator_handle *) handle->operator_handle)->func_type = (char *) strndup(value, OPH_TP_TASKLEN))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_PRIMITIVES_LIST_MEMORY_ERROR_INPUT, "func_type"); return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } } return OPH_ANALYTICS_OPERATOR_SUCCESS; }