diff --git a/src/redset.c b/src/redset.c index 3423592..0db6304 100644 --- a/src/redset.c +++ b/src/redset.c @@ -1240,7 +1240,7 @@ static int redset_from_dir( #endif /* returns a list of files added by redundancy descriptor */ -redset_filelist redset_filelist_get( +redset_filelist redset_filelist_enc_get( const char* name, const redset dvp) { @@ -1257,16 +1257,16 @@ redset_filelist redset_filelist_get( /* get files added by redundancy method */ switch (d->type) { case REDSET_COPY_SINGLE: - tmp = redset_filelist_get_single(name, d); + tmp = redset_filelist_enc_get_single(name, d); break; case REDSET_COPY_PARTNER: - tmp = redset_filelist_get_partner(name, d); + tmp = redset_filelist_enc_get_partner(name, d); break; case REDSET_COPY_XOR: - tmp = redset_filelist_get_xor(name, d); + tmp = redset_filelist_enc_get_xor(name, d); break; case REDSET_COPY_RS: - tmp = redset_filelist_get_rs(name, d); + tmp = redset_filelist_enc_get_rs(name, d); break; } diff --git a/src/redset.h b/src/redset.h index 22ab179..f97bf2a 100644 --- a/src/redset.h +++ b/src/redset.h @@ -156,7 +156,7 @@ int redset_unapply( ); /** return list of files added by redundancy scheme */ -redset_filelist redset_filelist_get( +redset_filelist redset_filelist_enc_get( const char* name, /**< [IN] - path/filename prefix to prepend to redset metadata files */ const redset d /**< [IN] - redundancy descriptor associated with above path */ ); @@ -167,7 +167,7 @@ redset_filelist redset_filelist_orig_get( const redset d /**< [IN] - redundancy descriptor associated with above path */ ); -/** free file list allocated by call to redset_filelist_get */ +/** free file list allocated by call to redset_filelist_*_get */ int redset_filelist_release( redset_filelist* plist /**< [INOUT] - address of pointer to list to be freed, sets pointer to NULL */ ); diff --git a/src/redset_internal.h b/src/redset_internal.h index 6c99772..c289bff 100644 --- a/src/redset_internal.h +++ b/src/redset_internal.h @@ -267,22 +267,22 @@ int redset_unapply_rs( ); -redset_list* redset_filelist_get_single( +redset_list* redset_filelist_enc_get_single( const char* name, redset_base* d ); -redset_list* redset_filelist_get_partner( +redset_list* redset_filelist_enc_get_partner( const char* name, redset_base* d ); -redset_list* redset_filelist_get_xor( +redset_list* redset_filelist_enc_get_xor( const char* name, redset_base* d ); -redset_list* redset_filelist_get_rs( +redset_list* redset_filelist_enc_get_rs( const char* name, redset_base* d ); diff --git a/src/redset_partner.c b/src/redset_partner.c index 209d4aa..52d986a 100644 --- a/src/redset_partner.c +++ b/src/redset_partner.c @@ -1034,7 +1034,7 @@ int redset_unapply_partner( } /* returns a list of files added by redundancy descriptor */ -redset_list* redset_filelist_get_partner( +redset_list* redset_filelist_enc_get_partner( const char* name, redset_base* d) { diff --git a/src/redset_reedsolomon.c b/src/redset_reedsolomon.c index 2b4fa34..2221caf 100644 --- a/src/redset_reedsolomon.c +++ b/src/redset_reedsolomon.c @@ -1128,7 +1128,7 @@ int redset_unapply_rs( } /* returns a list of files added by redundancy descriptor */ -redset_list* redset_filelist_get_rs( +redset_list* redset_filelist_enc_get_rs( const char* name, redset_base* d) { diff --git a/src/redset_single.c b/src/redset_single.c index f9ad813..e423e8f 100644 --- a/src/redset_single.c +++ b/src/redset_single.c @@ -170,7 +170,7 @@ int redset_unapply_single( } /* returns a list of files added by redundancy descriptor */ -redset_list* redset_filelist_get_single( +redset_list* redset_filelist_enc_get_single( const char* name, redset_base* d) { diff --git a/src/redset_xor.c b/src/redset_xor.c index 2a2c5c1..8c073f0 100644 --- a/src/redset_xor.c +++ b/src/redset_xor.c @@ -768,7 +768,7 @@ int redset_unapply_xor( } /* returns a list of files added by redundancy descriptor */ -redset_list* redset_filelist_get_xor( +redset_list* redset_filelist_enc_get_xor( const char* name, redset_base* d) { @@ -781,114 +781,6 @@ redset_list* redset_filelist_get_xor( return list; } -redset_filelist redset_filelist_get_data( - int num, - const char** files) -{ - int total_ranks = 0; - int total_files = 0; - kvtree** current_hashes = NULL; - - int i; - for (i = 0; i < num; i++) { - /* open the current file */ - const char* file = files[i]; - int fd = redset_open(file, O_RDONLY); - if (fd < 0) { - redset_err("Opening XOR file for reading: redset_open(%s) errno=%d %s @ %s:%d", - file, errno, strerror(errno), __FILE__, __LINE__ - ); - return NULL; - } - - /* read header from the file */ - kvtree* header = kvtree_new(); - kvtree_read_fd(file, fd, header); - - /* if this is our first file, get number of ranks in the redudancy group */ - if (current_hashes == NULL) { - /* read number of items in the redudancy group */ - kvtree* group_hash = kvtree_get(header, REDSET_KEY_COPY_XOR_GROUP); - kvtree_util_get_int(group_hash, REDSET_KEY_COPY_XOR_GROUP_RANKS, &total_ranks); - - /* allocate a spot to hold the file info for each member */ - current_hashes = (kvtree**) REDSET_MALLOC(total_ranks * sizeof(kvtree*)); - - /* initialize all spots to NULL so we know whether we've already read it in */ - int j; - for (j = 0; j < total_ranks; j++) { - current_hashes[j] = NULL; - } - } - - /* get file info for each rank we can pull from this header */ - kvtree* desc_hash = kvtree_get(header, REDSET_KEY_COPY_XOR_DESC); - kvtree_elem* rank_elem; - for (rank_elem = kvtree_elem_first(desc_hash); - rank_elem != NULL; - rank_elem = kvtree_elem_next(rank_elem)) - { - /* get the rank of the file info */ - int rank = kvtree_elem_key_int(rank_elem); - - /* copy to our array if it's not already set */ - if (current_hashes[rank] == NULL) { - /* not set, get pointer to file info */ - kvtree* rank_hash = kvtree_elem_hash(rank_elem); - - /* allocate an empty kvtree and copy the file info */ - current_hashes[rank] = kvtree_new(); - kvtree_merge(current_hashes[rank], rank_hash); - - /* get number of files for this rank */ - int numfiles = 0; - kvtree_util_get_int(rank_hash, "FILES", &numfiles); - - /* sum the files to our running total across all ranks */ - total_files += numfiles; - } - } - - kvtree_delete(&header); - - redset_close(file, fd); - } - - /* allocate a list to hold files for all ranks */ - redset_list* list = (redset_list*) REDSET_MALLOC(sizeof(redset_list)); - - list->count = total_files; - list->files = (const char**) REDSET_MALLOC(total_files * sizeof(char*)); - - int idx = 0; - for (i = 0; i < total_ranks; i++) { - if (current_hashes[i] == NULL) { - /* ERROR! */ - } - - /* get number of files for this rank */ - int numfiles = 0; - kvtree_util_get_int(current_hashes[i], "FILES", &numfiles); - - int j; - kvtree* files_hash = kvtree_get(current_hashes[i], "FILE"); - for (j = 0; j < numfiles; j++) { - /* get file name of this file */ - kvtree* index_hash = kvtree_getf(files_hash, "%d", i); - kvtree_elem* elem = kvtree_elem_first(index_hash); - const char* filename = kvtree_elem_key(elem); - list->files[idx] = strdup(filename); - idx++; - } - - kvtree_delete(¤t_hashes[i]); - } - - redset_free(¤t_hashes); - - return list; -} - /* returns a list of original files encoded by redundancy descriptor */ redset_list* redset_filelist_orig_get_xor( const char* name, diff --git a/test/test_redset.c b/test/test_redset.c index a386bba..dbba823 100644 --- a/test/test_redset.c +++ b/test/test_redset.c @@ -253,7 +253,7 @@ int check_for_redundancy_files(int mode, const char* path, redset d) int rc = 0; /* get list of redundancy files */ - redset_filelist list = redset_filelist_get(path, d); + redset_filelist list = redset_filelist_enc_get(path, d); if (list == NULL) { ABORT("Failed to get list of redundancy files"); } @@ -288,7 +288,7 @@ int delete_redundancy_files(int mode, const char* path, redset d) int rc = 0; /* get list of redundancy files */ - redset_filelist list = redset_filelist_get(path, d); + redset_filelist list = redset_filelist_enc_get(path, d); if (list == NULL) { ABORT("Failed to get list of redundancy files"); } @@ -358,7 +358,7 @@ int test_unapply(int mode, const char* path, redset d, MPI_Comm comm) } /* get list of redundancy files */ - redset_filelist list = redset_filelist_get(path, d); + redset_filelist list = redset_filelist_enc_get(path, d); if (list == NULL) { ABORT("Failed to get list of redundancy files"); }