Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
scala
scala
// Correct:
if (true) {
  println("Wow!")
}

// Wrong:
if (true) {
    println("Wow!")
}

// Correct:
def newAPIHadoopFile[K, V, F <: NewInputFormat[K, V]](
    path: String,
    fClass: Class[F],
    kClass: Class[K],
    vClass: Class[V],
    conf: Configuration = hadoopConfiguration): RDD[(K, V)] = {
  // function body
}

// Wrong 
def newAPIHadoopFile[K, V, F <: NewInputFormat[K, V]](
  path: String,
  fClass: Class[F],
  kClass: Class[K],
  vClass: Class[V],
  conf: Configuration = hadoopConfiguration): RDD[(K, V)] = {
  // function body
}

Code documentation style

Use For Scala doc / Java doc comment before classes, objects and methods, use Java docs style instead of Scala docs style.

Code Block
languagescala
/** This is a correct one-liner, short description. */
 
/**
 * This is correct multi-line JavaDoc comment. And
 * this is my second line, and if I keep typing, this would be
 * my third line.
 */
 
/** In Spark, we don't use the ScalaDoc style so this
  * is not correct.
  */

 

For inline comment with the code, use the usual // or /*  .. */ as it seems fit.

Code Block
languagescala
// This is a short, single line comment
 
/* This is a long single line comment, where this style also works. */
 
/*
 * This is a multi line comment.
 * Do not use scala doc style /** .. */ in this.
 */

 

Imports

Always import packages using absolute paths (e.g. scala.util.Random) instead of relative ones (e.g. util.Random).

...