예제 #1
0
void hdfutil::WriteString(const H5::CommonFG& group, const std::string & dsname, const std::string & str) {
    hsize_t dims[] = {1};
    H5::DataSpace dataspace(1, dims);       // 1 string
    H5::StrType   strtype  (0, str.size()); // string length
    H5::DataSet dset = group.createDataSet(dsname, strtype, dataspace, CreatePropList());
    dset.write(&str[0], strtype);
}
예제 #2
0
파일: DataSet.cpp 프로젝트: wvangeit/nix
DataSet DataSet::create(const H5::CommonFG &parent,
                        const std::string &name,
                        const H5::DataType &fileType,
                        const NDSize &size,
                        const NDSize &maxsize,
                        const NDSize &chunks,
                        bool max_size_unlimited,
                        bool guess_chunks)
{
    H5::DataSpace space;

    if (size) {
        if (maxsize) {
            space = DataSpace::create(size, maxsize);
        } else {
            space = DataSpace::create(size, max_size_unlimited);
        }
    }

    H5::DSetCreatPropList plcreate = H5::DSetCreatPropList::DEFAULT;

    if (chunks) {
        int rank = static_cast<int>(chunks.size());
        plcreate.setChunk(rank, chunks.data());
    } else if (guess_chunks) {
        NDSize guessedChunks = DataSet::guessChunking(size, fileType.getSize());
        plcreate.setChunk(static_cast<int>(guessedChunks.size()), guessedChunks.data());
    }

    H5::DataSet dset = parent.createDataSet(name, fileType, space);
    return DataSet(dset);
}
예제 #3
0
std::shared_ptr<H5::DataSet> NDArray<T, Nd>::WriteToH5(
    const H5::CommonFG& group, const std::string& dsetName) const {
  H5::DataType h5DType = GetH5DataType<T>();
  hsize_t dims[Nd]; 
  for (int i=0; i<Nd; ++i) dims[i] = mN[i]; 
  H5::DataSpace h5DSpace(Nd, dims); 
  std::shared_ptr<H5::DataSet> dset = std::make_shared<H5::DataSet>( 
      group.createDataSet(dsetName.c_str(), h5DType, h5DSpace));
  dset->write(mData, h5DType); 
  return dset;
}