Question about ExpressionFilter

31 views
Skip to first unread message

Jiang Mingwei

unread,
May 15, 2013, 5:35:49 PM5/15/13
to cascadi...@googlegroups.com
I'm debugging a very simple usage of ExpressionFilter as below:

I have a file with two columns, "col1" and "col2", both with integer values.

A sample file looks like below:

1 1
1 2
100 100
100 101
200 200
200 201


My code looks like:

Pipe testPipe = new Pipe("test_pipe");
ExpressionFilter filter = new ExpressionFilter("col1 == col2", new String[]{"col1", "col2"}, new Class[]{Long.class, Long.class});
testPipe = new Each(testPipe, new Fields("col1", "col2"), filter);

but the result is 

1 2
100 101
200 200
200 201

Notice it's not filtering out the "200 200" entry.

What could be the cause of this?

Thanks!

Chris K Wensel

unread,
May 15, 2013, 5:55:08 PM5/15/13
to cascadi...@googlegroups.com
is this guaranteed to be true in java?

boolean a =  new Long( 200 ) == new Long( 200 );

ckw

--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascading-use...@googlegroups.com.
To post to this group, send email to cascadi...@googlegroups.com.
Visit this group at http://groups.google.com/group/cascading-user?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


Jiang Mingwei

unread,
May 15, 2013, 6:35:28 PM5/15/13
to cascadi...@googlegroups.com
Oh, I didn't pay much attention it's going to convert it to a Long object instead of using the primitive. From java, I'm so used to use == for primitive comparison. and somehow I was under the impression that something like col1.equals(col2) doesn't work in ExpressionFilter. And most importantly, the "==" works every time in my local test cases using some dummy files I created. Until running in hadoop mode with real data, I found this issue.

and in the api doc for ExpressionFilter, it has the following which misled me as well.

Given an argument tuple with the fields "a" and "b", the following expression returns true:
a + b == $0 + $1

Would it be better for primitive types, we can still use "==" as it's so intuitive for java developers to use that to compare primitives?

Thanks!

在 2013年5月15日星期三UTC-7下午2时35分49秒,Jiang Mingwei写道:
Reply all
Reply to author
Forward
0 new messages