Apache Spark optimization