want return all row include all value in valuesfromsubquery this code just return row include frist value BUILDING
public static ArrayList<String> valuesfromsubquery = new ArrayList<String>(); valuesfromsubquery.add("BUILDING"); valuesfromsubquery.add("MACHINERY"); valuesfromsubquery.add("AUTOMOBILE"); DataSet<Customer3> customers=env.readCsvFile("/home/hadoop/Desktop/Dataset/customer.csv") .fieldDelimiter('|') .includeFields(mask).ignoreFirstLine() .tupleType(Customer3.class); customers = customers.filter(new FilterFunction<Customer3>() { @Override public boolean filter(Customer3 c) { for(int i=0;i<valuesfromsubquery.size();i++) return c.getField(index1).toString().equals(valuesfromsubquery.get(i)); return true; } }); customers.print(); customers.writeAsCsv("/home/hadoop/Desktop/Dataset/out2.csv", "\n", "|",WriteMode.OVERWRITE); |
Hi, in the for-loop you are always immediately returning. The code is only getting i=0 (which is BUILDING). You need to rework the for loop so that its not immediately returning. Maybe for(int i=0;i<valuesfromsubquery.size();i++) { if(c.getField(index1).toString().equals(valuesfromsubquery.get(i))) { return true; } } return false; On Tue, May 19, 2015 at 9:53 AM, hagersaleh <[hidden email]> wrote: want return all row include all value in valuesfromsubquery this code just |
Thank very much
|
Free forum by Nabble | Edit this page |