C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
AnalyzeRe.LargeDataUpload.BinaryYELTConverter Class Reference

Converts a YELT CSV data into a specified format. More...

Public Member Functions

 BinaryYELTConverter (IProducerConsumerBuffer< BufferedBytes > source, int max_queue_size=3, Encoding encoding=null)
 Construct a buffered bytes of binary YELT from other buffered bytes.
 
virtual void Cancel ()
 Stop the producer from reading any more bytes. Warning: This will leave the stream in its current position and any bytes that haven't been inserted into the buffer are lost.
 
void Dispose ()
 Cancel the producer thread and dispose of the queue.
 
void Start (CancellationToken? cancellationToken=null)
 Start the asynchronous producer.
 
TProduced TryTake (out bool success, CancellationToken? cancellation)
 Attempts to remove an item from the produced list. May block if there is not yet an item ready, or return success:false.
 

Static Public Member Functions

static void CopyAsBytes (byte[] destination, ref int offset, ulong trialId, ulong eventId, double sequence, double loss)
 Copy the values of a YELT row into an array as bytes.
 

Static Public Attributes

static readonly Encoding DEFAULT_ENCODING = Encoding.UTF8
 The default encoding used if none is supplied at construction.
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Cancel the producer thread and dispose of the queue.
 
override bool IsProducerFinished ()
 Indicates whether it can produce more items.
 
virtual void OnDispose ()
 Deriving classes' dispose actions.
 
override void OnStart ()
 Invoked before the producer thread is started.
 
override bool TryProduceNext (out BufferedBytes next)
 The method which asynchronously produces items.
 
bool TryProduceNext (out TProduced next)
 The method which asynchronously produces items.
 

Properties

CancellationTokenSource Cancellation [get]
 Can be used to cancel the buffering process.
 
bool CanTake [get]
 Indicates whether a call to Take will ever return another item.
 
Encoding Encoding [get]
 The encoding to use when producing the strings.
 
bool IsConsumerWaiting [get]
 Determines whether the consumer of this buffer is currently waiting for it to produce some data.
 
bool IsRunning [get]
 Indicates whether the producer is currently running.
 
BlockingCollection< TProduced > Produced [get]
 The collection of objects produced.
 

Detailed Description

Converts a YELT CSV data into a specified format.

Definition at line 11 of file BinaryYELTConverter.cs.

Inheritance diagram for AnalyzeRe.LargeDataUpload.BinaryYELTConverter:
AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< BufferedBytes >

Constructor & Destructor Documentation

◆ BinaryYELTConverter()

AnalyzeRe.LargeDataUpload.BinaryYELTConverter.BinaryYELTConverter ( IProducerConsumerBuffer< BufferedBytes source,
int  max_queue_size = 3,
Encoding  encoding = null 
)
inline

Construct a buffered bytes of binary YELT from other buffered bytes.

Parameters
sourceThe source bytes, which represent a CSV with no column headers in the format "Event", "Trial", "Sequence", "Loss".
encodingThe encoding to use to decode the stream.
max_queue_sizeThe maximum number of buffered chunks of binary YELT data to prepare in advance before waiting for the consumer to catch up.

Definition at line 41 of file BinaryYELTConverter.cs.

Member Function Documentation

◆ Cancel()

virtual void AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Cancel ( )
inlinevirtualinherited

Stop the producer from reading any more bytes. Warning: This will leave the stream in its current position and any bytes that haven't been inserted into the buffer are lost.

Definition at line 172 of file ProducerConsumerBuffer.cs.

◆ CopyAsBytes()

static void AnalyzeRe.LargeDataUpload.BinaryYELTConverter.CopyAsBytes ( byte[]  destination,
ref int  offset,
ulong  trialId,
ulong  eventId,
double  sequence,
double  loss 
)
inlinestatic

Copy the values of a YELT row into an array as bytes.

Parameters
destinationThe array where the bytes should be copied to.
offsetThe offset into destination to start copying the bytes.
trialIdThe trial of the YELT row.
eventIdThe event ID of the YELT row.
sequenceThe sequence of the YELT row.
lossThe loss value of the YELT row.

Definition at line 130 of file BinaryYELTConverter.cs.

◆ Dispose() [1/2]

void AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Dispose ( )
inlineinherited

Cancel the producer thread and dispose of the queue.

Definition at line 76 of file ProducerConsumerBuffer.cs.

◆ Dispose() [2/2]

virtual void AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Dispose ( bool  disposing)
inlineprotectedvirtualinherited

Cancel the producer thread and dispose of the queue.

Parameters
disposingWhether dispose is being called by the dispose method or the finalizer

Definition at line 91 of file ProducerConsumerBuffer.cs.

◆ IsProducerFinished()

override bool AnalyzeRe.LargeDataUpload.BinaryYELTConverter.IsProducerFinished ( )
protected

Indicates whether it can produce more items.

Returns
True if it is finished producing items.

◆ OnDispose()

virtual void AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.OnDispose ( )
inlineprotectedvirtualinherited

Deriving classes' dispose actions.

Reimplemented in AnalyzeRe.LargeDataUpload.GZipBufferedBytesProducer.

Definition at line 102 of file ProducerConsumerBuffer.cs.

◆ OnStart()

override void AnalyzeRe.LargeDataUpload.BinaryYELTConverter.OnStart ( )
inlineprotectedvirtual

Invoked before the producer thread is started.

Reimplemented from AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< BufferedBytes >.

Definition at line 50 of file BinaryYELTConverter.cs.

◆ Start()

void AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Start ( CancellationToken?  cancellationToken = null)
inlineinherited

Start the asynchronous producer.

Parameters
cancellationTokenCancellation token that will notify this producer if it is cancelled and halt the producer thread.
Exceptions
InvalidOperationExceptionProducer is already running.

Definition at line 110 of file ProducerConsumerBuffer.cs.

◆ TryProduceNext() [1/2]

override bool AnalyzeRe.LargeDataUpload.BinaryYELTConverter.TryProduceNext ( out BufferedBytes  next)
inlineprotected

The method which asynchronously produces items.

Parameters
nextThe next item to add to the blocking collection.
Returns
True if an item was successfully produced.

Definition at line 66 of file BinaryYELTConverter.cs.

◆ TryProduceNext() [2/2]

bool AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.TryProduceNext ( out TProduced  next)
abstractprotectedinherited

The method which asynchronously produces items.

Parameters
nextThe next item to add to the blocking collection.
Returns
True if an item was successfully produced.

◆ TryTake()

TProduced AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.TryTake ( out bool  success,
CancellationToken?  cancellation 
)
inlineinherited

Attempts to remove an item from the produced list. May block if there is not yet an item ready, or return success:false.

Parameters
successReturns true if a valid item was returned.
cancellationA cancellation token which can be used to cancel this Take operation.
Returns
The item removed from the list.
Exceptions
BufferProducerExceptionIf the producer thread raised an exception.
InvalidOperationExceptionThe producer thread is not currently running, either because the Start method has not been called, or because the Cancel method has been called.

Definition at line 138 of file ProducerConsumerBuffer.cs.

Member Data Documentation

◆ DEFAULT_ENCODING

readonly Encoding AnalyzeRe.LargeDataUpload.BinaryYELTConverter.DEFAULT_ENCODING = Encoding.UTF8
static

The default encoding used if none is supplied at construction.

Definition at line 14 of file BinaryYELTConverter.cs.

Property Documentation

◆ Cancellation

CancellationTokenSource AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Cancellation
getprotectedinherited

Can be used to cancel the buffering process.

Definition at line 53 of file ProducerConsumerBuffer.cs.

◆ CanTake

bool AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.CanTake
getinherited

Indicates whether a call to Take will ever return another item.

Exceptions
BufferProducerExceptionIf the producer thread raised an exception.

HACK: Need some way of surfacing asynchronous errors without consumers assuming we're done, so raise any asynchronous exception here. TODO: Revisit Implementation such that BufferProducerException is discovered elsewhere CanTake can simply be made to return false if an exception occurred.

Definition at line 36 of file ProducerConsumerBuffer.cs.

◆ Encoding

Encoding AnalyzeRe.LargeDataUpload.BinaryYELTConverter.Encoding
get

The encoding to use when producing the strings.

Definition at line 27 of file BinaryYELTConverter.cs.

◆ IsConsumerWaiting

bool AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.IsConsumerWaiting
getprotectedinherited

Determines whether the consumer of this buffer is currently waiting for it to produce some data.

Definition at line 23 of file ProducerConsumerBuffer.cs.

◆ IsRunning

bool AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.IsRunning
getinherited

Indicates whether the producer is currently running.

Definition at line 26 of file ProducerConsumerBuffer.cs.

◆ Produced

BlockingCollection<TProduced> AnalyzeRe.LargeDataUpload.ProducerConsumerBuffer< TProduced >.Produced
getprotectedinherited

The collection of objects produced.

Definition at line 19 of file ProducerConsumerBuffer.cs.


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