问:
MapReduce program in Hadoop that implements a simple “People You Might Know”
The input file contains the adjacency list and has multiple lines in the following format:

```<code>import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class Friends
{

public class FriendsMap extends Mapper < LongWritable, Text, Text, IntWritable >
    {
    private Text friendsAB;
    private Text friendsBA;
    private IntWritable one = new IntWritable(1);
    private IntWritable oneLess = new IntWritable(-999999999);
        //@SuppressWarnings("null")
        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
        {
            String friendsOfA[] = null;     //This will be all of the friends of the user in this row
            String oneRow[] = value.toString().split("\t,");    //Break the row up into users IDs
            String userA = oneRow[0];       //This is the main user for this row
            for (int i=1; i < oneRow.length; i++)   //Create an array of the rest of the users in this row
            {
                friendsOfA[i-1] = oneRow[i];
            }
            for (int i=0; i < oneRow.length; i++)   //Output the main user in pairs with all friends plus a lagre negative #
            {
                friendsAB.set(userA + " " + friendsOfA[i]);
                context.write(friendsAB, oneLess);
                System.out.println(friendsAB + " " + oneLess);
            }
            for (int i = 0; i < friendsOfA.length; i++)     //Output each friend pair plus the number 1
            {
                for (int j = i + 1; j < friendsOfA.length; j++)
                {
                    friendsAB.set(friendsOfA[i] + " " + friendsOfA[j]);
                    friendsBA.set(friendsOfA[j] + " " + friendsOfA[i]);
                    context.write(friendsAB, one);
                    context.write(friendsBA, one);
                    System.out.println(friendsAB + " " + one);
                    System.out.println(friendsBA + " " + one);
                }
            }
        }
    }

class FriendReducer extends Reducer < Text, IntWritable, Text, IntWritable >
    {
        private IntWritable result = new IntWritable();
        @Override
        public void reduce( Text key, Iterable < IntWritable > values, Context context) throws IOException, InterruptedException
        {
            int sum = 0;
            for (IntWritable val : values)
            {
                sum += val.get();
            }
            if (sum > 1)
            {
                result.set( sum);
                context.write( key, result);
            }
            //At this point I have all pairs of users with recomenede friends and a count of how many times they each
            //friend has been recomended to a user.
            //I need to sort by user and then by number of recomendations.
            //Then print the user <tab> all recomendations with commas between them.
        }
    }

public static void main( String[] args) throws Exception
    {
        Configuration conf = new Configuration();
        Job job = Job.getInstance( conf, "Friends");
        job.setJarByClass(Friends.class);
        FileInputFormat.addInputPath( job, new Path("input"));
        FileOutputFormat.setOutputPath( job, new Path("output"));
        job.setMapperClass( FriendsMap.class);
        job.setCombinerClass( FriendReducer.class);
        job.setReducerClass( FriendReducer.class);
        job.setOutputKeyClass( Text.class);
        job.setOutputValueClass( IntWritable.class);

        System.exit( job.waitForCompletion( true) ? 0 : 1);
    }
}
</code>```

This is the errors I am getting in the console.

17/11/15 16:05:51 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/15 16:06:54 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/15
  16:06:54 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/15 16:06:54 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/15 16:06:55
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/15 16:06:55
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/15
  16:07:05 INFO mapred.JobClient: Running job: job_local426825952_0001
  17/11/15 16:07:05 INFO mapred.LocalJobRunner: OutputCommitter set in
  config null 17/11/15 16:07:05 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Starting task:
  attempt_local426825952_0001_m_000000_0 17/11/15 16:07:05 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/15 16:07:05 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/15 16:07:05 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@670217f0
  17/11/15 16:07:05 INFO mapred.LocalJobRunner: Starting task:
  attempt_local426825952_0001_m_000001_0 17/11/15 16:07:05 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/15 16:07:05 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@1688e9ff 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Map task executor complete.
  17/11/15 16:07:05 WARN mapred.LocalJobRunner: job_local426825952_0001
  java.lang.Exception: java.lang.RuntimeException:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.RuntimeException:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:631)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)   at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) Caused by:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  java.lang.Class.getConstructor0(Class.java:2849)  at
  java.lang.Class.getDeclaredConstructor(Class.java:2053)   at
  org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
    ... 8 more 17/11/15 16:07:06 INFO mapred.JobClient:  map 0% reduce 0%
  17/11/15 16:07:06 INFO mapred.JobClient: Job complete:
  job_local426825952_0001 17/11/15 16:07:06 INFO mapred.JobClient:
  Counters: 0

After changing the classes to Static this is the new errors.

17/11/16 04:28:50 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/16 04:28:52 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/16
  04:28:52 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/16 04:28:52 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/16 04:28:52
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/16 04:28:53
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: OutputCommitter set in config
  null 17/11/16 04:28:54 INFO mapred.JobClient: Running job:
  job_local1593958162_0001 17/11/16 04:28:54 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: Starting task:
  attempt_local1593958162_0001_m_000000_0 17/11/16 04:28:54 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 04:28:54 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/16 04:28:54 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@57d51956
  17/11/16 04:28:54 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt:0+4106187
  17/11/16 04:28:54 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 04:28:54
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 04:28:55 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 04:28:55 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Starting task:
  attempt_local1593958162_0001_m_000001_0 17/11/16 04:28:55 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 04:28:55 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@774140b3 17/11/16
  04:28:55 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt~:0+0
  17/11/16 04:28:55 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 04:28:55
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 04:28:55 INFO
  mapred.JobClient:  map 0% reduce 0% 17/11/16 04:28:55 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 04:28:55 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner:  17/11/16 04:28:55 INFO mapred.MapTask:
  Starting flush of map output 17/11/16 04:28:55 INFO mapred.Task:
  Task:attempt_local1593958162_0001_m_000001_0 is done. And is in the
  process of commiting 17/11/16 04:28:55 INFO mapred.LocalJobRunner:
  17/11/16 04:28:55 INFO mapred.Task: Task
  'attempt_local1593958162_0001_m_000001_0' done. 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Finishing task:
  attempt_local1593958162_0001_m_000001_0 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Map task executor complete. 17/11/16 04:28:55
  WARN mapred.LocalJobRunner: job_local1593958162_0001
  java.lang.Exception: java.lang.NullPointerException   at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.NullPointerException     at
  Friends$FriendsMap.map(Friends.java:36)   at
  Friends$FriendsMap.map(Friends.java:1)    at
  org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:140)   at
  org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:672)   at
  org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)    at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) 17/11/16 04:28:56 INFO
  mapred.JobClient: Job complete: job_local1593958162_0001 17/11/16
  04:28:56 INFO mapred.JobClient: Counters: 16 17/11/16 04:28:56 INFO
  mapred.JobClient:   File System Counters 17/11/16 04:28:56 INFO
  mapred.JobClient:     FILE: Number of bytes read=4674 17/11/16
  04:28:56 INFO mapred.JobClient:     FILE: Number of bytes
  written=139416 17/11/16 04:28:56 INFO mapred.JobClient:     FILE:
  Number of read operations=0 17/11/16 04:28:56 INFO mapred.JobClient:

  FILE: Number of large read operations=0 17/11/16 04:28:56 INFO
  mapred.JobClient:     FILE: Number of write operations=0 17/11/16
  04:28:56 INFO mapred.JobClient:   Map-Reduce Framework 17/11/16
  04:28:56 INFO mapred.JobClient:     Map input records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Map output records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Map output bytes=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Input split bytes=125 17/11/16
  04:28:56 INFO mapred.JobClient:     Combine input records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Combine output records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Spilled Records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     CPU time spent (ms)=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0
  17/11/16 04:28:56 INFO mapred.JobClient:     Virtual memory (bytes)
  snapshot=0 17/11/16 04:28:56 INFO mapred.JobClient:     Total
  committed heap usage (bytes)=363696128

I think this is the part that is the most troublesome.

Screen Shot of some errors

This is the updated code.

```<code>public static class FriendsMap extends Mapper < LongWritable, Text, Text, IntWritable >
    {
        //@SuppressWarnings("null")
        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
        {

            String friendsOfA[];    //This will be all of the friends of the user in this row
            friendsOfA = new String[] {};
            String friendsAB        = "1";      //This will be used to create pairs of users
            String friendsBA        = "2";      //This will be used to create pairs of users
            Text pairA;
            Text pairB;
            IntWritable one     = new IntWritable(1);           //1 if they are not an existing pair here
            IntWritable oneLess = new IntWritable(-999999999);  // if they are an existing pair

            String oneRow[] = value.toString().split("\t,");    //Break the row up into users IDs
            Text userA = new Text(oneRow[0]);                                   //This is the main user for this row
            for (int i=1; i < oneRow.length; i++)   //Create an array of the rest of the users in this row
            {
                friendsOfA[i-1] = oneRow[i];
            }
            for (int i=0; i < oneRow.length; i++)   //Output the main user in pairs with all friends plus a large negative #
            {                                       //We do not want to recommend them as friends because they are friends
                Text FOA = new Text (friendsOfA[i]);
                friendsAB = (userA + " " + FOA);
                Text pair = new Text (friendsAB);
                context.write(pair, oneLess);
                System.out.println(pair + " " + oneLess);
            }
            for (int i = 0; i < friendsOfA.length; i++)     //Output each friend pair plus the number 1
            {                                               //We want to recommend them as potential friends
                for (int j = i + 1; j < friendsOfA.length; j++)
                {
                    Text FOA = new Text (friendsOfA[i]);
                    Text FOB = new Text (friendsOfA[j]);
                    friendsAB = (FOA + " " + FOB);
                    friendsBA = (FOB + " " + FOA);
                    pairA = new Text (friendsAB);
                    pairB = new Text (friendsBA);
                    context.write(pairA, one);
                    context.write(pairB, one);
                    System.out.println(pairA + " " + one);
                    System.out.println(pairB + " " + one);
                }
            }
        }
    }
</code>```

