NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::CollectTestSink< Type > Class Template Reference

A sink for testing that is instantiated using 'Type'. The CollectSink uses 'Type' as a template parameter for the TupleBuffer that it writes results into. More...

#include <TestSink.hpp>

Collaboration diagram for NES::CollectTestSink< Type >:
[legend]

Public Member Functions

 CollectTestSink (const SchemaPtr &schema, const Runtime::NodeEnginePtr &nodeEngine, uint32_t numOfProducers=1)
 Construct a new Collect Test Sink object. More...
 
bool writeData (Runtime::TupleBuffer &inputBuffer, Runtime::WorkerContext &) override
 method to write a TupleBuffer More...
 
std::vector< Type > & getResult ()
 Get the results vector using the template Type of the CollectSink class. More...
 
void setup () override
 virtual method to setup sink @Note this method will be overwritten by derived classes More...
 
std::string toString () const override
 virtual function to get a string describing the particular sink @Note this function is overwritten by the particular data sink More...
 
SinkMediumTypes getSinkMediumType () override
 method to return the type of medium More...
 
void waitTillCompleted (size_t numberOfRecords)
 Waits until numberOfRecords records are produced. More...
 
void waitTillCompletedOrTimeout (size_t numberOfRecords, uint64_t timeoutInMilliseconds)
 Either waits until numberOfRecords records are produced, or until the timeout is reached. More...
 
void shutdown () override
 virtual method to shutdown sink @Note this method will be overwritten by derived classes More...
 
- Public Member Functions inherited from NES::SinkMedium
 SinkMedium (SinkFormatPtr sinkFormat, Runtime::NodeEnginePtr nodeEngine, uint32_t numOfProducers, SharedQueryId sharedQueryId, DecomposedQueryId decomposedQueryId, DecomposedQueryPlanVersion decomposedQueryVersion)
 public constructor for data sink More...
 
 SinkMedium (SinkFormatPtr sinkFormat, Runtime::NodeEnginePtr nodeEngine, uint32_t numOfProducers, SharedQueryId sharedQueryId, DecomposedQueryId decomposedQueryId, DecomposedQueryPlanVersion decomposedQueryVersion, uint64_t numberOfOrigins)
 public constructor for data sink More...
 
SharedQueryId getSharedQueryId () const
 get the id of the owning plan More...
 
DecomposedQueryId getParentPlanId () const
 get the subplan id of the owning plan More...
 
DecomposedQueryPlanVersion getParentPlanVersion () const
 get the subplan version of the owning plan More...
 
uint64_t getNumberOfWrittenOutBuffers ()
 debug function for testing to get number of written buffers More...
 
uint64_t getNumberOfWrittenOutTuples ()
 debug function for testing to get number of written tuples More...
 
SchemaPtr getSchemaPtr () const
 method to return the current schema of the sink More...
 
std::string getSinkFormat ()
 method to get the format as string More...
 
void reconfigure (Runtime::ReconfigurationMessage &message, Runtime::WorkerContext &context) override
 
void postReconfigurationCallback (Runtime::ReconfigurationMessage &message) override
 
OperatorId getOperatorId () const
 Get operator id. More...
 
void setMigrationFlag ()
 Sets that sink is used for state migration. More...
 
bool isForMigration () const
 Check whether this sink is used for state migration. More...
 
- Public Member Functions inherited from NES::Runtime::Reconfigurable
 ~Reconfigurable () NES_NOEXCEPT(false) override=default
 
- Public Member Functions inherited from NES::detail::virtual_enable_shared_from_this< Reconfigurable, false >
 ~virtual_enable_shared_from_this () NES_NOEXCEPT(isNoexceptDestructible) override=default
 
std::shared_ptr< T1 > shared_from_this ()
 
std::weak_ptr< T1 > weak_from_this ()
 
- Public Member Functions inherited from NES::detail::virtual_enable_shared_from_this_base< isNoexceptDestructible >
virtual ~virtual_enable_shared_from_this_base () NES_NOEXCEPT(isNoexceptDestructible)=default
 

Static Public Member Functions

static std::shared_ptr< CollectTestSink< Type > > create (const SchemaPtr &schema, const Runtime::NodeEnginePtr &engine, uint32_t numOfProducers=1)
 Create factory function that calls the constructor of CollectTestSink and returns a shared pointer. More...
 

Public Attributes

std::mutex m
 
std::condition_variable cv
 
std::vector< Type > results
 
std::atomic< bool > running
 

Additional Inherited Members

- Protected Attributes inherited from NES::SinkMedium
SinkFormatPtr sinkFormat
 
bool schemaWritten
 
Runtime::NodeEnginePtr nodeEngine
 
std::atomic< uint32_t > activeProducers
 termination machinery More...
 
SharedQueryId sharedQueryId
 
DecomposedQueryId decomposedQueryId
 
DecomposedQueryPlanVersion decomposedQueryVersion
 
uint64_t numberOfOrigins
 
uint64_t sentBuffer {0}
 
