Binary Data (Blobs)¶
Blobs provide efficient binary data storage with typed layouts and zero-copy NumPy integration.
When to use: Use blobs for binary data like images, meshes, and raw buffers.
BlobArray for typed arrays, BlobPack for structured multi-region data.
Quick Start¶
from dsviper import BlobLayout, BlobArray, BlobPack, BlobPackDescriptor
import numpy as np
# Typed array: 100 vec3 positions (float, 3 components)
layout = BlobLayout('float', 3)
positions = BlobArray(layout, 100)
# Zero-copy NumPy access
np_view = np.array(positions, copy=False)
np_view[0] = [1.0, 2.0, 3.0] # Modifies original
# Structured blob: mesh with multiple regions
desc = BlobPackDescriptor()
desc.add_region('positions', BlobLayout('float', 3), 100)
desc.add_region('normals', BlobLayout('float', 3), 100)
desc.add_region('indices', BlobLayout('uint', 3), 50)
mesh = BlobPack(desc)
# Access region as NumPy array
pos_np = np.array(mesh['positions'], copy=False)
Choosing the Right Class¶
Data Type |
Class |
Example |
|---|---|---|
Raw bytes |
|
|
Typed array |
|
|
Multiple regions |
|
Mesh with pos/normals/indices |
Database reference |
|
SHA-1 hash reference |
Large files (>2GB) |
|
Streaming upload |
Core Classes¶
A class used to describe the layout of the element in a blob. |
|
A class used to reinterpret the blob of the internal BlobView as an array<blob_layout.data_type>. |
|
A class used to implements memory regions in one blob. |
|
A class used to describe binary regions. |
|
A class used for a region that implement the buffer protocol. |
Blob I/O¶
A class used to copy a huge blob (> 2GB) to a database. |
|
A class used to encode a blob. |
|
A class used to represent the layout of one element. |
|
A class used to interpret the bytes of a blob from the layout. |
|
A class used to represent the data associated with a blob during the synchronization of two databases. |
Database Integration¶
An interface used to retreive blobs from a persistence layer. |
|
A class used to represent various information of a blob in the persistence layer. |
|
A class used to represent the statistics about blobs. |