You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by hagersaleh <lo...@yahoo.com> on 2015/04/18 14:30:37 UTC

Why when the value that is used in filter getting from variable brings no result

when write this code value keep in linked list and return this value No
output code
 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()) ;
                         
                    }
            });  

but when write the coding  result coding =
(2,Customer#000000002,XSTf4&&NCwDVaWNe6tEgvwfmRchLXak,121.65,AUTOMOBILE)

 new FilterFunction<Customer>() {
                    @Override
                    public boolean filter(Customer c) {
                        
                          
                    return c.getField(4).equals("AUTOMOBILE") &&
c.getField(2).equals("XSTf4&&NCwDVaWNe6tEgvwfmRchLXak") ;
                         
                    }
            });  
      
coding

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);
    }\



--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Why-when-the-value-that-is-used-in-filter-getting-from-variable-brings-no-result-tp1098.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.