Kinetica   C#   API  Version 7.2.3.1
RecordKey Class Reference

A binary key used for shard routing. More...

Public Member Functions

 RecordKey (int bufferSize)
 Creates a new RecordKey with the specified buffer size. More...
 
long HashCode ()
 Gets the hash code for stripe distribution. More...
 
int Route (IList< int > routingTable)
 Routes this key to a worker index using the routing table. More...
 
void Invalidate ()
 Invalidates this key (e.g., when a null value is encountered). More...
 
void ComputeHash ()
 Computes the routing hash from the buffer contents. More...
 
void AddInt8 (sbyte value)
 Adds an 8-bit integer to the key. More...
 
void AddInt16 (short value)
 Adds a 16-bit integer to the key (little-endian). More...
 
void AddInt (int value)
 Adds a 32-bit integer to the key (little-endian). More...
 
void AddLong (long value)
 Adds a 64-bit integer to the key (little-endian). More...
 
void AddFloat (float value)
 Adds a 32-bit float to the key. More...
 
void AddDouble (double value)
 Adds a 64-bit double to the key. More...
 
void AddString (string value)
 Adds a string to the key (via MurmurHash3). More...
 
void AddCharN (string value, int length)
 Adds a fixed-length char to the key. More...
 
void AddDate (string value)
 Adds a date string (YYYY-MM-DD) to the key. More...
 
void AddDateTime (string value)
 Adds a datetime string (YYYY-MM-DD HH:MM:SS.mmm) to the key. More...
 
void AddTime (string value)
 Adds a time string (HH:MM:SS.mmm) to the key. More...
 
void AddIpv4 (string value)
 Adds an IPv4 address string (dotted-quad) to the key. More...
 
void AddDecimal (string value, int precision, int scale)
 Adds a decimal string to the key. More...
 
void AddUuid (string value)
 Adds a UUID string to the key. More...
 
 RecordKey (int size)
 Allocate the buffer for the record key with the given size. More...
 
bool isValid ()
 Returns whether the key is valid or not. More...
 
int hashCode ()
 Returns key's hash code. More...
 
void addInt (int? value)
 Add an integer to the buffer. More...
 
void addInt8 (int? value)
 Add an 8-bit integer to the buffer. More...
 
void addInt16 (int? value)
 Add a short (two bytes) to the buffer. More...
 
void addLong (long? value)
 Add a long to the buffer. More...
 
void addFloat (float? value)
 Add a float to the buffer. More...
 
void addDouble (double? value)
 Add a double to the buffer. More...
 
void addString (string value)
 Add a string to the buffer. More...
 
void addCharN (string value, int N)
 Appends a charN value to the buffer. More...
 
void addDate (string value)
 Adds a string to the buffer that has the 'date' property. More...
 
void addDateTime (string value)
 Adds a string to the buffer that has the 'datetime' property. More...
 
void addDecimal (string value, int precision, int scale)
 Adds a decimal value to the buffer with specified precision and scale. More...
 
void addIPv4 (string value)
 Adds a string to the buffer that has the 'ipv4' property. More...
 
void addTime (string value)
 Adds a string to the buffer that has the 'time' property. More...
 
void addTimeStamp (long? value)
 Adds a long to the buffer that has the 'timestamp' property. More...
 
void computeHashes ()
 Compute the hash of the key in the buffer. More...
 
int route (IList< int > routingTable)
 Given a routing table consisting of worker rank indices, choose a worker rank based on the hash of the record key. More...
 

Public Attributes

bool IsValid => _isValid && _position > 0
 Returns true if this key is valid (no null values were added). More...
 
long RoutingHash => _routingHash
 Gets the routing hash (must call ComputeHash first). More...
 

Detailed Description

A binary key used for shard routing.

A key based on a given record that serves as either a primary key

Equivalent to Rust's RecordKey.

This class holds a binary-encoded key buffer and computes a routing hash using MurmurHash3 for consistent shard distribution.

or a shard key. The RecordKeyBuilder<T> class creates these record keys.

Definition at line 16 of file RecordKey.cs.

Constructor & Destructor Documentation

◆ RecordKey() [1/2]

RecordKey.RecordKey ( int  bufferSize)
inline

Creates a new RecordKey with the specified buffer size.

Definition at line 26 of file RecordKey.cs.

◆ RecordKey() [2/2]

RecordKey.RecordKey ( int  size)
inline

Allocate the buffer for the record key with the given size.

