# View into HDF5 dataset

**URL:** <https://discourse.julialang.org/t/view-into-hdf5-dataset/7495>\
**Category:** Performance\
**Created:** [December 4, 2017, 12:57pm UTC](https://discourse.julialang.org/t/view-into-hdf5-dataset/7495 "2017-12-04T12:57:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [December 4, 2017, 12:57pm UTC](https://discourse.julialang.org/t/view-into-hdf5-dataset/7495/1 "2017-12-04T12:57:33Z")

</div>

Is it possible, for writing, to get a “view” into part of a HDF5 dataset containing an array of some dimension?

I have a HDF5 file with some dataset, let’s say, `data`, where data is an array of some dimension. I want to increase the size of `data` over time. Specifically I increase the last dimension of `data`. So far I’m doing

```julia
    set_dims!(f["data"],(elsize...,new_count))
    f["data"][colons...,end-count+1:end] = something_here

```

where `elsize` is the size of `data` left out the last dimension and `count`/`new_count` is the size/new size of `data` in the last dimension.

However, `f["data"][colons...,end-count+1:end]` alone has many allocations because I guess it reads the (uninitialized) values in that part of `data` before writing the new data to it. For a regular array I would use a view here on the l.h.s. to avoid that copy. So, is it possible to get a “view” into part of a HDF5 dataset containing an array of some dimension to avoid those allocations?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [December 4, 2017, 4:10pm UTC](https://discourse.julialang.org/t/view-into-hdf5-dataset/7495/2 "2017-12-04T16:10:59Z")

</div>

Some relevant previous discussions here: [Appending an element to a JLD2 file](https://discourse.julialang.org/t/appending-an-element-to-a-jld2-file/6424) and here: [HDF5 speed?](https://discourse.julialang.org/t/hdf5-speed/6584) but alas, neither has an easy fix for this situation.
