Home > other >  Java graphs wordcount statistical occurrences
Java graphs wordcount statistical occurrences

Time:10-01

First apologize, I didn't find graphs of the plate, so we have to put this question to the coming
To trouble you again a great god! The problem is this:
If at the time of the day, each hour of the web access record how many times, and how many users are in so many visit record, the original format is as follows:
Hourid url
0 com
0 com
0 cn
Zero net
1 org
2 com
2 com
2 cn
.

Output format is similar to the following:
Hourid visitscount userscount
0 4 3
1 1 1
2, 3, 2

A time period there were a few access records, visitscount is few; Userscount refers to (com, cn,.net)
If the kind of implementation method with wordcount, are summed up according to the key value, complete the function of the above two don't want to write a Java program, but I want to output to a document at the same time, really don't know how the format of the output as shown above, also please great god action,
Or tell me the implementation approach can also, I now is a confused, thanks again!!

CodePudding user response:

The Map key output for hourid, the value for the url
Reduce iterative processing values inside, the size of the values is visitscount, values is to repeat userscount
A graphs

CodePudding user response:

reference 1st floor wulinshishen response:
key for hourid Map output, the value for the url
Reduce iterative processing values inside, the size of the values is visitscount, values is to repeat userscount
A graphs

Thank you very much! I got a visitscount values, I want to ask values to repeat how

CodePudding user response:

refer to the second floor longyixian response:
Quote: refer to 1st floor wulinshishen response:

The Map key output for hourid, the value for the url
Reduce iterative processing values inside, the size of the values is visitscount, values is to repeat userscount
A graphs

Thank you very much! I got a visitscount values, I want to ask values to repeat how?

A Map variables can be achieved

CodePudding user response:

Is a Set variable can be achieved

CodePudding user response:

reference 4 floor wulinshishen response:
is a variable Set can achieve


Well, thank you for your advice, I have finished, finally there is a problem, hope you'll be glad to.
How can I let the content output to a CSV file, which is saved as a CSV file,
After I joined in the reduce CsvWriter always cover the original data only keeps a data, may be the wr. Close (); Sake, but away are not,
Is entangled with how should handle

CodePudding user response:

You are inside the reducer to define a global variable in the reduce method to output the contents of the collection, and then in the cleanup methods do file is written to the output

CodePudding user response:

refer to 6th floor wulinshishen response:
are you define a global variable in reducer in the reduce method to output the contents of the collection, and then in the cleanup methods do file is written to the output

Well I have a question, if calculated each period each url, the number of occurrences of how to calculate,

CodePudding user response:

Use a Map variable statistical number of urls
  • Related