Parameters
sizeThe size of the buffer. Must be greater than or equal to 1.

Definition at line 74 of file RecordKey.cs.

Member Function Documentation

◆ AddCharN()

void RecordKey.AddCharN ( string  value,
int  length 
)
inline

Adds a fixed-length char to the key.

Definition at line 159 of file RecordKey.cs.

◆ addCharN()

void RecordKey.addCharN ( string  value,
int  N 
)
inline

Appends a charN value to the buffer.

If value is longer than N in length, it gets truncated. If it is shorter, then the remaining characters get padded with byte 0.

Parameters
valueThe value to be added to the byte buffer.
NThe number of characters to be added to the byte buffer. If N is greater than what would fit in the buffer, then an exception is thrown.

Definition at line 370 of file RecordKey.cs.

◆ AddDate()

void RecordKey.AddDate ( string  value)
inline

Adds a date string (YYYY-MM-DD) to the key.

Definition at line 184 of file RecordKey.cs.

◆ addDate()

void RecordKey.addDate ( string  value)
inline

Adds a string to the buffer that has the 'date' property.

Internally, the date is stored as an integer.

Parameters
valueThe date string to be added. Must have the YYYY-MM-DD format.

Definition at line 419 of file RecordKey.cs.

◆ AddDateTime()

void RecordKey.AddDateTime ( string  value)
inline

Adds a datetime string (YYYY-MM-DD HH:MM:SS.mmm) to the key.

Definition at line 206 of file RecordKey.cs.

◆ addDateTime()

void RecordKey.addDateTime ( string  value)
inline

Adds a string to the buffer that has the 'datetime' property.

Internally, the date is stored as a long.

Parameters
valueThe datetime string to be added. Must have the YYYY-MM-DD HH:MM:SS.mmm format.

Definition at line 488 of file RecordKey.cs.

◆ AddDecimal()

void RecordKey.AddDecimal ( string  value,
int  precision,
int  scale 
)
inline

Adds a decimal string to the key.

Definition at line 277 of file RecordKey.cs.

◆ addDecimal()

void RecordKey.addDecimal ( string  value,
int  precision,
int  scale 
)
inline

Adds a decimal value to the buffer with specified precision and scale.

For precision <= 18, the value is stored as an 8-byte scaled long. For precision > 18, the value is stored as a 12-byte scaled BigInteger (little-endian).

Parameters
valueThe decimal string to be added.
precisionThe total number of digits in the decimal.
scaleThe number of digits after the decimal point.

Definition at line 601 of file RecordKey.cs.

◆ AddDouble()

void RecordKey.AddDouble ( double  value)
inline

Adds a 64-bit double to the key.

Definition at line 139 of file RecordKey.cs.

◆ addDouble()

void RecordKey.addDouble ( double?  value)
inline

Add a double to the buffer.

Parameters
valueThe double value to be added. Can be null.

Definition at line 306 of file RecordKey.cs.

◆ AddFloat()

void RecordKey.AddFloat ( float  value)
inline

Adds a 32-bit float to the key.

Definition at line 131 of file RecordKey.cs.

◆ addFloat()

void RecordKey.addFloat ( float?  value)
inline

Add a float to the buffer.

Parameters
valueThe float value to be added. Can be null.

Definition at line 276 of file RecordKey.cs.

◆ AddInt()

void RecordKey.AddInt ( int  value)
inline

Adds a 32-bit integer to the key (little-endian).

Definition at line 105 of file RecordKey.cs.

◆ addInt()

void RecordKey.addInt ( int?  value)
inline

Add an integer to the buffer.

Parameters
valueThe integer value to be added. Can be null.

Definition at line 164 of file RecordKey.cs.

◆ AddInt16()

void RecordKey.AddInt16 ( short  value)
inline

Adds a 16-bit integer to the key (little-endian).

Definition at line 96 of file RecordKey.cs.

◆ addInt16()

void RecordKey.addInt16 ( int?  value)
inline

Add a short (two bytes) to the buffer.

Parameters
valueThe short value to be added. Can be null.

Definition at line 215 of file RecordKey.cs.

◆ AddInt8()

void RecordKey.AddInt8 ( sbyte  value)
inline

Adds an 8-bit integer to the key.

Definition at line 88 of file RecordKey.cs.

◆ addInt8()

void RecordKey.addInt8 ( int?  value)
inline

Add an 8-bit integer to the buffer.

Parameters
valueThe integer value to be added. Can be null.

