Skip to content

CellRandomAccess unexpectedly loads neighboring cells #252

@igorpisarev

Description

@igorpisarev

Let's say a CellImg is defined with cell size [2,2,2], and we want to iterate from min=[4,4,4] to max=[5,5,5] in this image. This interval covers exactly one cell at grid position [2,2,2].
However, looping over this interval using

Views.iterable(Views.interval(cellImg, cell)).cursor()

unexpectedly leads to loading 3 extra cells:

  • the very first one at (0,0,0,..) when the random access is initialized
  • the previous cell in the iteration order when the cursor is initialized at the "-1" pixel
  • the next cell in the iteration order when the cursor reaches the end of the line

This behavior becomes problematic in a workflow when the cells are read and written concurrently as it subtly introduces race conditions.

I also created an example demonstrating this behavior using N5 as a cell storage backend: https://gist.github.com/igorpisarev/591212a26228e4ac7cb482b0134217a1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions