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 Netflix, 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
| scala> class Foo { def foo() = Array(1.0) } | |
| defined class Foo | |
| scala> val t = new Foo | |
| t: Foo = $iwC$$iwC$$iwC$$iwC$Foo@5ef6a5b6 | |
| scala> val m = t.foo | |
| m: Array[Double] = Array(1.0) | |
| scala> val r1 = sc.parallelize(List(1, 2, 3)) |
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> class Foo { def foo() = Array(1.0) } | |
| defined class Foo | |
| scala> var m: Array[Double] = null | |
| m: Array[Double] = null | |
| scala> { | |
| | val t = new Foo | |
| | m = t.foo | |
| | } |
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 org.apache.spark.SparkConf; | |
| import org.apache.spark.api.java.function.FlatMapFunction; | |
| import org.apache.spark.api.java.function.Function2; | |
| import org.apache.spark.api.java.function.PairFunction; | |
| import org.apache.spark.streaming.Duration; | |
| import org.apache.spark.streaming.api.java.JavaDStream; | |
| import org.apache.spark.streaming.api.java.JavaPairDStream; | |
| import org.apache.spark.streaming.api.java.JavaStreamingContext; | |
| import org.apache.spark.streaming.scheduler.*; | |
| import scala.Tuple2; |
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
| final JavaStreamingContext jssc = new JavaStreamingContext(...); | |
| final Time exitTime = new Time(12345L); // Need to set the correct exit time | |
| jssc.addStreamingListener(new StreamingListener(){ | |
| @Override | |
| public void onBatchCompleted(StreamingListenerBatchCompleted batchCompleted) { | |
| if (batchCompleted.batchInfo().batchTime().greaterEq(exitTime)) { | |
| new Thread() { | |
| @Override | |
| public void run() { | |
| jssc.stop(true, true); |
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 java.io.{DataOutputStream, ByteArrayOutputStream} | |
| import java.lang.String | |
| import org.apache.hadoop.hbase.client.Scan | |
| import org.apache.hadoop.hbase.HBaseConfiguration | |
| import org.apache.hadoop.hbase.io.ImmutableBytesWritable | |
| import org.apache.hadoop.hbase.client.Result | |
| import org.apache.hadoop.hbase.mapreduce.TableInputFormat | |
| import org.apache.hadoop.hbase.util.Base64 | |
| def convertScanToString(scan: Scan): String = { |
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
| set -- a b c | |
| echo "$1 $2 $3" |
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
| while read line; do | |
| echo $line; | |
| done < <(cat test.txt) |
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
| err() { | |
| echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2 | |
| } |
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
| # output "I am an exceptionally long string." | |
| long_string="I am an exceptionally | |
| long string." | |
| echo ${long_string} |
OlderNewer