This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception { | |
Configuration conf = new Configuration(); | |
conf.set("fs.defaultFS", "hdfs://localhost:9000"); | |
Job job = Job.getInstance(conf, "word count"); | |
job.setJarByClass(VisitorPathCount.class); | |
job.setMapperClass(TokenizerMapper.class); | |
job.setCombinerClass(IntSumReducer.class); | |
job.setReducerClass(IntSumReducer.class); | |
job.setOutputKeyClass(Text.class); | |
job.setOutputValueClass(IntWritable.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> { | |
private IntWritable result = new IntWritable(); | |
public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { | |
int sum = 0; | |
for (IntWritable val : values) { | |
sum += val.get(); | |
} | |
result.set(sum); | |
context.write(key, result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> { | |
private static final Pattern pattern = Pattern.compile("\"([^\"]*)\""); | |
private final static IntWritable one = new IntWritable(1); | |
private Text word = new Text(); | |
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { | |
Matcher matcher = pattern.matcher(value.toString()); | |
if (matcher.find()) { | |
word.set(matcher.group(0)); | |
context.write(word, one); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Alice from './Alice'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
greeting: "Hello World!", | |
parentMessage: "Hello Alice!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class Alice extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
greeting: props.newMsg | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Alice from './Alice'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
greeting: "Hello World!", | |
parentMessage: "Hello Alice!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Alice from './Alice'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
greeting: "Hello World!" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Alice from './Alice'; | |
class App extends Component { | |
render() { | |
return ( | |
<div className="greeting"> | |
<h1> Hello World! </h1> | |
<Alice/> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class Alice extends Component { | |
render() { | |
return ( | |
<div> | |
<h2> Hi, I am Alice </h2> | |
</div> | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const element = React.createElement( | |
'h1', | |
{className: 'greeting'}, | |
'Hello, world!' | |
); |