language-extensions/R/src/RSession.cpp
//--------------------------------------------------------------------------------------------------
// Name: RSession::Init
//
// Description:
//  Initializes the R session, by storing all the information passed in.
//
:Init
Description:
Initializes the R session, by storing all the information passed in.
: Init Description : Initializes the R session by storing all the information passed in .
void RSession::Init(
	const SQLGUID &sessionId,
	SQLUSMALLINT  taskId,
	SQLUSMALLINT  numTasks,
	const SQLCHAR *script,
	SQLULEN       scriptLength,
	SQLUSMALLINT  inputSchemaColumnsNumber,
	SQLUSMALLINT  parametersNumber,
	const SQLCHAR *inputDataName,
	SQLUSMALLINT  inputDataNameLength,
	const SQLCHAR *outputDataName,
	SQLUSMALLINT  outputDataNameLength)
{
	LOG("RSession::Init");
	m_sessionId = sessionId;
	m_taskId = taskId;
	m_numTasks = numTasks;
	if (script == nullptr)
	{
		throw invalid_argument("Invalid Script, the Script value cannot be nullptr");
	}
	 scriptLength does not include the null terminator.
	m_script = string(static_cast<const char*>(
		static_cast<const void *>(script)), scriptLength);
	 Remove any carriage returns from the script.
	 RInside's script evaluation function cannot handle carriage returns - only new lines.
	m_script.erase(remove(m_script.begin(), m_script.end(), 0x0D), m_script.end());
	 Initialize the InputDataSet
	m_inputDataSet.Init(inputDataName, inputDataNameLength, inputSchemaColumnsNumber);
	 Initialize the OutputDataSet. It is initialized with 0 columns.
	 Columns will be added after the script is evaluated and as per what the
	 the script execution defines the OutputDataSet to be.
	m_outputDataSet.Init(outputDataName,
		outputDataNameLength,
		0);     schemaColumnsNumber
	 Initialize the parameters container.
	m_paramContainer.Init(parametersNumber);
}
void RSession :: Init ( const SQLGUID & sessionId , SQLUSMALLINT taskId , SQLUSMALLINT numTasks , const SQLCHAR * script , SQLULEN scriptLength , SQLUSMALLINT inputSchemaColumnsNumber , SQLUSMALLINT parametersNumber , const SQLCHAR * inputDataName , SQLUSMALLINT inputDataNameLength , const SQLCHAR * outputDataName , SQLUSMALLINT outputDataNameLength ) { LOG ( " " ) ; m_sessionId = sessionId ; m_taskId = taskId ; m_numTasks = numTasks ; if ( script == nullptr ) { throw invalid_argument ( " " ) ; } m_script = string ( static_cast < const char * > ( static_cast < const void * > ( script ) ) , scriptLength ) ; m_script . erase ( remove ( m_script . begin ( ) , m_script . end ( ) , 0x0D ) , m_script . end ( ) ) ; m_inputDataSet . Init ( inputDataName , inputDataNameLength , inputSchemaColumnsNumber ) ; m_outputDataSet . Init ( outputDataName , outputDataNameLength , 0 ) ; m_paramContainer . Init ( parametersNumber ) ; }
Name: RSession::Init
Description:
Initializes the R session, by storing all the information passed in.
Name : RSession :: Init Description : Initializes the R session by storing all the information passed in .
// Initialize the script // // scriptLength does not include the null terminator. // // Remove any carriage returns from the script. // RInside's script evaluation function cannot handle carriage returns - only new lines. // // Initialize the InputDataSet // // Initialize the OutputDataSet. It is initialized with 0 columns. // Columns will be added after the script is evaluated and as per what the // the script execution defines the OutputDataSet to be. // // schemaColumnsNumber // Initialize the parameters container. //