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 $ivy.`com.github.pemistahl:lingua:1.0.1`, com.github.pemistahl.lingua.api._, com.github.pemistahl.lingua.api.Language._ | |
private val DefaultPattern = "txt" | |
private val QuotePattern = """("(?<dqt>[^"]*)")|('(?<sqt>[^']*)')""".r | |
private val SplitMatched = """([-,/])""".r | |
private val SplitCameCase = """(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])""".r | |
private val MinKeywordLen = 3 | |
private val CacheDir = os.Path("/tmp/.detect-non-english-cache") |
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
/** | |
* A stateful implementation of an auto-closable lock/monitor | |
* for the specified lockwith an ability to unlock it preliminarily. | |
* The class philosophy and namings are borrowed from C++ std::unique_lock<>. | |
* | |
* @apiNote this class isn't reentrant and isn't supposed to be shared across threads | |
* or to be used as a field. | |
* The instances of this class should be used as | |
* stack/method local variables with try-with-resources. | |
*/ |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE DuplicateRecordFields #-} | |
module Main where | |
import GHC.Generics | |
import Data.Aeson(ToJSON) | |
import Web.Scotty (ActionM, ScottyM, get, header, scotty, scottyApp, status, json, middleware, html) |
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
val conf = new SparkConf() | |
//.setMaster("local") for local development | |
.setAppName("FizzBuzz App") | |
val spark = SparkSession | |
.builder() | |
.config(conf) | |
.getOrCreate() | |
import spark.implicits._ |
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
// FizzBuzzNumber.avsc | |
{ | |
"namespace": "fizzbuzz", | |
"type": "record", | |
"name": "FizzBuzzNumber", | |
"fields":[ | |
{ | |
"name": "value", | |
"type": { | |
"type": "int" |
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 fizzbuzz | |
import cloudflow.akkastream._ | |
import cloudflow.akkastream.scaladsl._ | |
import cloudflow.streamlets._ | |
import cloudflow.streamlets.avro._ | |
class FizzBuzzPrinter extends AkkaStreamlet { | |
val inlet = AvroInlet[FizzBuzzResult]( "in" ) | |
val shape = StreamletShape.withInlets( inlet ) |
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 fizzbuzz | |
import cloudflow.akkastream._ | |
import cloudflow.akkastream.scaladsl._ | |
import cloudflow.streamlets.{ RoundRobinPartitioner, StreamletShape } | |
import cloudflow.streamlets.avro._ | |
class FizzBuzzProcessor extends AkkaServerStreamlet { | |
def basicFizzbuzzRules( x: Int ): 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
package fizzbuzz | |
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._ | |
import cloudflow.akkastream._ | |
import cloudflow.akkastream.util.scaladsl._ | |
import cloudflow.streamlets._ | |
import cloudflow.streamlets.avro._ |
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 akka.actor.ActorSystem | |
import akka.stream._ | |
import akka.stream.scaladsl._ | |
import scala.concurrent.duration._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
def reactiveFizzbuzz( n: Int )( rules: Int => String ): Source[( Int, String ), _] = { | |
Source( | |
1 to n |
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.collection.parallel.CollectionConverters._ | |
import scala.collection.parallel.ParSeq | |
def parallelFizzbuzz( n: Int )( rules: Int => String ): ParSeq[( Int, String )] = { | |
(1 to n).par | |
.map(x => ( x, rules( x ) ) ) | |
} | |
parallelFizzbuzz( N )( basicFizzbuzzRules ).foreach( println ) |
NewerOlder