And this is the new set of errors.

17/11/16 11:59:25 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/16 11:59:27 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/16
  11:59:27 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/16 11:59:27 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/16 11:59:27
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/16 11:59:27
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/16
  11:59:29 INFO mapred.JobClient: Running job: job_local1899187381_0001
  17/11/16 11:59:29 INFO mapred.LocalJobRunner: OutputCommitter set in
  config null 17/11/16 11:59:29 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/16
  11:59:29 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/16
  11:59:29 INFO mapred.LocalJobRunner: Starting task:
  attempt_local1899187381_0001_m_000000_0 17/11/16 11:59:29 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 11:59:29 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/16 11:59:29 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@4f94aaa1
  17/11/16 11:59:29 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt:0+4106187
  17/11/16 11:59:29 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 11:59:29
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 11:59:29 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 11:59:29 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 11:59:29 INFO
  mapred.LocalJobRunner: Starting task:
  attempt_local1899187381_0001_m_000001_0 17/11/16 11:59:29 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 11:59:29 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@622ecc38 17/11/16
  11:59:29 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt~:0+0
  17/11/16 11:59:29 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 11:59:29
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 11:59:30 INFO
  mapred.JobClient:  map 0% reduce 0% 17/11/16 11:59:30 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 11:59:30 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner:  17/11/16 11:59:30 INFO mapred.MapTask:
  Starting flush of map output 17/11/16 11:59:30 INFO mapred.Task:
  Task:attempt_local1899187381_0001_m_000001_0 is done. And is in the
  process of commiting 17/11/16 11:59:30 INFO mapred.LocalJobRunner:
  17/11/16 11:59:30 INFO mapred.Task: Task
  'attempt_local1899187381_0001_m_000001_0' done. 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner: Finishing task:
  attempt_local1899187381_0001_m_000001_0 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner: Map task executor complete. 17/11/16 11:59:30
  WARN mapred.LocalJobRunner: job_local1899187381_0001
  java.lang.Exception: java.lang.ArrayIndexOutOfBoundsException: 0  at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.ArrayIndexOutOfBoundsException: 0    at
  Friends$FriendsMap.map(Friends.java:41)   at
  Friends$FriendsMap.map(Friends.java:1)    at
  org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:140)   at
  org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:672)   at
  org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)    at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) 17/11/16 11:59:31 INFO
  mapred.JobClient: Job complete: job_local1899187381_0001 17/11/16
  11:59:31 INFO mapred.JobClient: Counters: 16 17/11/16 11:59:31 INFO
  mapred.JobClient:   File System Counters 17/11/16 11:59:31 INFO
  mapred.JobClient:     FILE: Number of bytes read=4674 17/11/16
  11:59:31 INFO mapred.JobClient:     FILE: Number of bytes
  written=139416 17/11/16 11:59:31 INFO mapred.JobClient:     FILE:
  Number of read operations=0 17/11/16 11:59:31 INFO mapred.JobClient:

  FILE: Number of large read operations=0 17/11/16 11:59:31 INFO
  mapred.JobClient:     FILE: Number of write operations=0 17/11/16
  11:59:31 INFO mapred.JobClient:   Map-Reduce Framework 17/11/16
  11:59:31 INFO mapred.JobClient:     Map input records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Map output records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Map output bytes=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Input split bytes=125 17/11/16
  11:59:31 INFO mapred.JobClient:     Combine input records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Combine output records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Spilled Records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     CPU time spent (ms)=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0
  17/11/16 11:59:31 INFO mapred.JobClient:     Virtual memory (bytes)
  snapshot=0 17/11/16 11:59:31 INFO mapred.JobClient:     Total
  committed heap usage (bytes)=363618304

答:
You've delcared the classes as inner classes, which might be causing issues. An inner class can only exist within an instance of the enclosing class.

Its probably easier to change them to static classes.

```<code>public class Friends {

    public static class FriendsMap extends Mapper <...> {}

    public static class FriendReducer extends Reducer <...> {}

    public static void main( String[] args) throws Exception {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "Friends");
        job.setJarByClass(Friends.class);
        FileInputFormat.addInputPath(job, new Path("input"));
        FileOutputFormat.setOutputPath(job, new Path("output"));
        job.setMapperClass(FriendsMap.class);
        job.setCombinerClass(FriendReducer.class);
        job.setReducerClass(FriendReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        System.exit( job.waitForCompletion( true) ? 0 : 1);
    }
}
</code>```

Body:
The input file contains the adjacency list and has multiple lines in the following format:

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class Friends
{

public class FriendsMap extends Mapper < LongWritable, Text, Text, IntWritable >
    {
    private Text friendsAB;
    private Text friendsBA;
    private IntWritable one = new IntWritable(1);
    private IntWritable oneLess = new IntWritable(-999999999);
        //@SuppressWarnings("null")
        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
        {
            String friendsOfA[] = null;     //This will be all of the friends of the user in this row
            String oneRow[] = value.toString().split("\t,");    //Break the row up into users IDs
            String userA = oneRow[0];       //This is the main user for this row
            for (int i=1; i < oneRow.length; i++)   //Create an array of the rest of the users in this row
            {
                friendsOfA[i-1] = oneRow[i];
            }
            for (int i=0; i < oneRow.length; i++)   //Output the main user in pairs with all friends plus a lagre negative #
            {
                friendsAB.set(userA + " " + friendsOfA[i]);
                context.write(friendsAB, oneLess);
                System.out.println(friendsAB + " " + oneLess);
            }
            for (int i = 0; i < friendsOfA.length; i++)     //Output each friend pair plus the number 1
            {
                for (int j = i + 1; j < friendsOfA.length; j++)
                {
                    friendsAB.set(friendsOfA[i] + " " + friendsOfA[j]);
                    friendsBA.set(friendsOfA[j] + " " + friendsOfA[i]);
                    context.write(friendsAB, one);
                    context.write(friendsBA, one);
                    System.out.println(friendsAB + " " + one);
                    System.out.println(friendsBA + " " + one);
                }
            }
        }
    }

class FriendReducer extends Reducer < Text, IntWritable, Text, IntWritable >
    {
        private IntWritable result = new IntWritable();
        @Override
        public void reduce( Text key, Iterable < IntWritable > values, Context context) throws IOException, InterruptedException
        {
            int sum = 0;
            for (IntWritable val : values)
            {
                sum += val.get();
            }
            if (sum > 1)
            {
                result.set( sum);
                context.write( key, result);
            }
            //At this point I have all pairs of users with recomenede friends and a count of how many times they each
            //friend has been recomended to a user.
            //I need to sort by user and then by number of recomendations.
            //Then print the user <tab> all recomendations with commas between them.
        }
    }

public static void main( String[] args) throws Exception
    {
        Configuration conf = new Configuration();
        Job job = Job.getInstance( conf, "Friends");
        job.setJarByClass(Friends.class);
        FileInputFormat.addInputPath( job, new Path("input"));
        FileOutputFormat.setOutputPath( job, new Path("output"));
        job.setMapperClass( FriendsMap.class);
        job.setCombinerClass( FriendReducer.class);
        job.setReducerClass( FriendReducer.class);
        job.setOutputKeyClass( Text.class);
        job.setOutputValueClass( IntWritable.class);

        System.exit( job.waitForCompletion( true) ? 0 : 1);
    }
}

This is the errors I am getting in the console.

17/11/15 16:05:51 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/15 16:06:54 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/15
  16:06:54 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/15 16:06:54 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/15 16:06:55
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/15 16:06:55
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/15
  16:07:05 INFO mapred.JobClient: Running job: job_local426825952_0001
  17/11/15 16:07:05 INFO mapred.LocalJobRunner: OutputCommitter set in
  config null 17/11/15 16:07:05 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Starting task:
  attempt_local426825952_0001_m_000000_0 17/11/15 16:07:05 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/15 16:07:05 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/15 16:07:05 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@670217f0
  17/11/15 16:07:05 INFO mapred.LocalJobRunner: Starting task:
  attempt_local426825952_0001_m_000001_0 17/11/15 16:07:05 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/15 16:07:05 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@1688e9ff 17/11/15
  16:07:05 INFO mapred.LocalJobRunner: Map task executor complete.
  17/11/15 16:07:05 WARN mapred.LocalJobRunner: job_local426825952_0001
  java.lang.Exception: java.lang.RuntimeException:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.RuntimeException:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:131)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:631)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)   at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) Caused by:
  java.lang.NoSuchMethodException: Friends$FriendsMap.()  at
  java.lang.Class.getConstructor0(Class.java:2849)  at
  java.lang.Class.getDeclaredConstructor(Class.java:2053)   at
  org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:125)
    ... 8 more 17/11/15 16:07:06 INFO mapred.JobClient:  map 0% reduce 0%
  17/11/15 16:07:06 INFO mapred.JobClient: Job complete:
  job_local426825952_0001 17/11/15 16:07:06 INFO mapred.JobClient:
  Counters: 0

After changing the classes to Static this is the new errors.

