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
case class Data(opt: Option[String], value: Int) | |
def d(o: String, v: Int) = Data(Some(o), v) | |
def n(v: Int) = Data(None, v) | |
val tList = List(d("a", 1), d("b", 2), n(10), d("c", 3), n(0)) | |
tList.collect { | |
case Data(Some(o), v) => v | |
} |
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
case class Data(opt: Option[String]) | |
val tList = List(Data(None), Data(Some("hoge")), Data(None), Data(Some("fuga")), Data(Some("piyo"))) | |
for(Data(Some(str)) <- tList) yield str | |
tList.collect { | |
case Data(Some(str)) => str | |
} |
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 scala.util.Try | |
case class Data(aId: String) | |
def get(aId: String): Try[Option[Data]] = Try{ aId match { | |
case "hoge" | "fuga" => Some(Data(aId)) | |
case "piyo" => None | |
case _ => throw new IllegalArgumentException("cannot get") | |
}} | |
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
object IteratorUtil { | |
def merge[_T](aIterators: Iterator[_T]*)(implicit aOrdering: Ordering[_T]): Iterator[_T] = { | |
def nextOrNone(aIterator: Iterator[_T]): Option[_T] = if (aIterator.hasNext) Some(aIterator.next) else None | |
implicit object ElementOrdering extends Ordering[(Int, Option[_T], Iterator[_T])] { | |
override def compare(x: (Int, Option[_T], Iterator[_T]), y: (Int, Option[_T], Iterator[_T])) = (x, y) match { | |
case ((_, None, _), (_, None, _)) => 0 | |
case ((_, None, _), (_, _, _)) => 1 | |
case ((_, _, _), (_, None, _)) => -1 | |
case ((_, Some(tLeft), _), (_, Some(tRight), _)) => aOrdering.compare(tLeft, tRight) | |
} |
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
trait Applicative[F[_]] { | |
def fmap[A, B](f: A => B)(aFunctor: F[A]): F[B] | |
def point[A](a: => A): F[A] | |
def apply[A, B](f: F[A => B])(aFunctor: F[A]): F[B] | |
} | |
object Applicative { | |
implicit def appToUtil[A, B, F[_]: Applicative](f: F[A => B]) = new ApplyUtil(f) | |
implicit def funcToUtil[A, B, F[_]: Applicative](f: A => B) = new PointApplyUtil(f) |
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
起動時 | |
2013-01-21 07:04:12 +0900: starting fluentd-0.10.30 | |
1/22 追記 | |
aggregate側のすべてのマシンのhostsファイルに関連するアドレスをすべて記入しましたが、この問題は依然発生しています。 | |
問題が起きた時のログ | |
このログの出力後、全てのsource(access-log以外も含む)から、このfluentdへのデータ転送が止まります(止まらない場合もあります)。 | |
また、同時にsourceのうち1台から、全てのaggregateへの送信が停止します。 | |
この状態になった後、td-agentをstopすると、td-agentの(恐らく)子プロセスが残った状態となります。 |
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
// 本当にやりたいこと | |
class Container[_X] | |
trait Get[_Elem, _Con <: Container[_Elem]]{ | |
def get(a: _Con): _Elem | |
} | |
def con[_Elem, _Con <: Container[_Elem]](a: _Con)(implicit getter: Get[_Elem, _Con]): _Elem = getter.get(a) |
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
class Container[_X] | |
def con[_Elem, _Con <: Container[_Elem]](a: _Con): _Con = a | |
// inferred type arguments [Nothing,Container[String]] do not conform to method con's type parameter bounds [_Elem,_Con <: Container[_Elem]] | |
con(new Container[String]) |
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
// 間違ってたので書換 | |
// 自己参照する型引数を持つtraitを定義 | |
trait A[_E, _A <: A[_A]]{ | |
def m: _A = this.asInstanceOf[_A] | |
} | |
// mixin | |
class B[_E] extends A[_E, B[_E]] |
NewerOlder