Class CqlVector<T>
Type used by the driver to represent the Apache Cassandra Vector type.
Examples of how to create a vector object (using int as a sub type here but all CQL types are supported):
var vector = new CqlVector<int>(1, 2, 3);
var vector = CqlVector<int>.New(new int[] { 1, 2, 3 });
// note that ToArray() performs a copy
var vector = CqlVector<int>.New(new List<int> { 1, 2, 3 }.ToArray());
var vector = CqlVector<int>.New(3);
vector[0] = 1;
vector[1] = 2;
vector[2] = 3;
// no copy
var vector = new int[] { 1, 2, 3 }.AsCqlVector();
// with copy
var vector = new int[] { 1, 2, 3 }.ToCqlVector();
Assembly: Cassandra.dll
Syntax
public sealed class CqlVector<T> : IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name |
Description |
T |
Type of the vector elements.
|
Constructors
CqlVector()
Creates a new vector with an empty array.
Declaration
CqlVector(params T[])
Creates a new vector with the provided array. Note that no copy is made, the provided array is used directly by the new vector object.
Declaration
public CqlVector(params T[] elements)
Parameters
Type |
Name |
Description |
T[] |
elements |
|
Properties
Count
Gets the size of this vector (number of dimensions).
Declaration
public int Count { get; }
Property Value
this[int]
Gets or sets the element at the specified index.
Declaration
public T this[int index] { get; set; }
Parameters
Type |
Name |
Description |
int |
index |
The zero-based index of the element to get or set.
|
Property Value
Type |
Description |
T |
The element at the specified index.
|
Exceptions
Methods
AsArray()
Declaration
Returns
Type |
Description |
T[] |
The underlying array.
|
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
Overrides
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
New(int)
Creates a new vector with the provided number of dimensions.
Declaration
public static CqlVector<T> New(int dimensions)
Parameters
Type |
Name |
Description |
int |
dimensions |
|
Returns
New(T[])
Creates a new vector with the provided array.
This is equivalent to calling the constructor CqlVector(params T[]). Note that no copy is made, the provided array is used directly by the new vector object.
Declaration
public static CqlVector<T> New(T[] arr)
Parameters
Type |
Name |
Description |
T[] |
arr |
|
Returns
Operators
operator ==(CqlVector<T>, CqlVector<T>)
Declaration
public static bool operator ==(CqlVector<T> left, CqlVector<T> right)
Parameters
Returns
explicit operator T[](CqlVector<T>)
Declaration
public static explicit operator T[](CqlVector<T> v)
Parameters
Returns
implicit operator CqlVector<T>(T[])
Declaration
public static implicit operator CqlVector<T>(T[] a)
Parameters
Type |
Name |
Description |
T[] |
a |
|
Returns
operator !=(CqlVector<T>, CqlVector<T>)
Declaration
public static bool operator !=(CqlVector<T> left, CqlVector<T> right)
Parameters
Returns
Implements