Skip to content

Instantly share code, notes, and snippets.

Supposing you've installed spark with brew install spark@1.6
it will place it into /usr/local/opt/apache-spark@1.6
to use spark locally from intellij from your script define following:
1. environment variables:
PYSPARK_PYTHON=/Users/igorberm/.runtimes/Python34/bin/python3
PYTHONPATH=/usr/local/opt/apache-spark@1.6/libexec/python/lib/pyspark.zip:/usr/local/opt/apache-spark@1.6/libexec/python/lib/py4j-0.9-src.zip
PYTHONUNBUFFERED=1
SPARK_HOME=/usr/local/opt/apache-spark@1.6/libexec
@IgorBerman
IgorBerman / SubstreamsWithOrder.java
Created April 7, 2017 15:30
Substreams with order and dispatcher, instead of ConsistentHashingPool with ask+timeout with blocking processing
//without backpressure:
ActorRef myActor = system.actorOf(
new akka.routing.ConsistentHashingPool(maxParallelism)
.withHashMapper(hashMapper)
.props(MyActor.props(blLogic).withDispatcher("my-dispatcher"))
, "my-ordered-processor-pool");
final Timeout timeout = Timeout.apply(1000L, TimeUnit.MILLISECONDS);
Flow.of(Event.class)
@IgorBerman
IgorBerman / StreamWithHttpPoolExample.java
Last active February 27, 2018 07:57
akka-http akka-streams java8
package com.example;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import scala.runtime.BoxedUnit;
import scala.util.Try;
import akka.Done;
import akka.NotUsed;
import akka.actor.ActorSystem;
@IgorBerman
IgorBerman / StructuredStreaming.java
Created December 18, 2019 14:21
structured streaming example
package igorprivate;
import shaded.parquet.org.slf4j.LoggerFactory;
import static org.apache.spark.sql.functions.concat_ws;
import static org.apache.spark.sql.functions.date_format;
import static org.apache.spark.sql.functions.from_json;
import static org.apache.spark.sql.functions.lit;
import static org.apache.spark.sql.functions.struct;
import static org.apache.spark.sql.functions.sum;
import static org.apache.spark.sql.functions.to_json;
@IgorBerman
IgorBerman / gist:8a9b06fff891eb038b51
Created November 23, 2014 22:09
some usefull queries from pg_hero
require "pghero/version"
require "active_record"
require "pghero/engine" if defined?(Rails)
module PgHero
# hack for connection
class Connection < ActiveRecord::Base
establish_connection ENV["PGHERO_DATABASE_URL"] if ENV["PGHERO_DATABASE_URL"]
end
@IgorBerman
IgorBerman / ExceptionHandlingExample.java
Created January 26, 2017 10:22
akka streams in java with kill switch, shutdown hook and error handling
package com.example;
import java.util.concurrent.CompletionStage;
import scala.concurrent.Await;
import scala.concurrent.duration.Duration;
import akka.Done;
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.japi.Pair;