how can rturn all row in dataset include mult value example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how can rturn all row in dataset include mult value example

hagersaleh
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);    
Reply | Threaded
Open this post in threaded view
|

Re: how can rturn all row in dataset include mult value example

rmetzger0
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
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);




--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/how-can-rturn-all-row-in-dataset-include-mult-value-example-tp1289.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: how can rturn all row in dataset include mult value example

hagersaleh
Thank  very much