17/11/16 04:28:50 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/16 04:28:52 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/16
  04:28:52 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/16 04:28:52 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/16 04:28:52
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/16 04:28:53
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: OutputCommitter set in config
  null 17/11/16 04:28:54 INFO mapred.JobClient: Running job:
  job_local1593958162_0001 17/11/16 04:28:54 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/16
  04:28:54 INFO mapred.LocalJobRunner: Starting task:
  attempt_local1593958162_0001_m_000000_0 17/11/16 04:28:54 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 04:28:54 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/16 04:28:54 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@57d51956
  17/11/16 04:28:54 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt:0+4106187
  17/11/16 04:28:54 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 04:28:54
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 04:28:55 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 04:28:55 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Starting task:
  attempt_local1593958162_0001_m_000001_0 17/11/16 04:28:55 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 04:28:55 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@774140b3 17/11/16
  04:28:55 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt~:0+0
  17/11/16 04:28:55 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 04:28:55
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 04:28:55 INFO
  mapred.JobClient:  map 0% reduce 0% 17/11/16 04:28:55 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 04:28:55 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner:  17/11/16 04:28:55 INFO mapred.MapTask:
  Starting flush of map output 17/11/16 04:28:55 INFO mapred.Task:
  Task:attempt_local1593958162_0001_m_000001_0 is done. And is in the
  process of commiting 17/11/16 04:28:55 INFO mapred.LocalJobRunner:
  17/11/16 04:28:55 INFO mapred.Task: Task
  'attempt_local1593958162_0001_m_000001_0' done. 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Finishing task:
  attempt_local1593958162_0001_m_000001_0 17/11/16 04:28:55 INFO
  mapred.LocalJobRunner: Map task executor complete. 17/11/16 04:28:55
  WARN mapred.LocalJobRunner: job_local1593958162_0001
  java.lang.Exception: java.lang.NullPointerException   at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.NullPointerException     at
  Friends$FriendsMap.map(Friends.java:36)   at
  Friends$FriendsMap.map(Friends.java:1)    at
  org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:140)   at
  org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:672)   at
  org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)    at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) 17/11/16 04:28:56 INFO
  mapred.JobClient: Job complete: job_local1593958162_0001 17/11/16
  04:28:56 INFO mapred.JobClient: Counters: 16 17/11/16 04:28:56 INFO
  mapred.JobClient:   File System Counters 17/11/16 04:28:56 INFO
  mapred.JobClient:     FILE: Number of bytes read=4674 17/11/16
  04:28:56 INFO mapred.JobClient:     FILE: Number of bytes
  written=139416 17/11/16 04:28:56 INFO mapred.JobClient:     FILE:
  Number of read operations=0 17/11/16 04:28:56 INFO mapred.JobClient:

  FILE: Number of large read operations=0 17/11/16 04:28:56 INFO
  mapred.JobClient:     FILE: Number of write operations=0 17/11/16
  04:28:56 INFO mapred.JobClient:   Map-Reduce Framework 17/11/16
  04:28:56 INFO mapred.JobClient:     Map input records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Map output records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Map output bytes=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Input split bytes=125 17/11/16
  04:28:56 INFO mapred.JobClient:     Combine input records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Combine output records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Spilled Records=0 17/11/16
  04:28:56 INFO mapred.JobClient:     CPU time spent (ms)=0 17/11/16
  04:28:56 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0
  17/11/16 04:28:56 INFO mapred.JobClient:     Virtual memory (bytes)
  snapshot=0 17/11/16 04:28:56 INFO mapred.JobClient:     Total
  committed heap usage (bytes)=363696128

I think this is the part that is the most troublesome.

Screen Shot of some errors

This is the updated code.

public static class FriendsMap extends Mapper < LongWritable, Text, Text, IntWritable >
    {
        //@SuppressWarnings("null")
        @Override
        public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException
        {

            String friendsOfA[];    //This will be all of the friends of the user in this row
            friendsOfA = new String[] {};
            String friendsAB        = "1";      //This will be used to create pairs of users
            String friendsBA        = "2";      //This will be used to create pairs of users
            Text pairA;
            Text pairB;
            IntWritable one     = new IntWritable(1);           //1 if they are not an existing pair here
            IntWritable oneLess = new IntWritable(-999999999);  // if they are an existing pair

            String oneRow[] = value.toString().split("\t,");    //Break the row up into users IDs
            Text userA = new Text(oneRow[0]);                                   //This is the main user for this row
            for (int i=1; i < oneRow.length; i++)   //Create an array of the rest of the users in this row
            {
                friendsOfA[i-1] = oneRow[i];
            }
            for (int i=0; i < oneRow.length; i++)   //Output the main user in pairs with all friends plus a large negative #
            {                                       //We do not want to recommend them as friends because they are friends
                Text FOA = new Text (friendsOfA[i]);
                friendsAB = (userA + " " + FOA);
                Text pair = new Text (friendsAB);
                context.write(pair, oneLess);
                System.out.println(pair + " " + oneLess);
            }
            for (int i = 0; i < friendsOfA.length; i++)     //Output each friend pair plus the number 1
            {                                               //We want to recommend them as potential friends
                for (int j = i + 1; j < friendsOfA.length; j++)
                {
                    Text FOA = new Text (friendsOfA[i]);
                    Text FOB = new Text (friendsOfA[j]);
                    friendsAB = (FOA + " " + FOB);
                    friendsBA = (FOB + " " + FOA);
                    pairA = new Text (friendsAB);
                    pairB = new Text (friendsBA);
                    context.write(pairA, one);
                    context.write(pairB, one);
                    System.out.println(pairA + " " + one);
                    System.out.println(pairB + " " + one);
                }
            }
        }
    }

And this is the new set of errors.

17/11/16 11:59:25 WARN util.NativeCodeLoader: Unable to load
  native-hadoop library for your platform... using builtin-java classes
  where applicable 17/11/16 11:59:27 INFO Configuration.deprecation:
  session.id is deprecated. Instead, use dfs.metrics.session-id 17/11/16
  11:59:27 INFO jvm.JvmMetrics: Initializing JVM Metrics with
  processName=JobTracker, sessionId= 17/11/16 11:59:27 WARN
  mapred.JobClient: Use GenericOptionsParser for parsing the arguments.
  Applications should implement Tool for the same. 17/11/16 11:59:27
  WARN mapred.JobClient: No job jar file set.  User classes may not be
  found. See JobConf(Class) or JobConf#setJar(String). 17/11/16 11:59:27
  INFO input.FileInputFormat: Total input paths to process : 2 17/11/16
  11:59:29 INFO mapred.JobClient: Running job: job_local1899187381_0001
  17/11/16 11:59:29 INFO mapred.LocalJobRunner: OutputCommitter set in
  config null 17/11/16 11:59:29 INFO mapred.LocalJobRunner:
  OutputCommitter is
  org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter 17/11/16
  11:59:29 INFO mapred.LocalJobRunner: Waiting for map tasks 17/11/16
  11:59:29 INFO mapred.LocalJobRunner: Starting task:
  attempt_local1899187381_0001_m_000000_0 17/11/16 11:59:29 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 11:59:29 INFO util.ProcessTree: setsid exited with exit code
  0 17/11/16 11:59:29 INFO mapred.Task:  Using ResourceCalculatorPlugin
  : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@4f94aaa1
  17/11/16 11:59:29 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt:0+4106187
  17/11/16 11:59:29 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 11:59:29
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 11:59:29 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 11:59:29 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 11:59:29 INFO
  mapred.LocalJobRunner: Starting task:
  attempt_local1899187381_0001_m_000001_0 17/11/16 11:59:29 WARN
  mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is
  deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
  17/11/16 11:59:29 INFO mapred.Task:  Using ResourceCalculatorPlugin :
  org.apache.hadoop.util.LinuxResourceCalculatorPlugin@622ecc38 17/11/16
  11:59:29 INFO mapred.MapTask: Processing split:
  file:/home/cloudera/workspace/Assignment4/input/Sample4.txt~:0+0
  17/11/16 11:59:29 INFO mapred.MapTask: Map output collector class =
  org.apache.hadoop.mapred.MapTask$MapOutputBuffer 17/11/16 11:59:29
  INFO mapred.MapTask: io.sort.mb = 100 17/11/16 11:59:30 INFO
  mapred.JobClient:  map 0% reduce 0% 17/11/16 11:59:30 INFO
  mapred.MapTask: data buffer = 79691776/99614720 17/11/16 11:59:30 INFO
  mapred.MapTask: record buffer = 262144/327680 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner:  17/11/16 11:59:30 INFO mapred.MapTask:
  Starting flush of map output 17/11/16 11:59:30 INFO mapred.Task:
  Task:attempt_local1899187381_0001_m_000001_0 is done. And is in the
  process of commiting 17/11/16 11:59:30 INFO mapred.LocalJobRunner:
  17/11/16 11:59:30 INFO mapred.Task: Task
  'attempt_local1899187381_0001_m_000001_0' done. 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner: Finishing task:
  attempt_local1899187381_0001_m_000001_0 17/11/16 11:59:30 INFO
  mapred.LocalJobRunner: Map task executor complete. 17/11/16 11:59:30
  WARN mapred.LocalJobRunner: job_local1899187381_0001
  java.lang.Exception: java.lang.ArrayIndexOutOfBoundsException: 0  at
  org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:406)
  Caused by: java.lang.ArrayIndexOutOfBoundsException: 0    at
  Friends$FriendsMap.map(Friends.java:41)   at
  Friends$FriendsMap.map(Friends.java:1)    at
  org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:140)   at
  org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:672)   at
  org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)    at
  org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:268)
    at
  java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)     at
  java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745) 17/11/16 11:59:31 INFO
  mapred.JobClient: Job complete: job_local1899187381_0001 17/11/16
  11:59:31 INFO mapred.JobClient: Counters: 16 17/11/16 11:59:31 INFO
  mapred.JobClient:   File System Counters 17/11/16 11:59:31 INFO
  mapred.JobClient:     FILE: Number of bytes read=4674 17/11/16
  11:59:31 INFO mapred.JobClient:     FILE: Number of bytes
  written=139416 17/11/16 11:59:31 INFO mapred.JobClient:     FILE:
  Number of read operations=0 17/11/16 11:59:31 INFO mapred.JobClient:

  FILE: Number of large read operations=0 17/11/16 11:59:31 INFO
  mapred.JobClient:     FILE: Number of write operations=0 17/11/16
  11:59:31 INFO mapred.JobClient:   Map-Reduce Framework 17/11/16
  11:59:31 INFO mapred.JobClient:     Map input records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Map output records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Map output bytes=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Input split bytes=125 17/11/16
  11:59:31 INFO mapred.JobClient:     Combine input records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Combine output records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Spilled Records=0 17/11/16
  11:59:31 INFO mapred.JobClient:     CPU time spent (ms)=0 17/11/16
  11:59:31 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0
  17/11/16 11:59:31 INFO mapred.JobClient:     Virtual memory (bytes)
  snapshot=0 17/11/16 11:59:31 INFO mapred.JobClient:     Total
  committed heap usage (bytes)=363618304

