C execution (v0.9)

From Native Big Data Documentation
Jump to: navigation, search


EXCUTION API

LOCAL PARALELISM

  • $PAR( ... ) Executes several codes in different threads
var ar = $ARN(100)
$PAR( 
	{ int o = 0; for (int i=0     ;i<10000;i++) { o+=i; }; $SET(ar , 0, $INT(o) } ,
	{ int o = 0; for (int i=100000;i<20000;i++) { o+=i; }; $SET(ar , 1, $INT(o) } ,
	{ int o = 0; for (int i=200000;i<30000;i++) { o+=i; }; $SET(ar , 2, $INT(o) } ,
);
$TRACE(ar);
  • $PFOR( begin, cond, increment, code ) : Executes every iteration in a different thread
var ar = $ARN(100)
$PFOR(int j=0,j<3,j++, {
	int o = 0;
	for (int j= i*10000;j<10000*(i+1);j++) { o+=i; }; $SET(ar , 0, $INT(o));
});

REMOTE EXECUTION

  • $@( computer_urp, function_urp, function_parameters ) : Executes function in other computer
var t = $@( "urp:server:/other_node" ,  "urp:nfunction:/date" , $JSON(a, "[2018,01,01]");


TRACE

  • $TRACE(var_1, ... , var_n) : Prints a message in log console. All parameters must be vars ( text pointers must be created with $T() )
var s = $JSON(a, "{ 'a':1, 'b':3 ");
$TRACE($T("Object s has value: '" , s , $T("'") );


EXCEPTIONS

  • $TRY( code_1, code_2 ) : Executes code_1, if a excepcion is generaded then code_2 is executed. code_2 has a predefined _e var with the value of the exception.
	$TRY( 
		{
			var t = 100;
			var s = ff(t,12);
		}, {
			$TRACE($T("Exception throwed:"), _e);
		}
	);
  • $THROW(...) : Generates a exception from a message. The parameters are the same as printf function. Every time a native exception is throwed,

a system trace with the message and the file name an number of line is logged.

	$TRY( 
		{
			var t = 100;
			$THROW("Error, %d . Code of this function is not implemented yet" , $I(100) );
		}, {
			$TRACE($T("Exception throwed:"), _e);
		}
	);