Skip to content

Instantly share code, notes, and snippets.

View matthew-dailey's full-sized avatar

Matt Dailey matthew-dailey

View GitHub Profile
@matthew-dailey
matthew-dailey / SparkThreadUnsafe.java
Last active November 30, 2016 15:33
Shows using a thread-unsafe Function in a Spark Closure
public JavaDStream<Long> createLongStream(JavaDStream<Object> inputDStream) {
return inputDStream.map(new ThreadUnsafeMapper());
}
private static class ThreadUnsafeMapper implements Function<Object, Long> {
private static final long serialVersionUID = 1L;
private long count = 0;
// definitely not a thread-safe function
@Override
@matthew-dailey
matthew-dailey / NonBlockingDrainTest.java
Last active November 30, 2016 15:34
Tests to make sure `BlockingQueue.drainTo` is non-blocking.
@Test
public void deletemetest() throws InterruptedException {
final BlockingQueue<Object> queue = Queues.newLinkedBlockingQueue();
queue.offer("hello");
Queue<Object> drain = Queues.newArrayDeque();
Assert.assertEquals(1, queue.size());
Assert.assertEquals(0, drain.size());
@matthew-dailey
matthew-dailey / mr4c-fedora-build.md
Last active August 29, 2015 14:17
How to build mr4c on Fedora 21

Building on Fedora 21

These instructions are for building mr4c on Fedora 21, written on March 15, 2015.

Installing Java dependencies

  • Java (1.8.0_31)
  • Download the Oracle JDK 1.8 and install.
  • Historically, the OpenJDK that comes with many Linux distros has not worked well with Hadoop.
  • Make sure to set JAVA_HOME to where you installed this.