Body:
You've delcared the classes as inner classes, which might be causing issues. An inner class can only exist within an instance of the enclosing class.

Its probably easier to change them to static classes.

public class Friends {

    public static class FriendsMap extends Mapper <...> {}

    public static class FriendReducer extends Reducer <...> {}

    public static void main( String[] args) throws Exception {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "Friends");
        job.setJarByClass(Friends.class);
        FileInputFormat.addInputPath(job, new Path("input"));
        FileOutputFormat.setOutputPath(job, new Path("output"));
        job.setMapperClass(FriendsMap.class);
        job.setCombinerClass(FriendReducer.class);
        job.setReducerClass(FriendReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        System.exit( job.waitForCompletion( true) ? 0 : 1);
    }
}


来源: stackexchange

问:
Getting a value sent by SignalR with AngularJS
I'm trying to write a very simple message on the screen that when signalr send a value this message gets updated.

I have a very simple Hub:

```<code>public class Chat : Hub
{
    public Task Send(string message)
    {
        return Clients.All.InvokeAsync("Send", message);
    }
}
</code>```

On the front-end I have the following html:

```<code><div ng-app="myApp" ng-controller="myCtrl">
    <p ng-bind="value"></p>
</div>
</code>```

And the script is:

```<code>var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
    $scope.value = "My Test Value";
});

chatConnection.on('Send', (message) => {
    app.scope.value = message;
});
</code>```

What I am failing to understand is how do I access that value parameter so that I may update it.

EDIT:

The SignalR part works, the message comes through. The problem is that I am not sure how to update the value that is inside of that controller.  app.scope.value = message;

答:
Use observer pattern. Basically create a service which should do the following things:

Creates hub connection (handles start, reconnection, ....)

Support for example the following methods:

register for event (adds the caller to a list which contains

interested members.)

unregister for event (removes the caller from the list with the interesed members.)

In the case a new message from server inform all observers

Example:

(Pseudocode extracted from my solution (to big to show all)):

Server (here called hubWrapperService):

```<code>    var yourHubProxy = $.connection.yourHub;
        yourHubProxy.client.yourMethodWhichServerCanCall= function (params){
           // Inform observers. Iterate to over all your observers and inform them
           notifyObservers(params);
        };

    // Start connection.
    $.connection.hub.start().done(function () {
        ...
        });

    }).fail(function (error) {...

    });

   function registerToEvent(callback) {
                $log.debug("ServiceHub:  getConnectionEvent called");
                // Add caller to you observer list. (here serviceInitObservers)
            }

   function notifyServiceInitObservers() {
                angular.forEach(serviceInitObservers, function (callback) {
                    callback.callback();
                });
        }
</code>```

In your Controller (inject service and register for events):

```<code>hubWrapperServer.registerToEvent(function () {
        serviceHub.getAllDevices().then(function (params) {    // Do something in your controller
        });
      });
</code>```

There is also a wrapper service available
https://github.com/JustMaier/angular-signalr-hub

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to write a very simple message on the screen that when signalr send a value this message gets updated.

I have a very simple Hub:

public class Chat : Hub
{
    public Task Send(string message)
    {
        return Clients.All.InvokeAsync("Send", message);
    }
}

On the front-end I have the following html:

And the script is:

var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
    $scope.value = "My Test Value";
});

chatConnection.on('Send', (message) => {
    app.scope.value = message;
});

What I am failing to understand is how do I access that value parameter so that I may update it.

EDIT:

The SignalR part works, the message comes through. The problem is that I am not sure how to update the value that is inside of that controller.  app.scope.value = message;

Body:
Use observer pattern. Basically create a service which should do the following things:

Creates hub connection (handles start, reconnection, ....)

Support for example the following methods:

register for event (adds the caller to a list which contains

interested members.)

unregister for event (removes the caller from the list with the interesed members.)

In the case a new message from server inform all observers

Example:

(Pseudocode extracted from my solution (to big to show all)):

Server (here called hubWrapperService):

    var yourHubProxy = $.connection.yourHub;
        yourHubProxy.client.yourMethodWhichServerCanCall= function (params){
           // Inform observers. Iterate to over all your observers and inform them
           notifyObservers(params);
        };

    // Start connection.
    $.connection.hub.start().done(function () {
        ...
        });

    }).fail(function (error) {...

    });

   function registerToEvent(callback) {
                $log.debug("ServiceHub:  getConnectionEvent called");
                // Add caller to you observer list. (here serviceInitObservers)
            }

   function notifyServiceInitObservers() {
                angular.forEach(serviceInitObservers, function (callback) {
                    callback.callback();
                });
        }

In your Controller (inject service and register for events):

hubWrapperServer.registerToEvent(function () {
        serviceHub.getAllDevices().then(function (params) {    // Do something in your controller
        });
      });

There is also a wrapper service available
https://github.com/JustMaier/angular-signalr-hub


问:
forloop for getting object
I have below PHP forloop, $review is object having values of 'avail_1', 'avail_2', 'avail_2' upto avail_40

```<code>$review_array_count = array();

for ($i=1; $i <= 4 ; $i++) {
    if(is_object($review) && $review->avail_.$i == 'yes')
    {
     array_push($review_array_count, '1');
    }
}
echo count($review_array_count);
</code>```

I am counting how many avail_x having value of 'yes', so i am doing forloop upto 40, then pushing 1 to array and counting array.

How can i use object value as avail_.$i? This does not working.

Thanks,

答:
use this:</p>

```<code>for ($i=1; $i <= 4 ; $i++) {
$testValObj = 'avail_'.$i;
$mainVal=$review->$testValObj;
    if(is_object($review) && $mainVal == 'yes')
    {
     array_push($review_array_count, '1');
    }
}
echo count($review_array_count);
</code>```

Title: forloop for getting object

Body:
I have below PHP forloop, $review is object having values of 'avail_1', 'avail_2', 'avail_2' upto avail_40

$review_array_count = array();

for ($i=1; $i <= 4 ; $i++) {
    if(is_object($review) && $review->avail_.$i == 'yes')
    {
     array_push($review_array_count, '1');
    }
}
echo count($review_array_count);

I am counting how many avail_x having value of 'yes', so i am doing forloop upto 40, then pushing 1 to array and counting array.

How can i use object value as avail_.$i? This does not working.

Thanks,

Body:
use this:

for ($i=1; $i <= 4 ; $i++) {
$testValObj = 'avail_'.$i;
$mainVal=$review->$testValObj;
    if(is_object($review) && $mainVal == 'yes')
    {
     array_push($review_array_count, '1');
    }
}
echo count($review_array_count);


问:
What happens to the global variables in shared library when dlclose is called on it?
If a shared library (or a DLL) is being used through dlopen and dlclose mechanism and if the shared library created has some global variables whose memory comes from the heap, then what will happen to those variables and the memory when dlclose is called? </p>

<p>If in the same process, dlopen is called again, what will be the behaviour? </p>

答:
If dlclose reduces the reference count to zero and the library is actually unloaded, any future reloading of the library should reset all variables with static storage duration in the library to their original values.

However, if the library was opened more than once, all but the final call to dlclose will just decrement the reference count. Sometimes it may not be obvious whether a library was opened more than once, since it might have gotten loaded as a dependency of some other library without you knowing, unless it's a module local to your program, so it's probably not a good idea to rely on this "reset" behavior.

Employed Russian added:

Even if the library is dlopen()ed and dlclose()d exactly once, and is not a dependency of something else, the act of referencing symbols from it (via dlsym()) will also increment the reference count (and make the library not unloadable); at least on Linux.

I have no idea if this information is accurate or not. In the future, please post new information as a comment or a new answer, not an edit to other people's answers. If you just edit someone else's answers, you make them take responsibility for the correctness of your answer, which they may not want.

ContentLicense: CC BY-SA 2.5

Body:
If a shared library (or a DLL) is being used through dlopen and dlclose mechanism and if the shared library created has some global variables whose memory comes from the heap, then what will happen to those variables and the memory when dlclose is called?

If in the same process, dlopen is called again, what will be the behaviour?


问:
Counting DISTINCT values in T-SQL
I am trying to count the number of distinct email addresses in a view, but I can't figure out the syntax... Here's what I have:

```<code>BEGIN
  SELECT COUNT(*) AS UserCount FROM (
    SELECT DISTINCT EmailAddress
    FROM viewCohortsAuthorizedByContractor
    WHERE (ListAccess = 1) AND (ContractorId = @id)
  )
END
</code>```

The inner select works fine, but if I try adding the COUNT, I get the following error: Msg 156, Level 15, State 1, Procedure rptContractorUsersWithListUserCount, Line 23 [Batch Start Line 15]
Incorrect syntax near the keyword 'END'.

I'm sure there's a simple solution, I just can't figure it out...

