Skip to content

Commit

Permalink
ckp
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisHeimbigner committed Dec 6, 2024
1 parent fd05809 commit 7cf8444
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
37 changes: 26 additions & 11 deletions libnczarr/zformat2.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,13 @@ ZF2_upload_grp(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, struct ZOBJ* zobj)
if((stat=NCZ_uploadjson(zinfo->map,key,zobj->jobj))) goto done;
nullfree(key); key = NULL;

/* build ZATTRS path */
if((stat = nczm_concat(fullpath,Z2ATTRS,&key))) goto done;
/* Write to map */
if((stat=NCZ_uploadjson(zinfo->map,key,zobj->jatts))) goto done;
nullfree(key); key = NULL;
if(zobj->jatts != NULL) {
/* build ZATTRS path */
if((stat = nczm_concat(fullpath,Z2ATTRS,&key))) goto done;
/* Write to map */
if((stat=NCZ_uploadjson(zinfo->map,key,zobj->jatts))) goto done;
nullfree(key); key = NULL;
}

done:
nullfree(fullpath);
Expand All @@ -763,7 +765,7 @@ ZF2_upload_var(NC_FILE_INFO_T* file, NC_VAR_INFO_T* var, struct ZOBJ* zobj)
if((stat=NCZ_uploadjson(zinfo->map,key,zobj->jobj))) goto done;
nullfree(key); key = NULL;

if(zobj->jatts) {
if(zobj->jatts != NULL) {
/* build ZATTRS path */
if((stat = nczm_concat(fullpath,Z2ATTRS,&key))) goto done;
/* Write to map */
Expand Down Expand Up @@ -1271,31 +1273,44 @@ ZF2_searchobjects(NC_FILE_INFO_T* file, NC_GRP_INFO_T* grp, NClist* varnames, NC
size_t i;
NCZ_FILE_INFO_T* zfile = (NCZ_FILE_INFO_T*)file->format_file_info;
char* grpkey = NULL;
char* subgrpkey = NULL;
char* varkey = NULL;
char* zarray = NULL;
char* zgroup = NULL;
NClist* matches = nclistnew();

/* Compute the key for the grp */
if((stat = NCZ_grpkey(grp,&grpkey))) goto done;
/* Get the map and search group */
if((stat = nczmap_list(zfile->map,grpkey,matches))) goto done;
if((stat = nczmap_list(zfile->map,grpkey,matches))) goto done; /* Shallow listing */
/* Search grp for group-level .zxxx and for var-level .zxxx*/
for(i=0;i<nclistlength(matches);i++) {
const char* name = nclistget(matches,i);
if(name[0] == NCZM_DOT) continue; /* zarr/nczarr specific */
/* See if name/.zarray exists */
if(name[0] == NCZM_DOT) continue; /* current group components */
/* See if name is an array by testing for name/.zarray exists */
if((stat = nczm_concat(grpkey,name,&varkey))) goto done;
if((stat = nczm_concat(varkey,Z2ARRAY,&zarray))) goto done;
if((stat = nczmap_exists(zfile->map,zarray)) == NC_NOERR)
if((stat = nczmap_exists(zfile->map,zarray)) == NC_NOERR) {
nclistpush(varnames,strdup(name));
} else {
/* See if name is a group by testing for name/.zgroup exists */
if((stat = nczm_concat(grpkey,name,&subgrpkey))) goto done;
if((stat = nczm_concat(varkey,Z2GROUP,&zgroup))) goto done;
if((stat = nczmap_exists(zfile->map,zgroup)) == NC_NOERR)
nclistpush(subgrpnames,strdup(name));
}
stat = NC_NOERR;
nullfree(varkey); varkey = NULL;
nullfree(zarray); zarray = NULL;
nullfree(subgrpkey); subgrpkey = NULL;
nullfree(zgroup); zgroup = NULL;
}

done:
nullfree(grpkey);
nullfree(varkey);
nullfree(zarray);
nullfree(zgroup);
nullfree(subgrpkey);
nclistfreeall(matches);
return stat;
}
Expand Down
8 changes: 4 additions & 4 deletions libnczarr/zmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ implementing the key/object model.
The list function takes a prefix path which has a key syntax (see
above). The set of legal keys is the set of keys such that the key
references a content-bearing object -- e.g. /x/y/.zarray or
/.zgroup. Essentially this is the set of keys pointing to the leaf
objects of the tree of keys constituting a dataset. This set
potentially limits the set of keys that need to be examined during
search.
/.zgroup or /g/.zgroup. Essentially this is the set of keys pointing
to the leaf objects of the tree of keys constituting a dataset.
This set potentially limits the set of keys that need to be examined
during search.
The list function has two primary purposes:
1. Support reading of pure zarr datasets (because they do not explicitly track their contents).
Expand Down
5 changes: 3 additions & 2 deletions libnczarr/zmap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ zfileclose(NCZMAP* map, int delete)
}

/*
Return a list of simple names immediately "below" a specified prefix key.
Return a list of simple names immediately "below" a specified prefix key
(i.e. shallow listing).
In theory, the returned list should be sorted in lexical order,
but it possible that it is not.
The prefix key is not included.
Expand Down Expand Up @@ -962,7 +963,7 @@ platformdircontent(const char* canonpath, NClist* contents)
default: goto done;
}

/* We need to process the path to make it work with FindFirstFile */
/* We need to process the path to make it work with Windows FindFirstFile */
len = strlen(canonpath);
/* Need to terminate path with '/''*' */
ffpath = (char*)malloc(len+2+1);
Expand Down
2 changes: 1 addition & 1 deletion libnczarr/zsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ ncz_decode_file(NC_FILE_INFO_T* file)
root = file->root_grp;
if((stat = NCZF_download_grp(file, root, &zobj))) goto done;

/* Decode the group metadata to get superblock */
/* Decode the group metadata to get only the superblock */
if((stat = NCZF_decode_group(file,root,&zobj,NULL,(NCjson**)&jsuper))) goto done;

if(jsuper != NULL) {
Expand Down

0 comments on commit 7cf8444

Please sign in to comment.