Kinetica   C#   API  Version 7.2.3.1
StripedWorkerQueue< T > Class Template Reference

A worker queue with multiple stripes to reduce lock contention. More...

Public Member Functions

 StripedWorkerQueue (Uri url, int workerIndex, int numStripes, int batchSize)
 Creates a new striped worker queue. More...
 
List< T >? Add (T record, long stripeHash, out int stripeIndex)
 Adds a record to the appropriate stripe based on the stripe hash. More...
 
List< T >? AddToStripe (T record, int stripeIndex)
 Adds a record to a specific stripe. More...
 
List< List< T > > AddRangeToStripe (IReadOnlyList< T > records, int stripeIndex)
 Adds multiple records to a specific stripe. More...
 
List<(int stripeIndex, List< T > batch)> FlushAll ()
 Flushes all stripes and returns all batches. More...
 

Public Attributes

int NumStripes => _numStripes
 Number of stripes in this queue. More...
 

Properties

Uri Url [get]
 URL of the worker this queue is associated with. More...
 
int WorkerIndex [get]
 Index of this worker in the worker list. More...
 
int TotalCount [get]
 Gets the total count of records across all stripes. More...
 

Detailed Description

A worker queue with multiple stripes to reduce lock contention.

Each stripe operates independently, allowing concurrent inserts to different stripes.

Template Parameters
TThe record type.

Definition at line 98 of file StripedWorkerQueue.cs.

Constructor & Destructor Documentation

◆ StripedWorkerQueue()

StripedWorkerQueue< T >.StripedWorkerQueue ( Uri  url,
int  workerIndex,
int  numStripes,
int  batchSize 
)
inline

Creates a new striped worker queue.

Parameters
urlWorker URL.
workerIndexWorker index.
numStripesNumber of stripes (should be power of 2 for efficient modulo).
batchSizeBatch size per stripe.

Definition at line 121 of file StripedWorkerQueue.cs.

Member Function Documentation

◆ Add()

List<T>? StripedWorkerQueue< T >.Add ( record,
long  stripeHash,
out int  stripeIndex 
)
inline

Adds a record to the appropriate stripe based on the stripe hash.

Returns a batch if the stripe reaches capacity.

Parameters
recordThe record to add.
stripeHashHash value to determine stripe placement.
stripeIndexOutput: the stripe index used.
Returns
A batch if capacity reached, null otherwise.

Definition at line 157 of file StripedWorkerQueue.cs.

◆ AddRangeToStripe()

List<List<T> > StripedWorkerQueue< T >.AddRangeToStripe ( IReadOnlyList< T >  records,
int  stripeIndex 
)
inline

Adds multiple records to a specific stripe.

Definition at line 174 of file StripedWorkerQueue.cs.

◆ AddToStripe()

List<T>? StripedWorkerQueue< T >.AddToStripe ( record,
int  stripeIndex 
)
inline

Adds a record to a specific stripe.

Definition at line 166 of file StripedWorkerQueue.cs.

◆ FlushAll()

List<(int stripeIndex, List<T> batch)> StripedWorkerQueue< T >.FlushAll ( )
inline

Flushes all stripes and returns all batches.

Returns
List of (stripeIndex, batch) tuples.

Definition at line 183 of file StripedWorkerQueue.cs.

Member Data Documentation

◆ NumStripes

int StripedWorkerQueue< T >.NumStripes => _numStripes

Number of stripes in this queue.

Definition at line 216 of file StripedWorkerQueue.cs.

Property Documentation

◆ TotalCount

int StripedWorkerQueue< T >.TotalCount
get

Gets the total count of records across all stripes.

Definition at line 201 of file StripedWorkerQueue.cs.

◆ Url

Uri StripedWorkerQueue< T >.Url
get

URL of the worker this queue is associated with.

Definition at line 107 of file StripedWorkerQueue.cs.

◆ WorkerIndex

int StripedWorkerQueue< T >.WorkerIndex
get

Index of this worker in the worker list.

Definition at line 112 of file StripedWorkerQueue.cs.


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