答:
```<code>BEGIN
  SELECT COUNT(*) AS UserCount FROM (
    SELECT DISTINCT EmailAddress
    FROM viewCohortsAuthorizedByContractor
    WHERE (ListAccess = 1) AND (ContractorId = @id)
  )A   -----give a name for result set
END
</code>```

Title: Counting DISTINCT values in T-SQL

Body:
I am trying to count the number of distinct email addresses in a view, but I can't figure out the syntax... Here's what I have:

BEGIN
  SELECT COUNT(*) AS UserCount FROM (
    SELECT DISTINCT EmailAddress
    FROM viewCohortsAuthorizedByContractor
    WHERE (ListAccess = 1) AND (ContractorId = @id)
  )
END

The inner select works fine, but if I try adding the COUNT, I get the following error: Msg 156, Level 15, State 1, Procedure rptContractorUsersWithListUserCount, Line 23 [Batch Start Line 15]
Incorrect syntax near the keyword 'END'.

I'm sure there's a simple solution, I just can't figure it out...


问:
Casting java.sql.Connection to Oracle Connection
I have a java application where I call Oracle procedure and passing Oracle array as parameter. My application is EAR.

Everything worked correctly on Java 7 and Jboss 7, but when we upgraded to Java 8 and Wildfly 10 we got this error:

```<code> java.lang.ClassCastException:
 org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast
 to org.jboss.jca.adapters.jdbc.WrappedConnection
</code>```

After some research I changed my code to this:

```<code>WrappedConnectionJDK7  wc = (WrappedConnectionJDK7 ) conn;
OracleConnection oraconn = (OracleConnection) wc.getUnderlyingConnection();
</code>```

and I added dependency in pom.xml

```<code><dependency>
  <groupId>org.jboss.ironjacamar</groupId>
  <artifactId>ironjacamar-jdbc</artifactId>
  <version>1.3.2.Final</version>
</dependency>
</code>```

but still I get this error:

```<code>java.lang.ClassCastException:
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7
</code>```

答:
I've added jboss-deployment-structure.xml in EAR/META-INF and it solved the problem. </p>

```<code><?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <sub-deployment name="myapp.jar">
        <dependencies>
            <module name="org.jboss.ironjacamar.jdbcadapters" />
            <module name="com.oracle.db" />
        </dependencies>
    </sub-deployment>
</jboss-deployment-structure>
</code>```

Body:
I have a java application where I call Oracle procedure and passing Oracle array as parameter. My application is EAR.

Everything worked correctly on Java 7 and Jboss 7, but when we upgraded to Java 8 and Wildfly 10 we got this error:

 java.lang.ClassCastException:
 org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast
 to org.jboss.jca.adapters.jdbc.WrappedConnection

After some research I changed my code to this:

WrappedConnectionJDK7  wc = (WrappedConnectionJDK7 ) conn;
OracleConnection oraconn = (OracleConnection) wc.getUnderlyingConnection();

and I added dependency in pom.xml

<dependency>
  <groupId>org.jboss.ironjacamar</groupId>
  <artifactId>ironjacamar-jdbc</artifactId>
  <version>1.3.2.Final</version>
</dependency>

but still I get this error:

java.lang.ClassCastException:
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to
org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7

Body:
I've added jboss-deployment-structure.xml in EAR/META-INF and it solved the problem.

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <sub-deployment name="myapp.jar">
        <dependencies>
            <module name="org.jboss.ironjacamar.jdbcadapters" />
            <module name="com.oracle.db" />
        </dependencies>
    </sub-deployment>
</jboss-deployment-structure>


问:
What is the mental picture to have when something is required/imported in JS?
I'm not sure how to think about it, if 1 file requires or imports another, is it correct to just think of it as the required code being copied pasted into the file that required it? How does it work when foo.js requires bar.js but they both require react? Does it react get copied twice?

答: If you're using something like webpack where all of your code is bundled up into a single file, you can think of it like this: both of your bar.js and foo.js code will be in the same file as well as react, so no code/file will be copied more than once.</p>


问:
change things from a required lua file, corona sdk
When I require a file1, I can export the values, data or objects to file2, but file2 can't export to file1

(With "file" I mean a lua file, example, Scene1.lua, Data.lua)

How can I export from file2 to file1 and viceversa?

example code

Data.lua (file1)

```<code>--data.lua

local M = {}

local money = 500
local moneyText = display.newText("Money: " .. money,
display.contentCenterX, display.contentCenterY, "calibri", 50)

M.moneyText = moneyText
M.moneyData = money

return M
</code>```

file2

```<code> --file2.lua

local Data = require("data")

local moneyText2 = Data.moneyText
local moneyData = Data.moneyData

local function addSomeValue()
moneyData = moneyData + 1
end

timer.performWithDelay(1000, addSomeValue, 0)
</code>```

答:
```<code>local Data = require("data")
</code>```

is more or less equivalent to

```<code>function chunkFromDataLua()

  local M = {}

  local money = 500
  local moneyText = display.newText("Money: " .. money,
  display.contentCenterX, display.contentCenterY, "calibri", 50)

  M.moneyText = moneyText
  M.moneyData = money

  return M

end

local Data = chunkFromDataLua()
</code>```

Data now refers to table M

```<code>local money = 500
M.moneyData = money
</code>```

only creates a copy of money and stores that in M. So changing M.moneyData will not affect money. Hence changing Data.moneyData will also not affect money.

In addition to that

```<code>local moneyText = display.newText("Money: " .. money,
  display.contentCenterX, display.contentCenterY, "calibri", 50)
</code>```

creates a display object with a static text using the value of money at that moment. So changing the value of money after that won't change the content of your text display. You have to change Data.moneyText.text to do that.

Body:
When I require a file1, I can export the values, data or objects to file2, but file2 can't export to file1

(With "file" I mean a lua file, example, Scene1.lua, Data.lua)

How can I export from file2 to file1 and viceversa?

example code

Data.lua (file1)

--data.lua

local M = {}

local money = 500
local moneyText = display.newText("Money: " .. money,
display.contentCenterX, display.contentCenterY, "calibri", 50)

M.moneyText = moneyText
M.moneyData = money

return M

file2

 --file2.lua

local Data = require("data")

local moneyText2 = Data.moneyText
local moneyData = Data.moneyData

local function addSomeValue()
moneyData = moneyData + 1
end

timer.performWithDelay(1000, addSomeValue, 0)

Body:
local Data = require("data")

is more or less equivalent to

function chunkFromDataLua()

  local M = {}

  local money = 500
  local moneyText = display.newText("Money: " .. money,
  display.contentCenterX, display.contentCenterY, "calibri", 50)

  M.moneyText = moneyText
  M.moneyData = money

  return M

end

local Data = chunkFromDataLua()

Data now refers to table M

local money = 500
M.moneyData = money

only creates a copy of money and stores that in M. So changing M.moneyData will not affect money. Hence changing Data.moneyData will also not affect money.

In addition to that

local moneyText = display.newText("Money: " .. money,
  display.contentCenterX, display.contentCenterY, "calibri", 50)

creates a display object with a static text using the value of money at that moment. So changing the value of money after that won't change the content of your text display. You have to change Data.moneyText.text to do that.


问:
Background-size cover/center not working
I'm trying to center the background image to the div using background-size: cover and background-size: contain, but it does not work. I need to display background images inside HTML tags and use background-size in the css file, this is the code:

