Fragments¶
Terms¶
- Fragment
A set of rows of one chunk’s
vertices/cell, listed in the chunk’svertex_fragments/cell. A fragment is either a contiguous range of rows or an explicit list of rows; the byte layout is on Fragment-index arrays.- Fragment address
The pair
(chunk_coords, fragment_index)that identifies a fragment within a level.fragment_indexis local to the chunk, in[0, F)for a chunk withFfragments.- Shared fragment
A fragment named by more than one object’s manifest.
Introduction¶
Fragments let a reader take part of a chunk. A chunk’s fragment index
divides its vertices/ rows into fragments. Objects name their vertices
by fragment address in their manifests.
Technical reference¶
Fragments by writer¶
Writer |
One fragment per |
|---|---|
|
Bin of the chunk, empty bins included (a range with |
|
Object present in the chunk |
|
Contiguous run of one object’s vertices within one chunk (and one attribute bin, when attribute chunking is on); an object that leaves a chunk and returns has a fragment for each visit |
|
Unbranched path of a skeleton piece within the chunk |
The core pyramid builder, at coarser levels |
Metavertex, one vertex each |
rebin_level rewrites a point-cloud chunk with one fragment per
occupied bin only, so after a rebin fragment f is no longer the bin
with linear index f.
A range fragment holds rows [start, start + count); an explicit
fragment lists its rows. Every row index is within the vertices cell.
With fragments_tile: true in the level’s attributes, each chunk’s
fragments are ranges that cover its rows in order, with no gaps or
overlaps. A reader may then take the whole cell without the fragment
index.
Row k of a chunk’s vertex_attributes/<name> cell belongs to vertex
row k, so a fragment’s attributes use the same row indices. Row f of
fragment_attributes/<name> belongs to fragment f (see
Chunk arrays).
Reading fragments¶
from zarr_vectors.building import read_fragment, read_vertex_fragment_index
from zarr_vectors.core.store import get_resolution_level, open_store
lg = get_resolution_level(open_store("scan.zarrvectors"), 0)
fidx = read_vertex_fragment_index(lg, (0, 0, 0)) # ChunkFragmentIndex
print(len(fidx)) # F
rows = fidx.indices(4) # row indices of fragment 4
vertices = read_fragment(lg, (0, 0, 0), 4) # (n, D) vertices of fragment 4
ChunkFragmentIndex (in zarr_vectors.encoding.fragments) also has
is_range(f), range(f) for a range fragment, and indices_view(f), a
view of an explicit fragment’s stored indices. read_fragment does a
byte-range read of a range fragment where the storage allows it, and
otherwise reads the whole cell. To read an object, see
Reading an object.
Validation¶
L1 warns when a level has no vertex_fragments/.
L3, for each chunk of each level:
Check |
Severity |
|---|---|
Every fragment decodes to a |
error |
A fragment holds |
warning |
With |
error |
With |
error |
Point cloud with bins and no object index: no more fragments than bins per chunk |
error |
Same: a vertex lies outside its fragment’s bin (checked in up to three chunks) |
warning |
The byte-level checks of the fragment index are on Fragment-index arrays.