如何用C写DataStage Parallel Job 的Routine
1个回答
展开全部
1、用C开发Parallel Routine,需要用到 Makefile去编译C文件
创建C文件和Makefile文件,
C文件如下:
/*
//
// Example functions to be used as parallel external user functions in the transformer stage
//
// These are examples for Solaris, and are intended for demonstration purposes only.
//
*/
#include "string.h"
/*
// Case 1: Returning an int value
*/
int TrxFuncInt()
{
return -1034;
}
/*
// Case 2: Returning an unsigned char
*/
unsigned char TrxFuncUChar()
{
return (unsigned char)'&';
}
/*
// Case 3: Returning a long
*/
long long TrxFuncLong()
{
return 119921;
}
/*
// Case 4: Returning a char string
*/
char* TrxFuncCharStr()
{
return (char*)"TestString";
}
/*
// Case 5: A function taking one of each type of argument
*/
int TrxFuncAllArgs(signed char arg1, unsigned char arg2,
short arg3, unsigned short arg4,
int arg5, unsigned int arg6,
long long arg7, unsigned long long arg8,
float arg9,
double arg10,
char* arg11)
{
int retval;
/*
// this just checks the value of each input argument. If all the values are
// as expected then it returns 0, otherwise -1
*/
if (arg1 != '&') {
retval = -1;
} else if (arg2 != (unsigned char)'&') {
retval = -1;
} else if (arg3 != -3) {
retval = -1;
} else if (arg4 != 4) {
retval = -1;
} else if (arg5 != 5555) {
retval = -1;
} else if (arg6 != 6665) {
retval = -1;
} else if (arg7 != -77777) {
retval = -1;
} else if (arg8 != 87654) {
retval = -1;
} else if ((arg9 <= 2.2) || (arg9 >= 2.4)) {
retval = -1;
} else if (arg10 != 4.3) {
retval = -1;
} else if (strcmp(arg11, (char*)"TestString") != 0) {
retval = -1;
} else {
retval = 0;
}
return retval;
}
创建C文件和Makefile文件,
C文件如下:
/*
//
// Example functions to be used as parallel external user functions in the transformer stage
//
// These are examples for Solaris, and are intended for demonstration purposes only.
//
*/
#include "string.h"
/*
// Case 1: Returning an int value
*/
int TrxFuncInt()
{
return -1034;
}
/*
// Case 2: Returning an unsigned char
*/
unsigned char TrxFuncUChar()
{
return (unsigned char)'&';
}
/*
// Case 3: Returning a long
*/
long long TrxFuncLong()
{
return 119921;
}
/*
// Case 4: Returning a char string
*/
char* TrxFuncCharStr()
{
return (char*)"TestString";
}
/*
// Case 5: A function taking one of each type of argument
*/
int TrxFuncAllArgs(signed char arg1, unsigned char arg2,
short arg3, unsigned short arg4,
int arg5, unsigned int arg6,
long long arg7, unsigned long long arg8,
float arg9,
double arg10,
char* arg11)
{
int retval;
/*
// this just checks the value of each input argument. If all the values are
// as expected then it returns 0, otherwise -1
*/
if (arg1 != '&') {
retval = -1;
} else if (arg2 != (unsigned char)'&') {
retval = -1;
} else if (arg3 != -3) {
retval = -1;
} else if (arg4 != 4) {
retval = -1;
} else if (arg5 != 5555) {
retval = -1;
} else if (arg6 != 6665) {
retval = -1;
} else if (arg7 != -77777) {
retval = -1;
} else if (arg8 != 87654) {
retval = -1;
} else if ((arg9 <= 2.2) || (arg9 >= 2.4)) {
retval = -1;
} else if (arg10 != 4.3) {
retval = -1;
} else if (strcmp(arg11, (char*)"TestString") != 0) {
retval = -1;
} else {
retval = 0;
}
return retval;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询