.container {
    width: 200px;
    height: 260px;
    position: relative;
    margin: 0 auto 40px;
    margin-left: 20px;
    display: inline-block;
}
.main{
    border: 1px solid black;
    background-color: #A6A6A6;
}
.card {
    width: 100%;
    height: 100%;
    position: absolute;
    border: 2px solid white;
}
.card div {
    height: 100%;
    width: 100%;
    color: white;
    text-align: center;
    position: absolute;
}
.card .front {
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    -webkit-background-size: contain;
    -moz-background-size: contain;
    -o-background-size: contain;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body style="background-image:url(https://s3.amazonaws.com/Syntaxxx/background-gold-bokeh.jpg);">
<div class="main">
  <section class="container">
      <div class="card">
          <div class="front" style="background-image: url('http://www.mobygames.com/images/covers/l/403626-injustice-2-playstation-4-front-cover.png');">
          </div>
          <div class="back">1</div>
      </div>
  </section>
  <section class="container">
      <div class="card">
          <div class="front" style="background-image: url('http://www.mobygames.com/images/covers/l/403651-the-surge-playstation-4-front-cover.jpg');">
          </div>
          <div class="back">2</div>
      </div>
  </section>
</div>

</body></code>```

答:
It is a simple fix, you need to specify background-position: center;. This will ensure your background images center itself.

```<code>.card .front {
    background-position: center;
｝
</code>```

Body:
I'm trying to center the background image to the div using background-size: cover and background-size: contain, but it does not work. I need to display background images inside HTML tags and use background-size in the css file, this is the code:

.container {
    width: 200px;
    height: 260px;
    position: relative;
    margin: 0 auto 40px;
    margin-left: 20px;
    display: inline-block;
}
.main{
    border: 1px solid black;
    background-color: #A6A6A6;
}
.card {
    width: 100%;
    height: 100%;
    position: absolute;
    border: 2px solid white;
}
.card div {
    height: 100%;
    width: 100%;
    color: white;
    text-align: center;
    position: absolute;
}
.card .front {
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    -webkit-background-size: contain;
    -moz-background-size: contain;
    -o-background-size: contain;
}

1

2

Body:
It is a simple fix, you need to specify background-position: center;. This will ensure your background images center itself.

.card .front {
    background-position: center;
｝


问:
mongodb connection thread safety
I am using the following code based on some tutorials to connect to the mongo database.

I have some doubts regarding the design:

Is it okay to call the MongoConnection.getDB() function from multiple threads simultaneously?

If not, should I make it synchronized?

If the design has issues, what kind of unwanted impact could it have?

I am new to mongodb so my question may sound a bit naive.

```<code>public class MongoConnection {

    private static MongoClient mongoClient = null;

    private static String IP = "mongodb://user:pwd@localhost:27017/?authSource=demodb&authMechanism=SCRAM-SHA-1";
    private static String DATABASE = "demodb";

    static {
        mongoClient = new MongoClient(new MongoClientURI(IP));
    }

    private MongoConnection() {

    }

    public static DB getDB() {
        return mongoClient.getDB(DATABASE);
    }
}
</code>```

答:
From the docs:

The MongoClient instance represents a pool of connections to the database; you will only need one instance of class MongoClient even with multiple threads.

And from the previous versions' quick start guides:

The MongoClient class is designed to be thread safe and shared among threads. Typically you create only 1 instance for a given database cluster and use it across your application.`

So, MongoClient.getDb(..) should not have any problem among threads

Title: mongodb connection thread safety

Body:
I am using the following code based on some tutorials to connect to the mongo database.

I have some doubts regarding the design:

Is it okay to call the MongoConnection.getDB() function from multiple threads simultaneously?

If not, should I make it synchronized?

If the design has issues, what kind of unwanted impact could it have?

I am new to mongodb so my question may sound a bit naive.

public class MongoConnection {

    private static MongoClient mongoClient = null;

    private static String IP = "mongodb://user:pwd@localhost:27017/?authSource=demodb&authMechanism=SCRAM-SHA-1";
    private static String DATABASE = "demodb";

    static {
        mongoClient = new MongoClient(new MongoClientURI(IP));
    }

    private MongoConnection() {

    }

    public static DB getDB() {
        return mongoClient.getDB(DATABASE);
    }
}


问:
Unable to get request data in asp.net web forms
in asp.net pageload method I am trying to get request data using

```<code>Request.Form["keyname"]
Request.Query
</code>```

but all are empty but when I run fiddler in inspector>>raw I am getting this

```<code>POST http://localhost:50844/Success.aspx HTTP/1.1
Host: localhost:50844
Connection: keep-alive
Content-Length: 15583
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: ASP.NET_SessionId=ax0e4j1ucaghsarowzmvgoep

valuestr=abc&randomnum=99389
</code>```

I need to get values of valuestr and randomnum,how can I do this

答:
You can use the below code as per the values in your URL.

if your URl is  = http://localhost:3039/test.aspx?valuestr=abc&randomnum=99389

then you can use the below code

```<code> string valuestr = Request.QueryString["valuestr"];
 string randomnum= Request.QueryString["valuestr"];
 Response.Write(valuestr );
 Response.Write(randomnum);
</code>```

do let me know in case you require any help

Body:
in asp.net pageload method I am trying to get request data using

Request.Form["keyname"]
Request.Query

but all are empty but when I run fiddler in inspector>>raw I am getting this

POST http://localhost:50844/Success.aspx HTTP/1.1
Host: localhost:50844
Connection: keep-alive
Content-Length: 15583
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: null
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: ASP.NET_SessionId=ax0e4j1ucaghsarowzmvgoep

valuestr=abc&randomnum=99389

I need to get values of valuestr and randomnum,how can I do this

Body:
You can use the below code as per the values in your URL.

if your URl is  = http://localhost:3039/test.aspx?valuestr=abc&randomnum=99389

then you can use the below code

 string valuestr = Request.QueryString["valuestr"];
 string randomnum= Request.QueryString["valuestr"];
 Response.Write(valuestr );
 Response.Write(randomnum);

do let me know in case you require any help


问:
Converting string with time to minutes
I am working on an Android app that gets a time (duration) value as string.

For example, the app can get a value like: 6 hours 43 mins

or a value like: 15 mins

I am looking for a way to convert this strings to an integer value in minutes.

I have tried using this function, but I can´t extract the needed values:

```<code>str = str.replaceAll("[^\\d.]", "");
</code>```

Edit:

it could be possible a result like 6 hours, the only known condition is that minutes are always rounded to an integer, the minimum value is 1 min

答:
Problem: There are few concerns as you never know without putting extra conditions like:
15 hours and 15 mins both will be stored in same integer value , you eventually need to differentiate them on some conditions to cater all the issues.

Coming to the question, you may achieve all this by using String split cases but you need to manually cater all the cases keeping in mind a user can use any spell words like hours can be hrs and so on

Title: Converting string with time to minutes

Body:
I am working on an Android app that gets a time (duration) value as string.

For example, the app can get a value like: 6 hours 43 mins

or a value like: 15 mins

I am looking for a way to convert this strings to an integer value in minutes.

I have tried using this function, but I can´t extract the needed values:

str = str.replaceAll("[^\\d.]", "");

Edit:

it could be possible a result like 6 hours, the only known condition is that minutes are always rounded to an integer, the minimum value is 1 min


问:
Filtering table with multiple filters
I've got the following javascript which takes the input of a form element, and hides table rows that do not qualify with the search term.

```<code><script>
    function wo_search(filter, column) {
        // Declare variables
        var input, table, tr, td, i;
        input = document.getElementById("wo_search_type");
        table = document.getElementById("work_order");
        tr = table.getElementsByTagName("tr");

        for (i = 0; i < tr.length; i++) {
            td = tr[i].getElementsByTagName("td")[column];
            if (td) {
                if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
                    tr[i].style.display = "";
                } else {
                    tr[i].style.display = "none";
                }
            }
        }
    }
</script>
</code>```

The problem is, my table has 7 search terms, not just one. With my current code, only 1 filter works at a time. When one filter is selected, it will hide the correct elements in the table. As soon as a user selects a 2nd filter, the first filter is nullified, basically all of the data that was hidden by that filter is shown again before applying the filter from the 2nd term selected.

How can I make it so that all of the filters are applied together?

P.S

This is how the filter function is called based on what type of input it is, there are regular text inputs and select boxes.

Select boxes use onchange="wo_search(this.value.toUpperCase(), 0)", the 2nd parameter being the table column id.

Input text uses onkeyup="wo_search(this.value.toUpperCase(), 0)", the 2nd parameter being the table column id.

EDIT:
I don't think I was clear in my initial post, and I apologize for that, but there are 7 different inputs that I am trying to make the table filter for.

Basically, on the table, there is a row at the very top (Above the headers), that just contain an input box (Select or text input) that need to filter that specific column of the table.

Every column has it's own filter. Here is a screenshot:

I'm thinking this may be easier to do with jquery, so jquery answers are also welcome.

答:
Here is an attempt to your requirement. So the below code will filter on filtered results. This means, when you enter something in first input, it would filter results based on that. Then, when you enter something in second input, it would filter results from the above results. So results once hidden, will never be considered in next set of searches.

In order to reset, clear all inputs / dropdowns, and you should be able to see all records again.

$(".column-filter").on('change input', function() {
  var emptyFields = $('.column-filter').filter(function() {
    return $.trim(this.value) === "";
  });
  if (emptyFields.length == $(".column-filter").length) {
    $('table tbody tr').each(function() {
      $(this).show();
    });
  } else {
    var columnNumber = this.id;
    var enteredValue = $(this).val();
    $('table tbody tr:visible').each(function() {
      var str = $(this).find('td:eq(' + parseInt(columnNumber) + ')').text();
      if (str.toLowerCase().indexOf(enteredValue.toLowerCase()) == -1) {
        $(this).hide();
      } else {
        $(this).show();
      }
    });
  }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#filter-list {
  display: inline-block;
}

#filter-list span.filter-item {
  display: inline-block;
  background-color: aqua;
  padding: 3px 6px;
  cursor: pointer;
}

#filter-list span.filter-item+span.filter-item {
  margin-left: 5px;
}

#filter-list span.filter-item::after {
  content: 'x';
  margin-left: 4px;
  padding-left: 4px;
  border-left: 1px solid grey;
}</code>```

        <select id='0' class="column-filter">
          <option value=""> </option>
          <option value="Lorem">Lorem</option>
          <option value="Illum">Illum</option>
        </select>

      <input type="search" placeholder="Filter" class="column-filter" id="1">
      <input type="search" placeholder="Filter" class="column-filter" id="2">
      <input type="search" placeholder="Filter" class="column-filter" id="3">
      <input type="search" placeholder="Filter" class="column-filter" id="4">

      Lorem, ipsum.
      Dolores, tempora?
      Tempore, soluta?
      Commodi, illum!
      Laudantium, debitis!

      Lorem ipsum dolor sit amet.
      Magni aspernatur eveniet amet. Eos.
      Doloribus numquam at nisi fuga.
      Exercitationem libero saepe iusto labore!
      Quod, debitis. Hic, eius voluptates?

      Excepturi aspernatur quia sequi labore.
      Ad tempore laudantium sed temporibus.
      Officia accusamus architecto perferendis quod?
      Laudantium facilis numquam quas iusto!
      Doloribus tenetur deleniti voluptatum alias.

      Ratione suscipit quis repudiandae ipsam!
      Repellendus blanditiis iure vel delectus.
      Sunt debitis voluptatum consectetur aliquam!
      Libero expedita odio maiores optio!
      Nam molestias delectus quam porro.

      Earum delectus sint ab error?
      Dicta ipsam facilis optio aliquam?
      Blanditiis eligendi sit ad accusamus?
      Sequi laborum illo eos incidunt?
      Necessitatibus iure sequi eaque quam!

      Illum aspernatur fuga laborum ratione!
      Maiores, excepturi! Dolorum, aspernatur mollitia.
      Labore corrupti itaque provident adipisci.
      Ipsum ducimus earum minus fuga.
      Necessitatibus rerum molestias autem libero.

      Nemo omnis similique labore minima!
      Dolore dolores saepe ea adipisci.
      Voluptate iusto in unde quas.
      Quod aperiam sit ut iusto.
      Quidem quisquam cupiditate dolor officiis.

      Officia numquam aliquam qui nulla.
      Laboriosam repellendus soluta aliquid similique.
      Veritatis, neque porro? Quae, quia?
      Magnam vel autem ad blanditiis!
      Laboriosam, a. Sunt, suscipit deserunt!

      Aspernatur iste saepe beatae nam.
      Ducimus quisquam corrupti quam inventore?
      Sit ullam minus possimus quidem!
      Officiis laborum laudantium veritatis et!
      Impedit dignissimos dolores maxime sequi.

      Neque similique cum sequi unde!
      Voluptatibus, ad? Ullam, facilis cumque.
      Enim in magnam id illo!
      Ex nobis quidem voluptatem voluptate.
      Eligendi esse ipsa ipsam omnis!

      Neque, fugit. Tempora, voluptates vel.
      Officia cupiditate dolores magni sunt?
      Eveniet tempore illo ipsa? Non.
      Possimus repellendus eligendi ipsam necessitatibus!
      Quisquam natus eos omnis ea.

      Aliquam voluptas recusandae et animi?
      Quis distinctio officiis quisquam dolores.
      Repellendus suscipit vero delectus hic.
      Quae asperiores temporibus impedit quis.
      Temporibus ipsa quidem magnam odio.

      Voluptatem optio quas nesciunt debitis!
      Hic mollitia alias laborum accusantium?
      Obcaecati eaque corrupti aperiam culpa!
      Voluptatum sequi sed numquam eos!
      Laborum exercitationem deleniti quaerat dolorem.

      Modi nam asperiores totam excepturi.
      Quod ipsa dolorem magni labore.
      Qui quidem quod eum quasi!
      Explicabo, ut eveniet. Quos, nam?
      Harum fugit sequi blanditiis accusamus.

      Ullam dolores vel natus in?
      Dolor velit dolorum quos error!
      Obcaecati blanditiis natus aperiam esse.
      Consequatur quasi qui minima laboriosam.
      Voluptatum, et atque. Iste, earum?

      Voluptate esse placeat doloribus hic?
      Dolorum velit ab incidunt quam.
      Laboriosam facere sed quia nisi.
      Saepe ex officia libero beatae?
      Ipsam ab distinctio assumenda itaque!

      Perferendis facere natus accusantium ut.
      Ipsam possimus dolores corporis totam!
      Ab officia rerum tempora ipsum.
      Id, soluta neque! Voluptatibus, id.
      Eaque enim fugiat corporis velit!

      Voluptatum cum atque eos quod.
      Esse corporis mollitia voluptatem ipsum.
      Corrupti unde inventore similique ad?
      Blanditiis dolorum molestiae minus tempore.
      Temporibus nihil doloremque quibusdam! Voluptatem!

      Iste voluptates iusto facilis cum?
      At est necessitatibus architecto repellendus?
      Officia qui soluta veniam nemo.
      Nobis cupiditate officiis reiciendis possimus.
      Voluptatibus quidem assumenda adipisci quis.

      Illum voluptatibus reprehenderit repellendus nostrum?
      Distinctio natus harum est nulla?
      Temporibus sit consequatur delectus ducimus.
      Veniam possimus qui fugiat temporibus.
      Delectus tenetur asperiores quasi perspiciatis.

      Quod atque ut doloribus libero?
      Animi assumenda praesentium alias accusantium!
      Labore ex optio eveniet architecto.
      Eaque delectus nemo fugiat dolorum.
      Atque, delectus. Obcaecati, saepe veritatis.

```

