Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript猪UDF似乎什么也没有返回_Javascript_Hadoop_Apache Pig_User Defined Functions - Fatal编程技术网

Javascript猪UDF似乎什么也没有返回

Javascript猪UDF似乎什么也没有返回,javascript,hadoop,apache-pig,user-defined-functions,Javascript,Hadoop,Apache Pig,User Defined Functions,我有一个JS udf,看起来是这样的: is_match.outputSchema = 'matched:chararray, match_against:chararray, match_candidate:chararray'; function is_match (match_against, match_candidate) { var mre = new RegExp(match_against); return { word:mre.test(match_candid

我有一个JS udf,看起来是这样的:

is_match.outputSchema = 'matched:chararray, match_against:chararray, match_candidate:chararray';
function is_match (match_against, match_candidate) {
    var mre = new RegExp(match_against);
    return { word:mre.test(match_candidate), word:match_against, word:match_candidate };
}
叫它的猪看起来像这样:

register '<full path omitted>my_match.js' using javascript as js_match;

regexes = load <stuff> using PigStorage() as ( regex:chararray );
tests   = load <stuff> using PigStorage() as ( agent:chararray );

regexes = distinct regexes;
tests = distinct tests;

tests = cross regexes, tests;

matched = foreach tests generate js_match.is_match( regex, agent );
如果我将JS中的函数切换为这样:

is_match.outputSchema = 'foo:int';
function is_match (foo, bar) {
    return 1;
}
我实际上得到:

(1.0)
(1.0)
(1.0)
这正是我所期望的。然而,当我将JS的返回更改为返回我的任何实际数据时,它不会返回。如果我使用return语句“return 1;”,我得了1分

我不知道为什么我不能从更大的JS函数返回值,并且我能够返回通过该函数得到的不太复杂的数据。它应该每次都返回一些东西。出于我们的目的,测试如下所示:

(.oo,foobar)
(.oo,bazfoobar)
(.oo,foobarbaz)
([Ff]oo,Bar)
([Ff]oo,bar)

其中第一列是表达式,第二列是字符串。我只是想用一个巨大的表达式列表来浏览一个巨大的字符串列表。

当您将is\u match.outputSchema设置为T:matched:chararray,match\u对:chararray,match\u候选:chararray时会发生什么。看起来您正试图返回元组,但您的输出架构与之不匹配。您好,我确实切换到了您在此处指示的内容,并且我的返回记录从、、更改为。我承认我有点困惑。
(.oo,foobar)
(.oo,bazfoobar)
(.oo,foobarbaz)
([Ff]oo,Bar)
([Ff]oo,bar)