# CassVector

### struct CassVector

A fixed-size sequence of values of the same type.

Note that a vector is not a CQL collection: its size is part of its type, its elements cannot be null, and it can only be updated as a whole. 

### Public Functions

### [CassVector](#_CPPv410CassVector) \*cass_vector_new([CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) element_type, [cass_uint16_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv413cass_uint16_t) dimensions)

Creates a new vector with elements of the given native type.

Contrary to a collection or a tuple, a vector is always fully typed: the wire representation of its elements depends on their type, so the element type must be known upfront. For a vector whose elements are not of a native type (a UDT, a tuple, a collection or another vector), build the data type and use [cass_vector_new_from_data_type()](#struct_cass_vector_1aacd389ad29f5ebf57fc4df9c25e0e01a) instead.

Unlike tuple items, vector elements cannot be null, and there is no cass_vector_set_null(). Leaving any element unset results in an error.

#### SEE ALSO
[cass_vector_free()](#struct_cass_vector_1ae63e3fdf4120381fca4754260625ffe1)

* **Parameters:**
  * **element_type** – **[in]** The value type of the vector’s elements. 
  * **dimensions** – **[in]** The number of elements of the vector, which must not be zero. 
* **Returns:**
  Returns a vector that must be freed. NULL is returned if `element_type` is not a native value type or `dimensions` is zero.

### [CassVector](#_CPPv410CassVector) \*cass_vector_new_from_data_type(const [CassDataType](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassDataType.md#_CPPv412CassDataType) \*data_type)

Creates a new vector from an existing data type.

#### SEE ALSO
[cass_vector_free()](#struct_cass_vector_1ae63e3fdf4120381fca4754260625ffe1); 

* **Parameters:**
  **data_type** – **[in]** 
* **Returns:**
  Returns a vector that must be freed. NULL is returned if the data type is not a vector.

### void cass_vector_free([CassVector](#_CPPv410CassVector) \*vector)

Frees a vector instance.

* **Parameters:**
  **vector** – **[in]** 

### const [CassDataType](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassDataType.md#_CPPv412CassDataType) \*cass_vector_data_type(const [CassVector](#_CPPv410CassVector) \*vector)

Gets the data type of a vector.

* **Parameters:**
  **vector** – **[in]** 
* **Returns:**
  Returns a reference to the data type of the vector. Do not free this reference as it is bound to the lifetime of the vector. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_int8([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_int8_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv411cass_int8_t) value)

Sets a “tinyint” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_int16([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_int16_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int16_t) value)

Sets an “smallint” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_int32([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_int32_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int32_t) value)

Sets an “int” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_uint32([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_uint32_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv413cass_uint32_t) value)

Sets a “date” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_int64([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_int64_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int64_t) value)

Sets a “bigint”, “counter”, “timestamp” or “time” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_float([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_float_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_float_t) value)

Sets a “float” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_double([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_double_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv413cass_double_t) value)

Sets a “double” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_bool([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_bool_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv411cass_bool_t) value)

Sets a “boolean” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_string([CassVector](#_CPPv410CassVector) \*vector, size_t index, const char \*value)

Sets an “ascii”, “text” or “varchar” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** The value is copied into the vector object; the memory pointed to by this parameter can be freed after this call. 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_string_n([CassVector](#_CPPv410CassVector) \*vector, size_t index, const char \*value, size_t value_length)

Same as [cass_vector_set_string()](#struct_cass_vector_1a2f2fc2880ad0ab59d85d9bd54bfe65a7), but with lengths for string parameters.

#### SEE ALSO
[cass_vector_set_string()](#struct_cass_vector_1a2f2fc2880ad0ab59d85d9bd54bfe65a7); 

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
  * **value_length** – **[in]** 
* **Returns:**
  same as [cass_vector_set_string()](#struct_cass_vector_1a2f2fc2880ad0ab59d85d9bd54bfe65a7)

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_bytes([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [cass_byte_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv411cass_byte_t) \*value, size_t value_size)

Sets a “blob”, “varint” or “custom” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** The value is copied into the vector object; the memory pointed to by this parameter can be freed after this call. 
  * **value_size** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_uuid([CassVector](#_CPPv410CassVector) \*vector, size_t index, [CassUuid](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassUuid.md#_CPPv48CassUuid) value)

Sets a “uuid” or “timeuuid” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_inet([CassVector](#_CPPv410CassVector) \*vector, size_t index, [CassInet](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassInet.md#_CPPv48CassInet) value)

Sets an “inet” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_decimal([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [cass_byte_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv411cass_byte_t) \*varint, size_t varint_size, [cass_int32_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int32_t) scale)

Sets a “decimal” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **varint** – **[in]** The value is copied into the vector object; the memory pointed to by this parameter can be freed after this call. 
  * **varint_size** – **[in]** 
  * **scale** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_duration([CassVector](#_CPPv410CassVector) \*vector, size_t index, [cass_int32_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int32_t) months, [cass_int32_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int32_t) days, [cass_int64_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv412cass_int64_t) nanos)

Sets a “duration” in a vector at the specified index.

**Requires Apache Cassandra:** 3.10+

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **months** – **[in]** 
  * **days** – **[in]** 
  * **nanos** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_collection([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [CassCollection](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassCollection.md#_CPPv414CassCollection) \*value)

Sets a “list”, “map” or “set” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_tuple([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [CassTuple](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassTuple.md#_CPPv49CassTuple) \*value)

Sets a “tuple” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_user_type([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [CassUserType](https://cpp-rs-driver.docs.scylladb.com/master/api/struct.CassUserType.md#_CPPv412CassUserType) \*value)

Sets a “udt” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_vector_set_vector([CassVector](#_CPPv410CassVector) \*vector, size_t index, const [CassVector](#_CPPv410CassVector) \*value)

Sets a “vector” in a vector at the specified index.

* **Parameters:**
  * **vector** – **[in]** 
  * **index** – **[in]** 
  * **value** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.
