DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Please follow the style of the existing codebase. Apache Spark follows the official Scala style guide, but with the following changes:
| Table of Contents |
|---|
Line Length
Limit lines to 100 characters. The only exceptions are import statements (although even for those, try to keep them under 100 chars).
Indentation
Use 2-space indentation in general. For function declarations, use 4 space indentation for its parameters when they don't fit in a single line. For example:
| Code Block | ||||
|---|---|---|---|---|
| ||||
// 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
}
|
...
Put curly braces even around one-line if, else or loop statements. The only exception is if you are using if/else as an one-line ternary operator.
| Code Block | ||||
|---|---|---|---|---|
| ||||
// Correct:
if (true) {
println("Wow!")
}
// Correct:
if (true) statement1 else statement2
// Wrong:
if (true)
println("Wow!")
|
...