Metalayers#

Metalayers are meta-information that can be attached to super-chunks. They can also be serialized to disk.

struct blosc2_metalayer#

This struct is meant to store metadata information inside a blosc2_schunk, allowing to specify, for example, how to interpret the contents included in the schunk.

Public Members

char *name#

The metalayer identifier for Blosc client (e.g. Blosc2 NDim).

uint8_t *content#

The serialized (msgpack preferably) content of the metalayer.

int32_t content_len#

The length in bytes of the content.

Fixed-length metalayers#

static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name)#

Find whether the schunk has a metalayer or not.

Parameters:
  • schunk – The super-chunk from which the metalayer will be checked.

  • name – The name of the metalayer to be checked.

Returns:

If successful, return the index of the metalayer. Else, return a negative value.

int blosc2_meta_add(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len)#

Add content into a new metalayer.

Parameters:
  • schunk – The super-chunk to which the metalayer should be added.

  • name – The name of the metalayer.

  • content – The content of the metalayer.

  • content_len – The length of the content.

Returns:

If successful, the index of the new metalayer. Else, return a negative value.

int blosc2_meta_update(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len)#

Update the content of an existing metalayer.

Parameters:
  • schunk – The frame containing the metalayer.

  • name – The name of the metalayer to be updated.

  • content – The new content of the metalayer.

  • content_len – The length of the content.

Returns:

If successful, the index of the metalayer. Else, return a negative value.

Note

Contrarily to blosc2_meta_add the updates to metalayers are automatically serialized into a possible attached frame.

static inline int blosc2_meta_get(blosc2_schunk *schunk, const char *name, uint8_t **content, int32_t *content_len)#

Get the content out of a metalayer.

Parameters:
  • schunk – The frame containing the metalayer.

  • name – The name of the metalayer.

  • content – The pointer where the content will be put.

  • content_len – The length of the content.

Returns:

If successful, the index of the new metalayer. Else, return a negative value.

Note

This function is inlined and available even when not linking with libblosc2.

Warning

The **content receives a malloc’ed copy of the content. The user is responsible of freeing it.

Variable-length metalayers#

int blosc2_vlmeta_exists(blosc2_schunk *schunk, const char *name)#

Find whether the schunk has a variable-length metalayer or not.

Parameters:
  • schunk – The super-chunk from which the variable-length metalayer will be checked.

  • name – The name of the variable-length metalayer to be checked.

Returns:

If successful, return the index of the variable-length metalayer. Else, return a negative value.

int blosc2_vlmeta_add(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len, blosc2_cparams *cparams)#

Add content into a new variable-length metalayer.

Parameters:
  • schunk – The super-chunk to which the variable-length metalayer should be added.

  • name – The name of the variable-length metalayer.

  • content – The content to be added.

  • content_len – The length of the content.

  • cparams – The parameters for compressing the variable-length metalayer content. If NULL, the BLOSC2_CPARAMS_DEFAULTS will be used.

Returns:

If successful, the index of the new variable-length metalayer. Else, return a negative value.

int blosc2_vlmeta_update(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len, blosc2_cparams *cparams)#

Update the content of an existing variable-length metalayer.

Parameters:
  • schunk – The super-chunk containing the variable-length metalayer.

  • name – The name of the variable-length metalayer to be updated.

  • content – The new content of the variable-length metalayer.

  • content_len – The length of the content.

  • cparams – The parameters for compressing the variable-length metalayer content. If NULL, the BLOSC2_CPARAMS_DEFAULTS will be used.

Returns:

If successful, the index of the variable-length metalayer. Else, return a negative value.

int blosc2_vlmeta_get(blosc2_schunk *schunk, const char *name, uint8_t **content, int32_t *content_len)#

Get the content out of a variable-length metalayer.

Parameters:
  • schunk – The super-chunk containing the variable-length metalayer.

  • name – The name of the variable-length metalayer.

  • content – The pointer where the content will be put.

  • content_len – The pointer where the length of the content will be put.

Returns:

If successful, the index of the new variable-length metalayer. Else, return a negative value.

Warning

The **content receives a malloc’ed copy of the content. The user is responsible of freeing it.

int blosc2_vlmeta_delete(blosc2_schunk *schunk, const char *name)#

Delete the variable-length metalayer from the super-chunk.

Parameters:
  • schunk – The super-chunk containing the variable-length metalayer.

  • name – The name of the variable-length metalayer.

Returns:

If successful, the number of the variable-length metalayers in the super-chunk. Else, return a negative value.

int blosc2_vlmeta_get_names(blosc2_schunk *schunk, char **names)#

Get a list of all the variable-length metalayer names.

Parameters:
  • schunk – The super-chunk containing the variable-length metalayers.

  • names – The pointer to a char** to store the name pointers. This should be of size schunk->nvlmetalayers * sizeof(char).

Returns:

The number of the variable-length metalayers in the super-chunk. This cannot fail unless the user does not pass a names which is large enough to keep pointers to all names, in which case funny things (seg faults and such) will happen.