Definition at line 193 of file RecordKey.cs.

◆ AddIpv4()

void RecordKey.AddIpv4 ( string  value)
inline

Adds an IPv4 address string (dotted-quad) to the key.

Definition at line 258 of file RecordKey.cs.

◆ addIPv4()

void RecordKey.addIPv4 ( string  value)
inline

Adds a string to the buffer that has the 'ipv4' property.

Internally, the IP is stored as an integer.

Parameters
valueThe IPv4 string to be added. Must have the XXX.XXX.XXX.XXX format.

Definition at line 686 of file RecordKey.cs.

◆ AddLong()

void RecordKey.AddLong ( long  value)
inline

Adds a 64-bit integer to the key (little-endian).

Definition at line 116 of file RecordKey.cs.

◆ addLong()

void RecordKey.addLong ( long?  value)
inline

Add a long to the buffer.

Parameters
valueThe long value to be added. Can be null.

Definition at line 243 of file RecordKey.cs.

◆ AddString()

void RecordKey.AddString ( string  value)
inline

Adds a string to the key (via MurmurHash3).

Definition at line 146 of file RecordKey.cs.

◆ addString()

void RecordKey.addString ( string  value)
inline

Add a string to the buffer.

Hash the string value and add it as a long internally.

Parameters
valueThe string value to be added. Can be null.

Definition at line 341 of file RecordKey.cs.

◆ AddTime()

void RecordKey.AddTime ( string  value)
inline

Adds a time string (HH:MM:SS.mmm) to the key.

Definition at line 237 of file RecordKey.cs.

◆ addTime()

void RecordKey.addTime ( string  value)
inline

Adds a string to the buffer that has the 'time' property.

Internally, the time is stored as an integer.

Parameters
valueThe time string to be added. Must have the HH:MM:SS[.mmm] format. Milliseconds can have one to three digits. HH can be one or two digits.

Definition at line 749 of file RecordKey.cs.

◆ addTimeStamp()

void RecordKey.addTimeStamp ( long?  value)
inline

Adds a long to the buffer that has the 'timestamp' property.

Parameters
valueThe timestamp to be added (in milliseconds).

Definition at line 824 of file RecordKey.cs.

◆ AddUuid()

void RecordKey.AddUuid ( string  value)
inline

Adds a UUID string to the key.

Definition at line 291 of file RecordKey.cs.

◆ ComputeHash()

void RecordKey.ComputeHash ( )
inline

Computes the routing hash from the buffer contents.

Definition at line 76 of file RecordKey.cs.

◆ computeHashes()

void RecordKey.computeHashes ( )
inline

Compute the hash of the key in the buffer.

Use the Murmurhash3 algorithm to compute the hash. If not all of the values have been added to the key (i.e. if the buffer is not full), then throw an exception.

Definition at line 857 of file RecordKey.cs.

◆ HashCode()

long RecordKey.HashCode ( )

Gets the hash code for stripe distribution.

◆ hashCode()

int RecordKey.hashCode ( )
inline

Returns key's hash code.

Returns
The hash code for the key.

Definition at line 98 of file RecordKey.cs.

◆ Invalidate()

void RecordKey.Invalidate ( )
inline

Invalidates this key (e.g., when a null value is encountered).

Definition at line 68 of file RecordKey.cs.

◆ isValid()

bool RecordKey.isValid ( )
inline

Returns whether the key is valid or not.

Returns
A bool indicating whether the key is valid at the moment.

Definition at line 89 of file RecordKey.cs.

◆ Route()

int RecordKey.Route ( IList< int >  routingTable)
inline

Routes this key to a worker index using the routing table.

Definition at line 52 of file RecordKey.cs.

◆ route()

int RecordKey.route ( IList< int >  routingTable)
inline

Given a routing table consisting of worker rank indices, choose a worker rank based on the hash of the record key.

Parameters
routingTableA list of integers which represent worker ranks.
Returns
The appropriate entry fromroutingTable .

Definition at line 880 of file RecordKey.cs.

Member Data Documentation

◆ IsValid

bool RecordKey.IsValid => _isValid && _position > 0

Returns true if this key is valid (no null values were added).

Definition at line 37 of file RecordKey.cs.

◆ RoutingHash

long RecordKey.RoutingHash => _routingHash

Gets the routing hash (must call ComputeHash first).

Definition at line 42 of file RecordKey.cs.


The documentation for this class was generated from the following file: