AddDescriptor
Add a new descriptor to a DescriptorSet, and properties associated with it.
A blob must be provided in the array of blobs, which contains the descriptor’s values. The blob is an unpadded binary array of 32-bit floating point values in IEEE 754 format in the native byte order of the server platform, which is usually little-endian. The size of the blob, in bytes, must be dimensions*4.
In Python, this blob can be generated using one of the following methods: `python blob = struct.pack('<{}f'.format(len(data)), *data) blob = np.array(data, dtype='<f4').tobytes() `
Parameters
Parameter | JSON type | Behavior |
|---|---|---|
integer, 1 through 100000 | Optional. Declares a unique reference for later commands in this transaction. When omitted, no reference is available to later commands. If conditional insertion finds existing objects, the reference names those matches. | |
connection object or array of connection objects | Optional. When omitted, no additional user connections are created. Each object requires an earlier node ref. Optional class chooses a connection class; direction is in or out (default out); properties sets connection properties. Omitted class uses this command’s default connection class. Connections are created only for a newly inserted object. | |
array expression | Optional. Checks existing objects of this type before insertion. When omitted, no duplicate lookup is performed. A match skips creation, properties, and new connections; status is 2 and _ref names all matches. An empty expression array is invalid. The duplicate filter is not automatically scoped to set; include a property that distinguishes your sets when needed. | |
string | Optional. Stored as “None”. Sets the object’s label independently of user properties. | |
object mapping property names to values | Optional. When omitted, no user properties are added. Stores booleans, numbers, strings, supported arrays, or single-key _date, _blob, and _json wrappers. Bare null is rejected; property names and wrapped values are validated. See the properties reference for nested value rules. | |
string | Required. Names an existing descriptor set, or one created earlier in this transaction. The input blob must contain exactly dimensions finite float32 values. |
Details
The properties object stores key-value pairs on the new object.
The if_not_found condition inserts the object only when no existing object matches the condition.
The connect parameter creates connections between the new object and objects referenced earlier in the transaction.
The set parameter specifies the name of the DescriptorSet to which the new Descriptor will be added. If the set does not exist, an error will be returned. The DescriptorSet is added using the AddDescriptorSet command.
Response and errors
An authenticated session with the objects create permission is required.
The response is an object under AddDescriptor with integer status. Status 0 means creation succeeded; status 2 means conditional insertion found existing objects. No output blob or created-object count is returned.
Invalid field types, missing required fields, malformed expressions, and invalid references fail validation. Execution failures include a nonzero status and an info message; inspect the transaction response before assuming a mutation succeeded. Missing descriptor sets, wrong blob byte length, and NaN or infinite vector elements are rejected.
Examples
Insert a Descriptor representing a person’s face to the DescriptorSet with the name of “pretty_faces”, insert an Image of the face, and create a connection between the new image and the new descriptor:
[{
"AddImage": {
"_ref": 1,
"properties": {
"description": "profile photo"
}
}
}, {
"AddDescriptor": {
"set": "pretty_faces",
"label": "Ricky Fort",
"properties": {
"gender": "M",
"age": 45
},
"connect": {
"ref": 1
}
}
}]
Successful response:
[{
"AddImage": {
"status": 0
}
}, {
"AddDescriptor": {
"status": 0
}
}]