NebulaStream  0.6.213
NebulaStream is a data and application management framework for the internet of things
NES::TestSink Class Reference

A sink for testing that can be part of a query plan and enables executing queries and producing results. More...

#include <TestSink.hpp>

Collaboration diagram for NES::TestSink:
[legend]

Public Member Functions

 TestSink (uint64_t expectedTuples, const SchemaPtr &schema, const Runtime::NodeEnginePtr &nodeEngine, uint32_t numOfProducers=1)
 Constructor for a TestSink. More...
 
bool writeData (Runtime::TupleBuffer &inputBuffer, Runtime::WorkerContext &) override
 Writes the input Buffer to the resultBuffer. More...
 
Runtime::TupleBuffer get (uint64_t index)
 Returns the TupleBuffer at the index. More...
 
Runtime::MemoryLayouts::TestTupleBuffer getResultBuffer (uint64_t index)
 Returns the TestTupleBuffer at the index. More...
 
std::vector< Runtime::MemoryLayouts::TestTupleBuffergetResultBuffers ()
 Returns all buffers as TestTupleBuffers. More...
 
void setup () override
 Setup method. More...
 
std::string toString () const override
 Creates a string representation. More...
 
uint32_t getNumberOfResultBuffers ()
 Returns the number of buffers that have been received. More...
 
SinkMediumTypes getSinkMediumType () override
 Returns the MediumType. More...
 
void cleanupBuffers ()
 Clears all resultBuffers. More...
 
void waitTillCompleted ()
 Waits in a blocking fashion until all the number of expected buffers have been received. More...
 
void waitTillCompletedOrTimeout (uint64_t timeoutInMilliseconds)
 Waits in a blocking fashion until all the number of expected buffers have been received or until the provided timeout is met. More...
 
void shutdown () override
 Shuts this sink down. 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< TestSinkcreate (uint64_t expectedTuples, const SchemaPtr &schema, const Runtime::NodeEnginePtr &engine, uint32_t numOfProducers=1)
 Factory method for a TestSink. More...
 

Public Attributes

std::recursive_mutex m
 
uint64_t numOfExpectedTuples
 
std::promise< uint64_t > completed
 
std::vector< Runtime::TupleBufferresultBuffers
 this vector must be cleanup by the test – do not rely on the engine to clean it up for you!! More...
 
Runtime::MemoryLayouts::MemoryLayoutPtr memoryLayout
 

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

A sink for testing that can be part of a query plan and enables executing queries and producing results.

Constructor & Destructor Documentation

◆ TestSink()

NES::TestSink::TestSink ( uint64_t  expectedTuples,
const SchemaPtr schema,
const Runtime::NodeEnginePtr nodeEngine,
uint32_t  numOfProducers = 1 
)

Constructor for a TestSink.

Parameters
expectedTuples
schema
nodeEngine
numOfProducers

References NES::Schema::COLUMNAR_LAYOUT, NES::Runtime::MemoryLayouts::ColumnLayout::create(), NES::Runtime::MemoryLayouts::RowLayout::create(), memoryLayout, NES::SinkMedium::nodeEngine, and NES::Schema::ROW_LAYOUT.

Here is the call graph for this function:

Member Function Documentation

◆ cleanupBuffers()

void NES::TestSink::cleanupBuffers ( )

Clears all resultBuffers.

References m, NES_DEBUG, and resultBuffers.

Referenced by shutdown().

Here is the caller graph for this function:

◆ create()

std::shared_ptr< TestSink > NES::TestSink::create ( uint64_t  expectedTuples,
const SchemaPtr schema,
const Runtime::NodeEnginePtr engine,
uint32_t  numOfProducers = 1 
)
static

Factory method for a TestSink.

Parameters
expectedTuples
schema
engine
numOfProducers
Returns

◆ get()

Runtime::TupleBuffer NES::TestSink::get ( uint64_t  index)

Returns the TupleBuffer at the index.

Parameters
index
Returns
Runtime::TupleBuffer

References index, m, and resultBuffers.

Referenced by getResultBuffer().

Here is the caller graph for this function:

◆ getNumberOfResultBuffers()

uint32_t NES::TestSink::getNumberOfResultBuffers ( )

Returns the number of buffers that have been received.

Returns
NumberOfResultBuffers

References m, and resultBuffers.

Referenced by getResultBuffers().

Here is the caller graph for this function:

◆ getResultBuffer()

Runtime::MemoryLayouts::TestTupleBuffer NES::TestSink::getResultBuffer ( uint64_t  index)

Returns the TestTupleBuffer at the index.

Parameters
index
Returns
TestTupleBuffer

References get(), index, and memoryLayout.

Referenced by getResultBuffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getResultBuffers()

std::vector< Runtime::MemoryLayouts::TestTupleBuffer > NES::TestSink::getResultBuffers ( )

Returns all buffers as TestTupleBuffers.

Returns
Vector of TestTupleBuffers

References getNumberOfResultBuffers(), and getResultBuffer().

Here is the call graph for this function:

◆ getSinkMediumType()

SinkMediumTypes NES::TestSink::getSinkMediumType ( )
overridevirtual

Returns the MediumType.

Returns
SinkMediumTypes

Implements NES::SinkMedium.

References NES::PRINT_SINK.

◆ setup()

void NES::TestSink::setup ( )
overridevirtual

Setup method.

Implements NES::SinkMedium.

◆ shutdown()

void NES::TestSink::shutdown ( )
overridevirtual

Shuts this sink down.

Implements NES::SinkMedium.

References cleanupBuffers().

Here is the call graph for this function:

◆ toString()

std::string NES::TestSink::toString ( ) const
overridevirtual

Creates a string representation.

Returns
String representation

Implements NES::SinkMedium.

◆ waitTillCompleted()

void NES::TestSink::waitTillCompleted ( )

Waits in a blocking fashion until all the number of expected buffers have been received.

References completed.

◆ waitTillCompletedOrTimeout()

void NES::TestSink::waitTillCompletedOrTimeout ( uint64_t  timeoutInMilliseconds)

Waits in a blocking fashion until all the number of expected buffers have been received or until the provided timeout is met.

References completed.

◆ writeData()

bool NES::TestSink::writeData ( Runtime::TupleBuffer inputBuffer,
Runtime::WorkerContext  
)
overridevirtual

Writes the input Buffer to the resultBuffer.

Parameters
inputBuffer
Returns
Success of write

Implements NES::SinkMedium.

References completed, NES::TestUtils::countTuples(), m, NES_DEBUG, NES_ERROR, numOfExpectedTuples, and resultBuffers.

Here is the call graph for this function:

Member Data Documentation

◆ completed

std::promise<uint64_t> NES::TestSink::completed

◆ m

std::recursive_mutex NES::TestSink::m
mutable

◆ memoryLayout

Runtime::MemoryLayouts::MemoryLayoutPtr NES::TestSink::memoryLayout

Referenced by getResultBuffer(), and TestSink().

◆ numOfExpectedTuples

uint64_t NES::TestSink::numOfExpectedTuples

Referenced by writeData().

◆ resultBuffers

std::vector<Runtime::TupleBuffer> NES::TestSink::resultBuffers

this vector must be cleanup by the test – do not rely on the engine to clean it up for you!!

Referenced by cleanupBuffers(), get(), getNumberOfResultBuffers(), and writeData().


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