Skip to content

High level topics #172

Description

@bogovicj

What is the preferred workflow for writing a region in an image?

When a developer doesn't know if a dataset is sharded or not, how should they go about efficiently writing
data with N5 (or reading, but its easier).

  • assume sharded? use readShard / writeShard
  • use readBlocks / writeBlocks
  • use readBlock / writeBlock and N5 API does some tricks under-the-covers
    • NO in my (JB, CH) opinion.

goals

  • behavior must be correct even when using "wrong" access methods 🚫 🐛s
  • shard methods will have some, but low overhead when not-sharded, and efficient when sharded
  • block methods will be conservative and potentially not efficient when sharded
  • blocks should use shard information when possible, fall back to block when not

API methods

Strongly confident that we will add the methods:

  • N5Reader.readBlocks
  • N5Writer.writeBlocks

Somewhat confident that we will add the methods:

  • N5Reader.readShard

  • N5Writer.writeShard

  • In general, do we include shard specific analogues for things that cover blocks now

    • Do we include isSharded for N5Reader
    • Do we include a way to get shard size from DatasetAttributes?
    • Getting a NestedGrid from DatasetAttributes is another possibility
  • DatasetAttributes.groupBlocks

    • takes block positions and returns a map or list-of-lists that groups blocks by shard
    • perhaps belongs in another class / interface (for future-proofing, e.g. nesting, do we care at this level? Likely not, most important is the new separation of parallelizable unit vs compressable unit, only two things)
  • DatasetAttributes.blockIterator

  • ShardAccess object could be how we handle read/write "policy" in the future (how is this different from LockedFileChannel/ ReadData?)

    • in general, a way to over-ride the default read/write behavior (?)
  • use auto-closable property readers and writers to flush things

    • probably not now, but later after we implement policies

shard method details

What type of object does readShard return? and what can one do with it?

  • A ReadData
  • A Shard object with
  • A ShardAccess (if it exists)

Default behaviors

  • readBlock for a sharded dataset:
    • read the shard index
    • partial read the block if the backend allows it
  • writeBlock / removeBlock for a sharded dataset:
    • reads the whole shard (if it exists)
    • adds / replaces / deletes the block as necessary
    • updates the index as necessary
    • writes / deletes the whole shard as necessary
  • writeBlocks should be efficient in the sharded context
    • requires grouping blocks by shard (see above)
  • readBlocks cost of ignoring shard is less bad that writeBlocks
    • but it could (maybe should?) be smarter than naiive case when sharded
      • e.g. only read shard index once per shard
      • heuristic for aggregating reads
      • we've already started work on this

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions