Skip to content

Commit

Permalink
rename redset_filelist_get to redset_filelist_enc_get
Browse files Browse the repository at this point in the history
  • Loading branch information
adammoody committed Dec 14, 2023
1 parent f690ebc commit 40050fb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 126 deletions.
10 changes: 5 additions & 5 deletions src/redset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/redset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
);
Expand All @@ -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 */
);
Expand Down
8 changes: 4 additions & 4 deletions src/redset_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion src/redset_partner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/redset_reedsolomon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/redset_single.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
110 changes: 1 addition & 109 deletions src/redset_xor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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(&current_hashes[i]);
}

redset_free(&current_hashes);

return list;
}

/* returns a list of original files encoded by redundancy descriptor */
redset_list* redset_filelist_orig_get_xor(
const char* name,
Expand Down
6 changes: 3 additions & 3 deletions test/test_redset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 40050fb

Please sign in to comment.