flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chesnay Schepler (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-1910) why this code flink not reurn value when use variable in filter
Date Sat, 18 Apr 2015 14:44:58 GMT

    [ https://issues.apache.org/jira/browse/FLINK-1910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14501395#comment-14501395
] 

Chesnay Schepler commented on FLINK-1910:
-----------------------------------------

save the LinkedList in a field inside your filter function, or pass the values around as a
broadcast variables.

> why this code flink not reurn value when use variable in filter
> ---------------------------------------------------------------
>
>                 Key: FLINK-1910
>                 URL: https://issues.apache.org/jira/browse/FLINK-1910
>             Project: Flink
>          Issue Type: Bug
>            Reporter: hagersaleh
>
> {code:java}
> public static LinkedList values=new LinkedList<String>();
> public static void main(String[] args) throws Exception 
> {
> 	values.add("AUTOMOBILE");
> 	values.add("XSTf4&&NCwDVaWNe6tEgvwfmRchLXak");
> 	ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
> 	DataSet<Customer> customers = getCustomerDataSet(env);
> 	customers = customers.filter(
> 		new FilterFunction<Customer>() {
> 		@Override
> 		public boolean filter(Customer c) {
> 		return c.getField(4).equals(values.get(0).toString()) && c.getField(2).equals(values.get(1).toString())
;
> 		}
> 	});        
> 	System.out.println(customers.print());
> 	customers.writeAsCsv("/home/hadoop/Desktop/Dataset/output.csv", "\n", "|");
> 	env.execute();  
> 	}
> public static class Customer extends Tuple5<Long,String,String,String,String> {
> }
> private static DataSet<Customer> getCustomerDataSet(ExecutionEnvironment env) {
> 	return env.readCsvFile("/home/hadoop/Desktop/Dataset/customer.csv")
> 		.fieldDelimiter('|')
> 		.includeFields("11100110").ignoreFirstLine()
> 		.tupleType(Customer.class);
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message