2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Runtime.CompilerServices;
6 namespace kinetica.Records;
60 private readonly
long _intValue;
61 private readonly
double _floatValue;
62 private readonly
string? _stringValue;
68 _floatValue = floatValue;
69 _stringValue = stringValue;
78 #region Factory Methods (Equivalent to Rust enum variants) 133 #region Value Accessors 137 [MethodImpl(MethodImplOptions.AggressiveInlining)]
144 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to Int")
150 [MethodImpl(MethodImplOptions.AggressiveInlining)]
158 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to Long")
164 [MethodImpl(MethodImplOptions.AggressiveInlining)]
170 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to Float")
176 [MethodImpl(MethodImplOptions.AggressiveInlining)]
182 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to Double")
188 [MethodImpl(MethodImplOptions.AggressiveInlining)]
198 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to String")
204 [MethodImpl(MethodImplOptions.AggressiveInlining)]
210 _ =>
throw new InvalidOperationException($
"Cannot convert {_type} to Boolean")
219 value = (int)_intValue;
246 value = _stringValue;
255 #region Equality and Hashing 259 if (_type != other._type)
return false;
266 => _intValue == other._intValue,
268 => _floatValue == other._floatValue,
269 _ =>
string.Equals(_stringValue, other._stringValue, StringComparison.Ordinal)
282 => HashCode.Combine(_type, _intValue),
284 => HashCode.Combine(_type, _floatValue),
285 _ => HashCode.Combine(_type, _stringValue)
301 => _intValue.ToString(),
304 => _floatValue.ToString(),
305 _ => _stringValue ??
"null" 317 public readonly
struct ShardKeyValues : IReadOnlyList<(string Name, ShardKeyValue Value)>
332 =>
new((name, value));
336 =>
new((name1, value1), (name2, value2));
343 =>
new((name1, value1), (name2, value2), (name3, value3));
351 =>
new((name1, value1), (name2, value2), (name3, value3), (name4, value4));
354 public int Count => _values?.Length ?? 0;
361 if (_values ==
null || index < 0 || index >= _values.Length)
362 throw new IndexOutOfRangeException();
363 return _values[index];
373 foreach (var value
in _values)
ShardKeyValueType
Represents the type of a shard key value.
static ShardKeyValue Int(int value)
Creates a 32-bit integer shard key value.
static ShardKeyValue Float(float value)
Creates a 32-bit float shard key value.
bool TryGetLong(out long value)
Tries to get the value as a long.
string? AsString()
Gets the value as a string.
override string ToString()
int Count
Gets the number of shard key values.
static bool operator !=(ShardKeyValue left, ShardKeyValue right)
override int GetHashCode()
static ShardKeyValues Three(string name1, ShardKeyValue value1, string name2, ShardKeyValue value2, string name3, ShardKeyValue value3)
Creates a ShardKeyValues collection with three values.
static ShardKeyValue Int16(short value)
Creates a 16-bit integer shard key value.
Date in YYYY-MM-DD format
string Name
Gets the shard key value at the specified index.
static ShardKeyValues Two(string name1, ShardKeyValue value1, string name2, ShardKeyValue value2)
Creates a ShardKeyValues collection with two values.
static ShardKeyValue Uuid(string value)
Creates a UUID shard key value (standard format).
static ShardKeyValue Time(string value)
Creates a time shard key value (HH:MM:SS.mmm format).
Time in HH:MM:SS.mmm format
float AsFloat()
Gets the value as a 32-bit float.
int AsInt()
Gets the value as a 32-bit integer.
static ShardKeyValue Double(double value)
Creates a 64-bit double shard key value.
IPv4 address in dotted-quad format
Unsigned long as string (0 to 18446744073709551615)
static ShardKeyValues Single(string name, ShardKeyValue value)
Creates a ShardKeyValues collection with a single value.
static ShardKeyValue Ipv4(string value)
Creates an IPv4 shard key value (dotted-quad format).
static ShardKeyValue Null()
Creates a null shard key value.
long AsLong()
Gets the value as a 64-bit integer.
IEnumerator<(string Name, ShardKeyValue Value)> GetEnumerator()
Gets an enumerator for the shard key values.
Collection of shard key column names and values.
static ShardKeyValue Timestamp(long value)
Creates a timestamp shard key value (milliseconds since Unix epoch).
bool AsBool()
Gets the value as a boolean.
static ShardKeyValue Decimal(string value)
Creates a decimal shard key value (string representation).
bool Equals(ShardKeyValue other)
double AsDouble()
Gets the value as a 64-bit double.
static ShardKeyValues Empty
Creates an empty ShardKeyValues collection.
static ShardKeyValue Int8(sbyte value)
Creates an 8-bit integer shard key value.
static ShardKeyValue DateTime(string value)
Creates a datetime shard key value (YYYY-MM-DD HH:MM:SS.mmm format).
static ShardKeyValue Long(long value)
Creates a 64-bit integer shard key value.
static ShardKeyValue Date(string value)
Creates a date shard key value (YYYY-MM-DD format).
Immutable collection of metadata about a Kinetica type.
static ShardKeyValue String(string value)
Creates a string shard key value.
A typed value for shard key computation.
Timestamp as milliseconds since Unix epoch
ShardKeyValues(params(string Name, ShardKeyValue Value)[] values)
Creates a ShardKeyValues collection from the specified values.
static bool operator==(ShardKeyValue left, ShardKeyValue right)
32-bit signed integer (also used for boolean, int8, int16)
bool TryGetString(out string? value)
Tries to get the value as a string.
bool IsNull
Returns true if this value is null.
DateTime in YYYY-MM-DD HH:MM:SS.mmm format
static ShardKeyValue Boolean(bool value)
Creates a boolean shard key value.
static ShardKeyValue Ulong(string value)
Creates an unsigned long shard key value (string representation).
bool TryGetInt(out int value)
Tries to get the value as an integer.
static ShardKeyValues Four(string name1, ShardKeyValue value1, string name2, ShardKeyValue value2, string name3, ShardKeyValue value3, string name4, ShardKeyValue value4)
Creates a ShardKeyValues collection with four values.
Boolean stored as integer (0 or 1)