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
/* | |
* Copyright 2013 Cloudera Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
python -c 'import random | |
r = random.Random() | |
ops = [ "fuck", "shit", "stack", "put it in a glass bowl", "take it off the wall" ] | |
for i in range(0, 10): | |
for j in range(0, 10): | |
print ops[int(round(r.uniform(0, len(ops) - 1)))], | |
print "\n" | |
' |
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
// The MR contract says we're guaranteed to get: | |
// 1. each key exactly once. | |
// 2. keys in sorted order. | |
// 3. all values for each key. | |
// | |
// We are not guaranteed to get values in any particular order, however. | |
// Let's fix that. | |
void reduce(Text key, Iterator<LongWritable> values, Context<Text, LongWritable> context) { | |
// Create a copy buffer and slurp all values out of the iterator. |
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
scala> :silent | |
Switched off result printing. | |
scala> class Bad { | |
| var toStringCount: Int = 0 | |
| override def toString(): String = { toStringCount += 1 ; super.toString() } | |
| } | |
scala> val b = new Bad |
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
/* | |
* A simple example of user demographic dataset generation in scala. | |
* | |
* This highlights the following scala bits: | |
* - Java integration | |
* - Annotations | |
* - Tail recursion optimization | |
* - Enums | |
* - Vals vs. vars | |
* - Working with singleton objects |
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
} catch (NullPointerException e) { | |
throw npe(e, " of "+schema.getFullName()); | |
} | |
} | |
/** Helper method for adding a message to an NPE. */ | |
protected NullPointerException npe(NullPointerException e, String s) { | |
NullPointerException result = new NullPointerException(e.getMessage()+s); | |
result.initCause(e.getCause() == null ? e : e.getCause()); | |
return 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
// Wire this up to an eclipse template called slf4j_logger and never type it again. | |
private static final Logger logger = LoggerFactory.getLogger(${enclosing_type}.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 ${enclosing_type} ${name:field}(${type:elemType(name)} ${name}) { | |
this.${name} = ${name}; | |
return this; | |
} |
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 class AvroProjectionMapFn extends MapFn<Record, Record> { | |
private static final long serialVersionUID = 1L; | |
private List<String> fieldNames; | |
private Schema sourceSchema; | |
private Schema projectionSchema; | |
@Override |
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
#!/usr/bin/python | |
import sys | |
def load_passwd(path): | |
lookup = { } | |
f = file(path) | |
for line in f: | |
line = line.rstrip() |