Page 1 of 1

server routine vs parallel routine

Posted: Mon Dec 28, 2009 11:53 pm
by zulfi123786
I guess both kind of routines use the same BASIC code (Please correct if wrong), then why is it so that a server routine cannot be used in Parallel job and vice versa

Thank you.

Posted: Tue Dec 29, 2009 12:17 am
by ray.wurlod
You are completely wrong. Parallel routines must be written in C++ (definitely not any kind of BASIC language) then compiled and linked. Finally an entry must be placed in the repository recording the existence, location and required arguments of the routine.

Re: server routine vs parallel routine

Posted: Sun Jan 10, 2010 12:28 pm
by srikanth386
Server routines are written in Basic language and called in server job environment but the Parallel routines are written in c++ language(not in basic level language) and called din parallel job environment......

Posted: Sun Jan 10, 2010 1:37 pm
by ray.wurlod
Server routines can be called from server jobs, from sequences, from BASIC Transformer stages in parallel jobs and from server Transformer stages in server shared containers in parallel jobs.

Parallel routines can only be called from Transformer or certain custom stage types in parallel jobs.

Posted: Sat Apr 17, 2010 4:59 am
by zulfi123786
In server routines we can pass Nulls in arguments which can be checked inside the routine with IsNull() function but guess Nulls cannot be passed to and from parallel routines.... Am i right? guess we need to replace nulls with dummy values before passing as arguments.

Posted: Sat Apr 17, 2010 4:05 pm
by ray.wurlod
You're wrong. Nulls can be passed to parallel routines - but the routine has to be able to handle null arguments.

Posted: Sun Apr 18, 2010 8:58 am
by zulfi123786
okay. could you please brief me how to make the routine handle nulls or give me any reference to where it is documented.

Posted: Sun Apr 18, 2010 9:06 am
by zulfi123786
Wrote a small Parallel routine to get started with........ this one takes 2 integers and returns the sum........works fine Hurray!!!!
But due to some reason the routines with character arguments are not working
I am trying to pass 2 char arguments and then check if they are equal, the function returns an integer 1 if equal else 0;

#include <iostream.h>

int CharComp(char a, char b){
int c;
if (a==b) c=1;
else c=0;
return c;
}

The job aborts with this error :

Transformer_46: Failed to load the library "V0S46_checking1_Transformer_46.o"; either the directory containing the library file
is not on the library search path, or the library was compiled on a system
that is incompatible with this system: Could not load "V0S46_checking1_Transformer_46": rtld: 0712-001 Symbol CharComp__FUcT1 was referenced
from module /data/ds/hbus/projectlib/dpr_hbus_dev/RT_BP6744.O/V0S46_checking1_Transformer_46.o(), but a runtime definition
of the symbol was not found..


I am including the transformer code from the project directory:

==> cat V0S46_checking1_Transformer_46.trx.osh
transform -inputschema record
(
DELTA_FLAG:nullable string[];
)
-outputschema record
(
DELTA_FLAG:string[];
One:int32;
)
-expressionfile [&DSPXSourceDir]/V0S46_checking1_Transformer_46.trx
-flag compile
-staticobj '/data/ds/hbus/dev/landing/CharComp.o'
-compiler '/usr/vacpp/bin/xlC_r'
-compileopt '-O -c -qspill=32704'
-linker '/usr/vacpp/bin/xlC_r'
-linkopt '-G'
-name V0S46_checking1_Transformer_46
-dir /data/ds/hbus/projectlib/dpr_hbus_dev/RT_BP6744.O

vh2ldcdv02:{HBUS}:/data/ds/hbus/projectlib/dpr_hbus_dev/RT_SC6744
==> cat V0S46_checking1_Transformer_46.trx
//
// Generated file to implement the V0S46_repos_Transformer_46 transform operator.
//

// define external functions used
extern int32 CharComp(int32 a,int32 b);

// define our input/output link names
inputname 0 lnkItemRed;
outputname 0 DSLink47;

initialize {
// define our row rejected variable
int8 RowRejected0;

// define our null set variable
int8 NullSetVar0;

}

mainloop {
// initialise our row rejected variable
RowRejected0 = 1;

// evaluate columns (no constraints) for link: DSLink47
DSLink47.DELTA_FLAG = lnkItemRed.DELTA_FLAG;
DSLink47.One = CharComp(1 , 3);
writerecord 0;
RowRejected0 = 0;
}

finish {
}


I then changed the arguments type from char to int and rewrote the c++ code as :

#include <iostream.h>

int CharComp(int a,int b){
int c;
if (a==b) c=1;
else c=0;
return c;
}

It then worked fine ...............Could anyone tell me where the issue is?

Posted: Tue Apr 20, 2010 5:29 am
by zulfi123786
It worked when the type of input arguments in the routine was changed from char to char*, guess the transformer passes the address and not the values to the Parallel routine.
I would be very thankful if anyone helps me in handling NULL values in Parallel routines, when i pass NULL able columns as arguments how do we make C++ code to work with nulls and how do we check from inside the code if the value is NULL?

Thanks in advance

Posted: Tue Apr 20, 2010 5:47 am
by priyadarshikunal
In c++ its a mere empty string
for array the terminator will be at array[0], hence you can check if array[0]='\0'
or in case of pointers you can use .empty() to check if its null.

But i dont think you need to do anything special just to handle null values, it shouldn't drop any record.

Posted: Tue Apr 27, 2010 3:55 am
by zulfi123786
priyadarshikunal wrote:But i dont think you need to do anything special just to handle null values, it shouldn't drop any record.
Transformer_46,0: Field 'DELTA_FLAG' from input dataset '0' is NULL. Record dropped.

It is dropping records when null value is passed as an argument.

Posted: Tue Apr 27, 2010 4:02 am
by ray.wurlod
Read the manual. Null is represented internally as a byte with only its most singificant bit set.

Posted: Tue Apr 27, 2010 4:24 am
by zulfi123786
ray.wurlod wrote:Read the manual. Null is represented internally as a byte with only its most singificant bit set.
Could you please tell me which mannual would help me in this regard

Posted: Tue Apr 27, 2010 4:57 am
by ray.wurlod
Parallel Job Developer's Guide - search in it for "out of band null".

Posted: Sat Jan 01, 2011 3:40 am
by zulfi123786
ray.wurlod wrote:You're wrong. Nulls can be passed to parallel routines - but the routine has to be able to handle null arguments.
How do we make the Parallel routine handle nulls ? Is it by using makenull() function and convert the in-band nulls to out-band nulls and check the same in the routine?

thanks in advance.