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
interface ObjectStoreTx { | |
CompletableFuture<Void> execute(TxContext ctx); | |
Optional<Throwable> rollback(); | |
} | |
public final class CompletableFutureSaga { | |
private CompletableFuture<TxContext> executeHeadTx(Iterator<ObjectStoreTx> txs, TxContext ctx) { | |
if (!txs.hasNext()) { | |
return CompletableFuture.completedFuture(ctx); |
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.SparkSession; | |
public class SparkDriver { | |
public static void main(String[] args) { | |
final SparkSession session = SparkSession.builder(). | |
appName("MySparkApp" + System.currentTimeMillis()). | |
master(SparkEnvCfg.sparkMasterUrl()). | |
config(SparkEnvCfg.SPARK_EXECUTOR_MEMORY, "1g"). | |
config(SparkEnvCfg.SPARK_SERIALIZER, SparkEnvCfg.KRYO). | |
config(SparkEnvCfg.SPARK_SQL_SHUFFLE_PARTITIONS, "2"). |
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
public void readAndCache(SQLContext sqlCtx, File file) { | |
final DataFrame df = sqlCtx.read().parquet("file://" + file.getAbsolutePath()) | |
sqlCtx.registerDataFrameAsTable(df, name); | |
sqlCtx.cacheTable(name); // != df.persist(StorageLevel.MEMORY_ONLY_SER()) when reading from a Parquet file | |
final long rowCount = df.count(); // warm-up cache | |
} |