This file contains 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
sub listener { | |
my ($event) = @_; | |
console->log("event is " . $event); | |
# doesn't work | |
# $event->respondWith(handleRequest($event->request)); | |
# works | |
my $req = $event->request; | |
my $resp = handleRequest($req); |
This file contains 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
package example; | |
public class JavaExample { | |
public static void main(String[] args) { | |
System.out.println("before assert"); | |
assert 1 == 0; | |
System.out.println("after asssert"); | |
} | |
} |
This file contains 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> def useInt(i: Int) = println(s"used $i") | |
useInt: (i: Int)Unit | |
scala> val i: java.lang.Integer = null | |
i: Integer = null | |
// implicit conversion from Integer to Int fails | |
scala> useInt(i) | |
java.lang.NullPointerException | |
at scala.Predef$.Integer2int(Predef.scala:392) |
This file contains 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
15/01/12 16:07:07 INFO CheckpointReader: Attempting to load checkpoint from file file:/var/tmp/cp/checkpoint-1421100410000.bk | |
15/01/12 16:07:07 WARN CheckpointReader: Error reading checkpoint from file file:/var/tmp/cp/checkpoint-1421100410000.bk | |
java.io.IOException: java.lang.ClassNotFoundException: org.apache.spark.rdd.kafka.KafkaRDDPartition | |
at org.apache.spark.util.Utils$.tryOrIOException(Utils.scala:1043) | |
at org.apache.spark.streaming.dstream.DStreamCheckpointData.readObject(DStreamCheckpointData.scala:146) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:606) | |
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017) |
This file contains 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 org.apache.spark.sql.{ SQLContext, Row } | |
val sqlContext = new SQLContext(sc) | |
import sqlContext._ | |
/* | |
Next you'll need to get your data registered as a table. Note that in order to infer the schema (column names and types) it must be a case class. A normal class won't work, unless you manually implement much of what a case class would do, e.g. extend Product and Serializable. | |
Any data source can be used, as long as you can transform it to an rdd of case classes. For now, we'll just use some dummy data: | |
*/ |
This file contains 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
// hector version | |
val mutator: Mutator[Composite] = HFactory.createMutator(ksp, CompositeSerializer.get) | |
val column = HFactory.createColumn(deviceId, Array[Byte]()) | |
column.setClock(clock) | |
profiles.foreach { p => | |
if (p(attributes)) | |
mutator.addInsertion(rowkey(brandCode, p.id.get), columnFamilyName, column) | |
else | |
mutator.addDeletion(rowkey(brandCode, p.id.get), columnFamilyName, deviceId, StringSerializer.get, clock) | |
} |
This file contains 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 dispatch._ | |
import scala.util.Random | |
object AsyncExample { | |
val total = 2000000 | |
val groupSize = 100 | |
def svc = url("http://localhost:8080/") | |
def req(q: String) = Http(svc.addQueryParameter("q", q) OK as.String) | |
def res = Seq.fill(total)(Random.nextInt). |