---
tags: GraphBLAS Proposals
---
# GrB_Type_new proposed changes
Decisions about the string (null-terminated, ownership, max size, etc) will match whatever decisions are made for Will K's generic get/set proposal.
## 2.1 Spec
- **GrB_Type_new**(GrB_Type *t, size_t size)
- The name is set to empty string
- Attempts to retrieve the name will work, but will return empty string
- **GrB_Type_new_v3**(GrB_Type *t, size_t size, const char *name)
- Name must be non-empty
- Name must be unique (meaning some kind of global type registry); need to decide on error to raise
- **GrB_Matrix_Type**(GrB_Type *t, const GrB_Matrix A)
- **GrB_Vector_Type**(GrB_Type *t, const GrB_Vector v)
- **GrB_Scalar_Type**(GrB_Type *t, const GrB_Scalar s)
- **GrB_Matrix_deserialize**(Matrix *A, Type d, void *data, GrB_Index length)
- Can only use this method if the provided type has no name (i.e. empty string). This is for backward compatibility.
- **GrB_Matrix_deserialize_v3**(Matrix *A, void *data, GrB_Index length, Descriptor desc)
- The serialized data must know the name of its serialized type. That name must be in the global registry. The deserialization doesn't recreate the Type from scratch. It merely links the existing type with the reconstituted object based on the name. Probably do a size check for good measure, just to be safe.
- Should we add Descriptor? Need a way to specify number of threads
- **GrB_deserialize_type_name**(char *name, void *data)
- **GrB_Matrix_serialize_v3**(void *data, GrB_Index *size, GrB_Matrix A, Descriptor desc)
- When serializing, include the type name. In the case of an unnamed type, include an empty string for the name.
- **GrB_Type_equal**(bool *, GrB_Type left, GrB_Type right)
- Set bool param to True if left and right are the same type; False otherwise
- **GrB_Type_from_name**(GrB_Type *type, const char *name)
- Raise InvalidValue error if name not in registry
### Questions:
Does the user free the Type after getting it and using it to determine which semiring to use? Yes
Should we be able to ask a serialized blob the name of its type? Probably
## 3.0 Spec
- **GrB_Type_new**(GrB_Type *t, size_t size, const char *name)
- This becomes the mainline function with required name
- **GrB_Matrix_deserialize**(Matrix *A, void *data, GrB_Index length)
- This becomes the mainline function. It will not be able to deserialize an object with an unnamed type.
- **GrB_Matrix_serialize**(void *data, GrB_Index *size, GrB_Matrix A, Descriptor desc)
## Connection to Will K proposal for generic get/set
To retrieve the type name, use the get/set mechanism that Will K is designing. Something like `GrB_Type_get(my_type, GrB_Name_Size, int *size)` will get the size of the name. Then `GrB_Type_get(my_type, GrB_Name, char *arr, size)` will retrieve the name.
The same mechanism can return the size of the Type.
This mechanism will be introduced in the 2.1 spec and will continue to be used in 3.0.
**Note**: Attempting to set the name using `GrB_Type_set(my_type, GrB_Name, char *name)` must raise an error. Setting the name is only allowed during the initial creation of the Type. This is different from the more general way that get/set will be used on other objects.
## Builtin Types
The names for builtin types will be:
- GrB_BOOL
- GrB_INT8
- GrB_INT16
- GrB_INT32
- GrB_INT64
- GrB_UINT8
- GrB_UINT16
- GrB_UINT32
- GrB_UINT64
- GrB_FP32
- GrB_FP64
These match Table 3.2 in the 2.0 spec. Formalizing these allows an object serialized by one GraphBLAS implementation to