Title: Filtering table with multiple filters

Body:
I've got the following javascript which takes the input of a form element, and hides table rows that do not qualify with the search term.

The problem is, my table has 7 search terms, not just one. With my current code, only 1 filter works at a time. When one filter is selected, it will hide the correct elements in the table. As soon as a user selects a 2nd filter, the first filter is nullified, basically all of the data that was hidden by that filter is shown again before applying the filter from the 2nd term selected.

How can I make it so that all of the filters are applied together?

P.S

This is how the filter function is called based on what type of input it is, there are regular text inputs and select boxes.

Select boxes use onchange="wo_search(this.value.toUpperCase(), 0)", the 2nd parameter being the table column id.

Input text uses onkeyup="wo_search(this.value.toUpperCase(), 0)", the 2nd parameter being the table column id.

EDIT:
I don't think I was clear in my initial post, and I apologize for that, but there are 7 different inputs that I am trying to make the table filter for.

Basically, on the table, there is a row at the very top (Above the headers), that just contain an input box (Select or text input) that need to filter that specific column of the table.

Every column has it's own filter. Here is a screenshot:

I'm thinking this may be easier to do with jquery, so jquery answers are also welcome.

Body:
Here is an attempt to your requirement. So the below code will filter on filtered results. This means, when you enter something in first input, it would filter results based on that. Then, when you enter something in second input, it would filter results from the above results. So results once hidden, will never be considered in next set of searches.

In order to reset, clear all inputs / dropdowns, and you should be able to see all records again.

$(".column-filter").on('change input', function() {
  var emptyFields = $('.column-filter').filter(function() {
    return $.trim(this.value) === "";
  });
  if (emptyFields.length == $(".column-filter").length) {
    $('table tbody tr').each(function() {
      $(this).show();
    });
  } else {
    var columnNumber = this.id;
    var enteredValue = $(this).val();
    $('table tbody tr:visible').each(function() {
      var str = $(this).find('td:eq(' + parseInt(columnNumber) + ')').text();
      if (str.toLowerCase().indexOf(enteredValue.toLowerCase()) == -1) {
        $(this).hide();
      } else {
        $(this).show();
      }
    });
  }
});

#filter-list {
  display: inline-block;
}

#filter-list span.filter-item {
  display: inline-block;
  background-color: aqua;
  padding: 3px 6px;
  cursor: pointer;
}

#filter-list span.filter-item+span.filter-item {
  margin-left: 5px;
}

