HDFGroup / hdf5-json

Specification and tools for representing HDF5 in JSON
https://support.hdfgroup.org/documentation/hdf5-json/latest/
Other
73 stars 25 forks source link

String Pad value not used for String types #24

Closed jreadey closed 9 years ago

jreadey commented 9 years ago

All strings are saved as NULLPAD regardless of String Pad value.

gheber commented 9 years ago

What do you mean? Are you talking about an issue in the JSON rendering or the HDF5 generation, or what?

jreadey commented 9 years ago

When converting JSON containing a attribute or dataset with a string type, the nullpad attribute doesn't make it to the HDF5 file - the strpad value is always show up as nullpad. E.g. this json:


    "datasets": {
        "b69e2e99-cd15-11e4-bcb2-3c15c2da029e": {
            "alias": [
                "/DS1"
            ],
            "attributes": [
                {
                    "name": "A1",
                    "shape": {
                        "class": "H5S_SIMPLE",
                        "dims": [
                            4
                        ]
                    },
                    "type": {
                        "charSet": "H5T_CSET_ASCII",
                        "class": "H5T_STRING",
                        "length": 5,
                        "order": "H5T_ORDER_NONE",
                        "strPad": "H5T_STR_NULLTERM"
                    },
                    "value": [
                        "HELLO",
"Hi",
                        "HELLO ",
                        "Hihihihi"
                    ]
                }
            ],
            "shape": {
                "class": "H5S_NULL"
            },
            "type": {
                "base": "H5T_STD_I32LE",
                "class": "H5T_INTEGER"
            },
            "value": null
        }
    },
    "groups": {
        "b69d219c-cd15-11e4-a723-3c15c2da029e": {
            "alias": [
  "/"
            ],
            "links": [
                {
                    "class": "H5L_TYPE_HARD",
                    "collection": "datasets",
                    "id": "b69e2e99-cd15-11e4-bcb2-3c15c2da029e",
                    "title": "DS1"
                }
            ]
        }
    },
    "root": "b69d219c-cd15-11e4-a723-3c15c2da029e"
}

Gets converted to this HDF5:

HDF5 "out/fixed_string_attr.h5" {
GROUP "/" {
   DATASET "DS1" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  NULL
      DATA {
      }
      ATTRIBUTE "A1" {
         DATATYPE  H5T_STRING {
            STRSIZE 5;
            STRPAD H5T_STR_NULLPAD;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SIMPLE { ( 4 ) / ( 4 ) }
         DATA {
         (0): "HELLO", "Hi\000\000\000", "HELLO", "Hihih"
         }
      }
   }
}
}
jreadey commented 9 years ago

This is fixed for top-level types (but not strings that are part of a compound type).