uint64_t sentTuples {0}
 
std::recursive_mutex writeMutex
 
bool migration {false}
 

Detailed Description

template<class Type>
class NES::CollectTestSink< Type >

A sink for testing that is instantiated using 'Type'. The CollectSink uses 'Type' as a template parameter for the TupleBuffer that it writes results into.

Template Parameters
TypeUsed to determine the record layout (field types) of the TupleBuffer.

Constructor & Destructor Documentation

◆ CollectTestSink()

template<class Type >
NES::CollectTestSink< Type >::CollectTestSink ( const SchemaPtr schema,
const Runtime::NodeEnginePtr nodeEngine,
uint32_t  numOfProducers = 1 
)
inline

Construct a new Collect Test Sink object.

Parameters
schemaUsed to create an object of the parent class 'SinkMedium'.
nodeEngineAlso used to create a SinkMedium. Is used to manage queries.
numOfProducersAlso used to create a SinkMedium.

References NES_ASSERT, NES::SinkMedium::nodeEngine, and NES::Schema::ROW_LAYOUT.

Member Function Documentation

◆ create()

template<class Type >
static std::shared_ptr<CollectTestSink<Type> > NES::CollectTestSink< Type >::create ( const SchemaPtr schema,
const Runtime::NodeEnginePtr engine,
uint32_t  numOfProducers = 1 
)
inlinestatic

Create factory function that calls the constructor of CollectTestSink and returns a shared pointer.

Referenced by NES::Testing::TestExecutionEngine::createCollectSink(), and NES::TEST_F().

Here is the caller graph for this function:

◆ getResult()

template<class Type >
std::vector<Type>& NES::CollectTestSink< Type >::getResult ( )
inline

Get the results vector using the template Type of the CollectSink class.

Returns
std::vector<Type>&: vector containing the results.

References NES::CollectTestSink< Type >::results.

◆ getSinkMediumType()

template<class Type >
SinkMediumTypes NES::CollectTestSink< Type >::getSinkMediumType ( )
inlineoverridevirtual

method to return the type of medium

Returns
type of medium

Implements NES::SinkMedium.

References NES::PRINT_SINK.

◆ setup()

template<class Type >
void NES::CollectTestSink< Type >::setup ( )
inlineoverridevirtual

virtual method to setup sink @Note this method will be overwritten by derived classes

Implements NES::SinkMedium.

References NES::CollectTestSink< Type >::running.

◆ shutdown()

template<class Type >
void NES::CollectTestSink< Type >::shutdown ( )
inlineoverridevirtual

virtual method to shutdown sink @Note this method will be overwritten by derived classes

Implements NES::SinkMedium.

References NES::CollectTestSink< Type >::cv, and NES::CollectTestSink< Type >::running.

◆ toString()

template<class Type >
std::string NES::CollectTestSink< Type >::toString ( ) const
inlineoverridevirtual

virtual function to get a string describing the particular sink @Note this function is overwritten by the particular data sink

Returns
string with name and additional information about the sink

Implements NES::SinkMedium.

◆ waitTillCompleted()

template<class Type >
void NES::CollectTestSink< Type >::waitTillCompleted ( size_t  numberOfRecords)
inline

Waits until numberOfRecords records are produced.

Parameters
numberOfRecordsThe number of records to produce until we stop waiting.

References NES::CollectTestSink< Type >::waitTillCompletedOrTimeout().

Here is the call graph for this function:

◆ waitTillCompletedOrTimeout()

template<class Type >
void NES::CollectTestSink< Type >::waitTillCompletedOrTimeout ( size_t  numberOfRecords,
uint64_t  timeoutInMilliseconds 
)
inline

Either waits until numberOfRecords records are produced, or until the timeout is reached.

Parameters
numberOfRecordsThe number of records to produce until we stop waiting.
timeoutInMillisecondsAmount of time that needs to pass until we stop waiting.

References NES::CollectTestSink< Type >::cv, NES::CollectTestSink< Type >::m, NES_DEBUG, NES_ERROR, NES::CollectTestSink< Type >::results, and NES::CollectTestSink< Type >::running.

Referenced by NES::CollectTestSink< Type >::waitTillCompleted().

Here is the caller graph for this function:

◆ writeData()

template<class Type >
bool NES::CollectTestSink< Type >::writeData ( Runtime::TupleBuffer inputBuffer,
Runtime::WorkerContext workerContext 
)
inlineoverridevirtual

method to write a TupleBuffer

Parameters
atuple buffers pointer
Returns
bool indicating if the write was complete

Implements NES::SinkMedium.

References NES::CollectTestSink< Type >::cv, NES::Runtime::TupleBuffer::getBuffer(), NES::Runtime::TupleBuffer::getNumberOfTuples(), NES::CollectTestSink< Type >::m, NES_DEBUG, and NES::CollectTestSink< Type >::results.

Here is the call graph for this function:

Member Data Documentation

◆ cv

◆ m

◆ results

◆ running


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