#filter-list span.filter-item::after {
  content: 'x';
  margin-left: 4px;
  padding-left: 4px;
  border-left: 1px solid grey;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="filter-me" class="table">
  <caption id="filter-list"></caption>
  <thead>
    <tr>
      <th>
        <select id='0' class="column-filter">
          <option value="">&nbsp;</option>
          <option value="Lorem">Lorem</option>
          <option value="Illum">Illum</option>
        </select>
      </th>
      <th><input type="search" placeholder="Filter" class="column-filter" id="1"></th>
      <th><input type="search" placeholder="Filter" class="column-filter" id="2"></th>
      <th><input type="search" placeholder="Filter" class="column-filter" id="3"></th>
      <th><input type="search" placeholder="Filter" class="column-filter" id="4"></th>
    </tr>
    <tr>
      <th>Lorem, ipsum. <span class="arrow-up">&nbsp;</span></th>
      <th>Dolores, tempora?</th>
      <th>Tempore, soluta?</th>
      <th>Commodi, illum!</th>
      <th>Laudantium, debitis!</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Lorem ipsum dolor sit amet.</td>
      <td>Magni aspernatur eveniet amet. Eos.</td>
      <td>Doloribus numquam at nisi fuga.</td>
      <td>Exercitationem libero saepe iusto labore!</td>
      <td>Quod, debitis. Hic, eius voluptates?</td>
    </tr>
    <tr>
      <td>Excepturi aspernatur quia sequi labore.</td>
      <td>Ad tempore laudantium sed temporibus.</td>
      <td>Officia accusamus architecto perferendis quod?</td>
      <td>Laudantium facilis numquam quas iusto!</td>
      <td>Doloribus tenetur deleniti voluptatum alias.</td>
    </tr>
    <tr>
      <td>Ratione suscipit quis repudiandae ipsam!</td>
      <td>Repellendus blanditiis iure vel delectus.</td>
      <td>Sunt debitis voluptatum consectetur aliquam!</td>
      <td>Libero expedita odio maiores optio!</td>
      <td>Nam molestias delectus quam porro.</td>
    </tr>
    <tr>
      <td>Earum delectus sint ab error?</td>
      <td>Dicta ipsam facilis optio aliquam?</td>
      <td>Blanditiis eligendi sit ad accusamus?</td>
      <td>Sequi laborum illo eos incidunt?</td>
      <td>Necessitatibus iure sequi eaque quam!</td>
    </tr>
    <tr>
      <td>Illum aspernatur fuga laborum ratione!</td>
      <td>Maiores, excepturi! Dolorum, aspernatur mollitia.</td>
      <td>Labore corrupti itaque provident adipisci.</td>
      <td>Ipsum ducimus earum minus fuga.</td>
      <td>Necessitatibus rerum molestias autem libero.</td>
    </tr>
    <tr>
      <td>Nemo omnis similique labore minima!</td>
      <td>Dolore dolores saepe ea adipisci.</td>
      <td>Voluptate iusto in unde quas.</td>
      <td>Quod aperiam sit ut iusto.</td>
      <td>Quidem quisquam cupiditate dolor officiis.</td>
    </tr>
    <tr>
      <td>Officia numquam aliquam qui nulla.</td>
      <td>Laboriosam repellendus soluta aliquid similique.</td>
      <td>Veritatis, neque porro? Quae, quia?</td>
      <td>Magnam vel autem ad blanditiis!</td>
      <td>Laboriosam, a. Sunt, suscipit deserunt!</td>
    </tr>
    <tr>
      <td>Aspernatur iste saepe beatae nam.</td>
      <td>Ducimus quisquam corrupti quam inventore?</td>
      <td>Sit ullam minus possimus quidem!</td>
      <td>Officiis laborum laudantium veritatis et!</td>
      <td>Impedit dignissimos dolores maxime sequi.</td>
    </tr>
    <tr>
      <td>Neque similique cum sequi unde!</td>
      <td>Voluptatibus, ad? Ullam, facilis cumque.</td>
      <td>Enim in magnam id illo!</td>
      <td>Ex nobis quidem voluptatem voluptate.</td>
      <td>Eligendi esse ipsa ipsam omnis!</td>
    </tr>
    <tr>
      <td>Neque, fugit. Tempora, voluptates vel.</td>
      <td>Officia cupiditate dolores magni sunt?</td>
      <td>Eveniet tempore illo ipsa? Non.</td>
      <td>Possimus repellendus eligendi ipsam necessitatibus!</td>
      <td>Quisquam natus eos omnis ea.</td>
    </tr>
    <tr>
      <td>Aliquam voluptas recusandae et animi?</td>
      <td>Quis distinctio officiis quisquam dolores.</td>
      <td>Repellendus suscipit vero delectus hic.</td>
      <td>Quae asperiores temporibus impedit quis.</td>
      <td>Temporibus ipsa quidem magnam odio.</td>
    </tr>
    <tr>
      <td>Voluptatem optio quas nesciunt debitis!</td>
      <td>Hic mollitia alias laborum accusantium?</td>
      <td>Obcaecati eaque corrupti aperiam culpa!</td>
      <td>Voluptatum sequi sed numquam eos!</td>
      <td>Laborum exercitationem deleniti quaerat dolorem.</td>
    </tr>
    <tr>
      <td>Modi nam asperiores totam excepturi.</td>
      <td>Quod ipsa dolorem magni labore.</td>
      <td>Qui quidem quod eum quasi!</td>
      <td>Explicabo, ut eveniet. Quos, nam?</td>
      <td>Harum fugit sequi blanditiis accusamus.</td>
    </tr>
    <tr>
      <td>Ullam dolores vel natus in?</td>
      <td>Dolor velit dolorum quos error!</td>
      <td>Obcaecati blanditiis natus aperiam esse.</td>
      <td>Consequatur quasi qui minima laboriosam.</td>
      <td>Voluptatum, et atque. Iste, earum?</td>
    </tr>
    <tr>
      <td>Voluptate esse placeat doloribus hic?</td>
      <td>Dolorum velit ab incidunt quam.</td>
      <td>Laboriosam facere sed quia nisi.</td>
      <td>Saepe ex officia libero beatae?</td>
      <td>Ipsam ab distinctio assumenda itaque!</td>
    </tr>
    <tr>
      <td>Perferendis facere natus accusantium ut.</td>
      <td>Ipsam possimus dolores corporis totam!</td>
      <td>Ab officia rerum tempora ipsum.</td>
      <td>Id, soluta neque! Voluptatibus, id.</td>
      <td>Eaque enim fugiat corporis velit!</td>
    </tr>
    <tr>
      <td>Voluptatum cum atque eos quod.</td>
      <td>Esse corporis mollitia voluptatem ipsum.</td>
      <td>Corrupti unde inventore similique ad?</td>
      <td>Blanditiis dolorum molestiae minus tempore.</td>
      <td>Temporibus nihil doloremque quibusdam! Voluptatem!</td>
    </tr>
    <tr>
      <td>Iste voluptates iusto facilis cum?</td>
      <td>At est necessitatibus architecto repellendus?</td>
      <td>Officia qui soluta veniam nemo.</td>
      <td>Nobis cupiditate officiis reiciendis possimus.</td>
      <td>Voluptatibus quidem assumenda adipisci quis.</td>
    </tr>
    <tr>
      <td>Illum voluptatibus reprehenderit repellendus nostrum?</td>
      <td>Distinctio natus harum est nulla?</td>
      <td>Temporibus sit consequatur delectus ducimus.</td>
      <td>Veniam possimus qui fugiat temporibus.</td>
      <td>Delectus tenetur asperiores quasi perspiciatis.</td>
    </tr>
    <tr>
      <td>Quod atque ut doloribus libero?</td>
      <td>Animi assumenda praesentium alias accusantium!</td>
      <td>Labore ex optio eveniet architecto.</td>
      <td>Eaque delectus nemo fugiat dolorum.</td>
      <td>Atque, delectus. Obcaecati, saepe veritatis.</td>
    </tr>
  </tbody>
</table>


问:
how to toggle react-navigation drawer
I am using react-navigation https://reactnavigation.org/ for my first react-native project. I would like to toggle my drawer (open & close), but I have no idea how I can achieve this. I've been looking at the documentation from reactnavigation.org, but can't really find any hints.</p>

答:
If you would like to toggle the drawer you can navigate to 'DrawerToggle', and this will choose which navigation is appropriate for you given the drawers current state.

fires 'DrawerOpen&DrawerClose' accordingly

this.props.navigation.navigate('DrawerToggle');

Title: how to toggle react-navigation drawer


问:
How to write a file into preference store in Eclipse
I want to write a CSS file into the preference store instead of into a local file path and read back whenever it requires.

I am new to Eclipse, an example would be helpful for me...

答:
The preference store is for fairly small values stored using a 'key' and a 'value'. You could put the contents of the file as a 'value' but this is probably not a good use of the store.

Eclipse plugins can use the 'state location' to save files. Use something like:

Bundle bundle = FrameworkUtil.getBundle(getClass());

IPath path = Platform.getStateLocation(bundle);

File dir = path.toFile();
```

to get the path to the state location directory. Your plugin can store anything it likes in this directory,

Platform is org.eclipse.core.runtime.Platform

Body:
The preference store is for fairly small values stored using a 'key' and a 'value'. You could put the contents of the file as a 'value' but this is probably not a good use of the store.

Eclipse plugins can use the 'state location' to save files. Use something like:

Bundle bundle = FrameworkUtil.getBundle(getClass());

IPath path = Platform.getStateLocation(bundle);

File dir = path.toFile();

to get the path to the state location directory. Your plugin can store anything it likes in this directory,

Platform is org.eclipse.core.runtime.Platform


问:
How to run accelerometer on background?
I need to implement accelerometer running on background service on Android. The thread has to communicate both way and fire event based on accelerometer data. The service has to run indefinitely and in case that OS kills service, it restarts from previous state. I did some research and I am not sure whether to use Bound Service or Out of process Service. Is it possible to implement this task? Which type of service works for this problem?</p>

答:
Is it possible to implement this task? Which type of service works for this problem?

You will need partial wake lock to prevent the service from being stopped.

Then you can use certain service like Foreground Service as @SushiHangover suggested to track accelerometer data and fire event when necessary.

Title: How to run accelerometer on background?


问:
C++ Move semantics and Exceptions
In the forthcoming C++0x standard, what happens when an exception is thrown within/during the move constructor?

Will the original object remain? or are both the original and move-to object in an undefined state? what are the guarantees afforded by the language?

答:
I believe that the standards committee originally attempted to make it so move constructors would not be allowed to throw exceptions, but (at least as of today) found that trying to enforce that had too many pitfalls.

Proposal N3050, "Allowing Move Constructors to Throw (Rev 1)", has been incorporated into the draft standard. Essentially the proposal adds the capability for move constructors to throw, but to disallow 'throwing' moves to be used for certain operations where strong exception safety guarantees were needed (the library will fall back to copying the object if a non-throwing move isn't available).

If you mark a move constructor as non-throwing (noexcept) and an exception is thrown, std::terminate() will be called.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html

It might also be worth reading a blog article by David Abrahams that discusses the issues that N3050 was intended to address:

http://cpp-next.com/archive/2009/10/exceptionally-moving/

OwnerDisplayName: Matthieu N.

Title: C++ Move semantics and Exceptions


问:
Write a list in a python csv file, one new row per list
I have the following source code, where I am trying to write a list in a csv file. I need every new list to be written in a new line of this csv file. The source code is the following:

```<code>import csv
list1=[55,100,'dir1/dir2/dir3/file.txt',0.8]

resultFile = open("output.csv",'wa')
wr = csv.writer(resultFile, dialect='excel')
wr.writerow(list1)
resultFile.close()
</code>```

The problem is that it doesn't insert list1 in a newline every time i run the code.

In matlab that would be easy, I just need to use dlmwrite with '-append' parameter.

But how to do this in Python?

答:
If you use Python 3.x then change your code:

```<code>import csv

list1 = [58,100,'dir1/dir2/dir3/file.txt',0.8]

with open("output.csv", "a", newline='') as fp:
    wr = csv.writer(fp, dialect='excel')
    wr.writerow(list1)
</code>```

Adding newline='' can help you to avoid getting extra new lines, empty rows in between two rows with data.

Body:
I have the following source code, where I am trying to write a list in a csv file. I need every new list to be written in a new line of this csv file. The source code is the following:

import csv
list1=[55,100,'dir1/dir2/dir3/file.txt',0.8]

resultFile = open("output.csv",'wa')
wr = csv.writer(resultFile, dialect='excel')
wr.writerow(list1)
resultFile.close()

The problem is that it doesn't insert list1 in a newline every time i run the code.

In matlab that would be easy, I just need to use dlmwrite with '-append' parameter.

But how to do this in Python?

Body:
If you use Python 3.x then change your code:

import csv

list1 = [58,100,'dir1/dir2/dir3/file.txt',0.8]

with open("output.csv", "a", newline='') as fp:
    wr = csv.writer(fp, dialect='excel')
    wr.writerow(list1)

Adding newline='' can help you to avoid getting extra new lines, empty rows in between two rows with data.