Skip to content

Instantly share code, notes, and snippets.

View sajithdilshan's full-sized avatar

Sajith Edirisinghe sajithdilshan

View GitHub Profile
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);
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);
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);
import React, { Component } from 'react';
import Alice from './Alice';
class App extends Component {
constructor() {
super();
this.state = {
greeting: "Hello World!",
parentMessage: "Hello Alice!"
import React, { Component } from 'react';
class Alice extends Component {
constructor(props) {
super(props)
this.state = {
greeting: props.newMsg
}
}
import React, { Component } from 'react';
import Alice from './Alice';
class App extends Component {
constructor() {
super();
this.state = {
greeting: "Hello World!",
parentMessage: "Hello Alice!"
import React, { Component } from 'react';
import Alice from './Alice';
class App extends Component {
constructor() {
super();
this.state = {
greeting: "Hello World!"
}
import React, { Component } from 'react';
import Alice from './Alice';
class App extends Component {
render() {
return (
<div className="greeting">
<h1> Hello World! </h1>
<Alice/>
</div>
import React, { Component } from 'react';
class Alice extends Component {
render() {
return (
<div>
<h2> Hi, I am Alice </h2>
</div>
);
}
const element = React.createElement(
'h1',
{className: 'greeting'},
'Hello, world!'
);