Hi,

How do I create a 2 dimensional dataset for strings in Java?  I have it
working fine for integers, but once I change the type to
HDF5Constants.H5T_C_S1, the dataset seems to become a 1D array with a size
of the specified Y-dimension.  I copied and pasted my code below for anyone
who can point out what I'm doing wrong.  

Thanks in advance!

                final int RANK = 2;
        int filespace_id = -1;
        int type_id = -1;
        int dcpl_id = -1;
        int dataset_id = -1;
        Dataset dset = null;
        final int DIM_X = 32;
        final int DIM_Y = 100;
        final int CHUNK_X = 4;
        final int CHUNK_Y = 8;
        long[] chunk_dims = {  CHUNK_X, CHUNK_Y };
        long[] dims = { DIM_X, DIM_Y };
        
        final int NDIMS = 2;
        
        // Create dataspace. 
        try {
            filespace_id = H5.H5Screate_simple(RANK, dims, maxdims);
            type_id = H5.H5Tcopy(HDF5Constants.H5T_C_S1);
            H5.H5Tset_size(type_id, HDF5Constants.H5T_VARIABLE);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        
        // Create the dataset creation property list, add the gzip
compression
        // filter.
        try {
            dcpl_id = H5.H5Pcreate(HDF5Constants.H5P_DATASET_CREATE);
            if(dcpl_id >= 0){
                H5.H5Pset_deflate(dcpl_id, 9);
                // Set the chunk size.
                H5.H5Pset_chunk(dcpl_id, NDIMS, chunk_dims);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        
        // Create the dataset.
        try {
            if ((file_id >= 0) && (filespace_id >= 0) && (dcpl_id >= 0))
                  dataset_id = H5.H5Dcreate(file_id, DATASETNAME,
                          type_id, filespace_id, HDF5Constants.H5P_DEFAULT,
dcpl_id, HDF5Constants.H5P_DEFAULT);
              dset = new H5ScalarDS(file, DATASETNAME, "/");
              Group pgroup = (Group) file.get("/");
              pgroup.addToMemberList(dset);
        }
        catch (Exception e) {
              e.printStackTrace();
        }
            // End access to the dataset and release resources used by it.
        try {
            if (dcpl_id >= 0)
                H5.H5Pclose(dcpl_id);
            if (type_id >= 0)
                  H5.H5Tclose(type_id);
            if (dataset_id >= 0)
                  dset.close(dataset_id);
            if (filespace_id >= 0)
                  H5.H5Sclose(filespace_id);
        }
          catch (Exception e) {
              e.printStackTrace();
        }




--
View this message in context: 
http://hdf-forum.184993.n3.nabble.com/Cannot-create-2D-datasets-for-strings-tp4025908.html
Sent from the hdf-forum mailing list archive at Nabble.com.

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Reply via email to