int task_execute(oph_operator_struct *handle) { if (!handle || !handle->operator_handle){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_NULL_OPERATOR_HANDLE ); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } //Only master process has to continue if (handle->proc_rank != 0) return OPH_ANALYTICS_OPERATOR_SUCCESS; ophidiadb *oDB = &((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->oDB; int id_container = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container; int hidden = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->hidden; int delete_type = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->delete_type; char *container_name = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->container_input; char *cwd = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->cwd; char *user = ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->user; if(delete_type == OPH_DELETE_LOGIC_CODE) hidden = 0; //Check if user can operate on container and if container exists int permission = 0; int folder_id = 0; int container_exists = 0; //Check if input path exists if((oph_odb_fs_path_parsing("", cwd, &folder_id, NULL, oDB))) { //Check if user can work on datacube pmesg(LOG_ERROR, __FILE__, __LINE__, "Path %s doesn't exists\n", cwd); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_CWD_ERROR, container_name, cwd ); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if((oph_odb_fs_check_folder_session(folder_id, ((OPH_DELETECONTAINER_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 in this folder\n", user); logging(LOG_ERROR, __FILE__, __LINE__, OPH_GENERIC_CONTAINER_ID, OPH_LOG_OPH_DELETECONTAINER_DATACUBE_PERMISSION_ERROR, container_name, user ); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if(oph_odb_fs_retrieve_container_id_from_container_name(oDB, folder_id, container_name, hidden, &id_container)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Unknown input %s container\n", (hidden ? "hidden" : "visible")); logging(LOG_ERROR, __FILE__, __LINE__,id_container, OPH_LOG_OPH_DELETECONTAINER_NO_INPUT_CONTAINER, (hidden ? "hidden" : "visible"), container_name ); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container = id_container; if(delete_type == OPH_DELETE_PHYSIC_CODE){ if(oph_odb_fs_check_if_container_empty(oDB, id_container)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Input container isn't empty\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_DELETECONTAINER_CONTAINER_NOT_EMPTY, container_name ); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } //Remove also grid related to container dimensions if(oph_odb_dim_delete_from_grid_table(oDB, id_container)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while deleting grid related to container\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_GRID_DELETE_ERROR ); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } //Delete container and related dimensions/ dimension instances if(oph_odb_fs_delete_from_container_table(oDB, id_container)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while deleting input container\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_CONTAINER_DELETE_ERROR ); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } oph_odb_db_instance db_; oph_odb_db_instance *db = &db_; if (oph_dim_load_dim_dbinstance(db)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while loading dimension db paramters\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_DIM_LOAD ); oph_dim_unload_dim_dbinstance(db); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } if (oph_dim_connect_to_dbms(db->dbms_instance, 0)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while connecting to dimension dbms\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_DIM_CONNECT ); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } if (oph_dim_use_db_of_dbms(db->dbms_instance, db)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while opening dimension db\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_DIM_USE_DB ); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } char index_dimension_table_name[OPH_COMMON_BUFFER_LEN],label_dimension_table_name[OPH_COMMON_BUFFER_LEN]; snprintf(index_dimension_table_name,OPH_COMMON_BUFFER_LEN,OPH_DIM_TABLE_NAME_MACRO,((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container); snprintf(label_dimension_table_name,OPH_COMMON_BUFFER_LEN,OPH_DIM_TABLE_LABEL_MACRO,((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container); if (oph_dim_delete_table(db, index_dimension_table_name)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while deleting dimension table\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_DIM_TABLE_DELETE_ERROR ); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } if (oph_dim_delete_table(db, label_dimension_table_name)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while deleting dimension table\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_DELETECONTAINER_operator_handle*)handle->operator_handle)->id_input_container, OPH_LOG_OPH_DELETECONTAINER_DIM_TABLE_DELETE_ERROR ); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); return OPH_ANALYTICS_OPERATOR_MYSQL_ERROR; } oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); } else{ //Check if hidden container exists in folder if(oph_odb_fs_is_hidden_container(folder_id, container_name, oDB, &container_exists)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to check output container\n"); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_DELETECONTAINER_OUTPUT_CONTAINER_ERROR_NO_CONTAINER, container_name, container_name ); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if (container_exists) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Hidden container '%s' already exists in this folder\n", container_name); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_DELETECONTAINER_OUTPUT_CONTAINER_EXIST_ERROR, container_name, container_name ); return OPH_ANALYTICS_OPERATOR_INVALID_PARAM; } //If container exists then DELETE if(oph_odb_fs_set_container_hidden_status(id_container, 1, oDB)){ pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to delete logically container %s\n", container_name); logging(LOG_ERROR, __FILE__, __LINE__, id_container, OPH_LOG_OPH_DELETECONTAINER_UPDATE_CONTAINER_ERROR, container_name ); return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } } return OPH_ANALYTICS_OPERATOR_SUCCESS; }
int task_init(oph_operator_struct * handle) { if (!handle || !handle->operator_handle) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Null Handle\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_NULL_OPERATOR_HANDLE); return OPH_ANALYTICS_OPERATOR_NULL_OPERATOR_HANDLE; } //For error checking char id_string[4][OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE]; memset(id_string, 0, sizeof(id_string)); id_string[0][0] = 0; if (handle->proc_rank == 0) { ophidiadb *oDB = &((OPH_SPLIT_operator_handle *) handle->operator_handle)->oDB; oph_odb_datacube cube; oph_odb_cube_init_datacube(&cube); int datacube_id = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_datacube; //retrieve input datacube if (oph_odb_cube_retrieve_datacube(oDB, datacube_id, &cube)) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while retrieving input datacube\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_DATACUBE_READ_ERROR); goto __OPH_EXIT_1; } //Change the datacube name cube.id_container = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container; cube.fragmentxdb = cube.fragmentxdb * ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number; //For new fragments, tuplexfragment is floor of old tuplexfragment/split_number; only 'remainder' fragments have one more tuple ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_tuplexfragment = cube.tuplexfragment / ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number; ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_remainder = cube.tuplexfragment % ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number; //Check if split number is lower than max value of tuplexfragment number if (cube.tuplexfragment < ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to split datacube in more than %d parts.\n", cube.tuplexfragment); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_SPLITTING_NUMBER_ERROR, cube.tuplexfragment); goto __OPH_EXIT_1; } //In the OphidiaDB I stored the ceil (nearest integer >= number) value cube.tuplexfragment = (int) ceilf((float) cube.tuplexfragment / (float) ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number); //Compute new fragment relative index set int id_number; char *tmp = cube.frag_relative_index_set; //if(oph_ids_count_number_of_ids((tmp, &id_number))){ if (oph_ids_count_number_of_ids(cube.frag_relative_index_set, &id_number)) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to get total number of IDs\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_RETREIVE_IDS_ERROR); goto __OPH_EXIT_1; } //Copy fragment id relative index set if (!(((OPH_SPLIT_operator_handle *) handle->operator_handle)->fragment_ids = (char *) strndup(cube.frag_relative_index_set, OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE))) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_MEMORY_ERROR_INPUT, "fragment ids"); goto __OPH_EXIT_1; } if (oph_ids_create_new_id_string(&tmp, OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE, 1, id_number * ((OPH_SPLIT_operator_handle *) handle->operator_handle)->split_number)) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to extract fragment relative index set\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_CREATE_ID_STRING_ERROR); goto __OPH_EXIT_1; } //New fields cube.id_source = 0; cube.level++; if (((OPH_SPLIT_operator_handle *) handle->operator_handle)->description) snprintf(cube.description, OPH_ODB_CUBE_DESCRIPTION_SIZE, "%s", ((OPH_SPLIT_operator_handle *) handle->operator_handle)->description); else *cube.description = 0; //Insert new datacube if (oph_odb_cube_insert_into_datacube_partitioned_tables(oDB, &cube, &(((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube))) { oph_odb_cube_free_datacube(&cube); pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to update datacube table\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_DATACUBE_INSERT_ERROR); goto __OPH_EXIT_1; } oph_odb_cube_free_datacube(&cube); oph_odb_cubehasdim *cubedims = NULL; int number_of_dimensions = 0; int last_insertd_id = 0; int l; //Read old cube - dimension relation rows if (oph_odb_cube_retrieve_cubehasdim_list(oDB, datacube_id, &cubedims, &number_of_dimensions)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to retreive datacube - dimension relations.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_CUBEHASDIM_READ_ERROR); free(cubedims); goto __OPH_EXIT_1; } // Copy the dimension in case of output has to be saved in a new container if (((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container != ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container) { oph_odb_dimension dim[number_of_dimensions]; oph_odb_dimension_instance dim_inst[number_of_dimensions]; for (l = 0; l < number_of_dimensions; ++l) { if (oph_odb_dim_retrieve_dimension_instance(oDB, cubedims[l].id_dimensioninst, &(dim_inst[l]), datacube_id)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in reading dimension information.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_READ_ERROR); free(cubedims); goto __OPH_EXIT_1; } if (oph_odb_dim_retrieve_dimension(oDB, dim_inst[l].id_dimension, &(dim[l]), datacube_id)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in reading dimension information.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_READ_ERROR); free(cubedims); goto __OPH_EXIT_1; } } oph_odb_db_instance db_; oph_odb_db_instance *db = &db_; if (oph_dim_load_dim_dbinstance(db)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while loading dimension db paramters\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_LOAD_ERROR); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (oph_dim_connect_to_dbms(db->dbms_instance, 0)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while connecting to dimension dbms\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_CONNECT_ERROR); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (oph_dim_use_db_of_dbms(db->dbms_instance, db)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error while opening dimension db\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_USE_DB_ERROR); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } char index_dimension_table_name[OPH_COMMON_BUFFER_LEN], label_dimension_table_name[OPH_COMMON_BUFFER_LEN], operation[OPH_COMMON_BUFFER_LEN]; snprintf(index_dimension_table_name, OPH_COMMON_BUFFER_LEN, OPH_DIM_TABLE_NAME_MACRO, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container); snprintf(label_dimension_table_name, OPH_COMMON_BUFFER_LEN, OPH_DIM_TABLE_LABEL_MACRO, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container); char o_index_dimension_table_name[OPH_COMMON_BUFFER_LEN], o_label_dimension_table_name[OPH_COMMON_BUFFER_LEN]; snprintf(o_index_dimension_table_name, OPH_COMMON_BUFFER_LEN, OPH_DIM_TABLE_NAME_MACRO, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container); snprintf(o_label_dimension_table_name, OPH_COMMON_BUFFER_LEN, OPH_DIM_TABLE_LABEL_MACRO, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_container); char *dim_row, *cl_value; int compressed = 0; for (l = 0; l < number_of_dimensions; ++l) { if (!dim_inst[l].fk_id_dimension_index) { pmesg(LOG_WARNING, __FILE__, __LINE__, "Dimension FK not set in cubehasdim.\n"); break; } if (dim_inst[l].size) { // Load input labels dim_row = NULL; if (oph_dim_read_dimension_data(db, index_dimension_table_name, dim_inst[l].fk_id_dimension_index, MYSQL_DIMENSION, compressed, &dim_row) || !dim_row) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in reading a row from dimension table.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_READ_ERROR); if (dim_row) free(dim_row); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (dim_inst[l].fk_id_dimension_label) { if (oph_dim_read_dimension_filtered_data (db, label_dimension_table_name, dim_inst[l].fk_id_dimension_label, MYSQL_DIMENSION, compressed, &dim_row, dim[l].dimension_type, dim_inst[l].size) || !dim_row) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in reading a row from dimension table.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_READ_ERROR); if (dim_row) free(dim_row); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } } else { strncpy(dim[l].dimension_type, OPH_DIM_INDEX_DATA_TYPE, OPH_ODB_DIM_DIMENSION_TYPE_SIZE); // A reduced dimension is handled by indexes dim[l].dimension_type[OPH_ODB_DIM_DIMENSION_TYPE_SIZE] = 0; } // Store output labels if (oph_dim_insert_into_dimension_table (db, o_label_dimension_table_name, dim[l].dimension_type, dim_inst[l].size, dim_row, &(dim_inst[l].fk_id_dimension_label))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in inserting a new row in dimension table.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_ROW_ERROR); if (dim_row) free(dim_row); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (dim_row) free(dim_row); // Set indexes snprintf(operation, OPH_COMMON_BUFFER_LEN, MYSQL_DIM_INDEX_ARRAY, OPH_DIM_INDEX_DATA_TYPE, 1, dim_inst[l].size); dim_row = NULL; if (oph_dim_read_dimension_data(db, index_dimension_table_name, dim_inst[l].fk_id_dimension_index, operation, compressed, &dim_row) || !dim_row) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in reading a row from dimension table.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_READ_ERROR); if (dim_row) free(dim_row); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } // Store output indexes if (oph_dim_insert_into_dimension_table (db, o_index_dimension_table_name, OPH_DIM_INDEX_DATA_TYPE, dim_inst[l].size, dim_row, &(dim_inst[l].fk_id_dimension_index))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in inserting a new row in dimension table.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_ROW_ERROR); if (dim_row) free(dim_row); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (dim_row) free(dim_row); } else dim_inst[l].fk_id_dimension_index = dim_inst[l].fk_id_dimension_label = 0; dim_inst[l].id_grid = 0; cl_value = NULL; if (oph_odb_dim_insert_into_dimensioninstance_table (oDB, &(dim_inst[l]), &(cubedims[l].id_dimensioninst), ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube, dim[l].dimension_name, cl_value)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error in inserting a new dimension instance\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_DIM_INSTANCE_STORE_ERROR); if (cl_value) free(cl_value); oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); free(cubedims); goto __OPH_EXIT_1; } if (cl_value) free(cl_value); } oph_dim_disconnect_from_dbms(db->dbms_instance); oph_dim_unload_dim_dbinstance(db); } //Write new cube - dimension relation rows for (l = 0; l < number_of_dimensions; l++) { //Change iddatacube in cubehasdim cubedims[l].id_datacube = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube; if (oph_odb_cube_insert_into_cubehasdim_table(oDB, &(cubedims[l]), &last_insertd_id)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to insert new datacube - dimension relations.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_CUBEHASDIM_INSERT_ERROR); free(cubedims); goto __OPH_EXIT_1; } } free(cubedims); if (oph_odb_meta_copy_from_cube_to_cube (oDB, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_datacube, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_user)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to copy metadata.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_GENERIC_METADATA_COPY_ERROR); goto __OPH_EXIT_1; } last_insertd_id = 0; oph_odb_task new_task; new_task.id_outputcube = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube; new_task.id_job = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_job; strncpy(new_task.operator, handle->operator_type, OPH_ODB_CUBE_OPERATOR_SIZE); new_task.operator[OPH_ODB_CUBE_OPERATOR_SIZE] = 0; memset(new_task.query, 0, OPH_ODB_CUBE_OPERATION_QUERY_SIZE * sizeof(char)); if (!(new_task.id_inputcube = (int *) malloc(1 * sizeof(int)))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_MEMORY_ERROR_STRUCT, "task"); goto __OPH_EXIT_1; } new_task.id_inputcube[0] = ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_datacube; new_task.input_cube_number = 1; if (oph_odb_cube_insert_into_task_table(oDB, &new_task, &last_insertd_id)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Unable to insert new task.\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_TASK_INSERT_ERROR, new_task.operator); free(new_task.id_inputcube); goto __OPH_EXIT_1; } free(new_task.id_inputcube); strncpy(id_string[0], ((OPH_SPLIT_operator_handle *) handle->operator_handle)->fragment_ids, OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE); snprintf(id_string[1], OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE, "%d", ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube); snprintf(id_string[2], OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE, "%d", ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_tuplexfragment); snprintf(id_string[3], OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE, "%d", ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_remainder); } __OPH_EXIT_1: //Broadcast to all other processes the fragment relative index MPI_Bcast(id_string, 4 * OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE, MPI_CHAR, 0, MPI_COMM_WORLD); //Check if sequential part has been completed if (id_string[0][0] == 0) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Master procedure or broadcasting has failed\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_MASTER_TASK_INIT_FAILED); ((OPH_SPLIT_operator_handle *) handle->operator_handle)->execute_error = 1; return OPH_ANALYTICS_OPERATOR_UTILITY_ERROR; } if (handle->proc_rank != 0) { if (!(((OPH_SPLIT_operator_handle *) handle->operator_handle)->fragment_ids = (char *) strndup(id_string[0], OPH_ODB_CUBE_FRAG_REL_INDEX_SET_SIZE))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error allocating memory\n"); logging(LOG_ERROR, __FILE__, __LINE__, ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_input_container, OPH_LOG_OPH_SPLIT_MEMORY_ERROR_INPUT, "fragment ids"); ((OPH_SPLIT_operator_handle *) handle->operator_handle)->execute_error = 1; return OPH_ANALYTICS_OPERATOR_MEMORY_ERR; } ((OPH_SPLIT_operator_handle *) handle->operator_handle)->id_output_datacube = (int) strtol(id_string[1], NULL, 10); ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_tuplexfragment = (int) strtol(id_string[2], NULL, 10); ((OPH_SPLIT_operator_handle *) handle->operator_handle)->new_remainder = (int) strtol(id_string[3], NULL, 10); } return OPH_ANALYTICS_OPERATOR_SUCCESS; }