Skip to content

Commit

Permalink
[SPARK-26081][SQL][FOLLOW-UP] Use foreach instead of misuse of map (f…
Browse files Browse the repository at this point in the history
…or Unit)

## What changes were proposed in this pull request?

This PR proposes to use foreach instead of misuse of map (for Unit). This could cause some weird errors potentially and it's not a good practice anyway. See also SPARK-16694

## How was this patch tested?

N/A

Closes apache#23341 from HyukjinKwon/followup-SPARK-26081.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
  • Loading branch information
HyukjinKwon committed Dec 18, 2018
1 parent d72571e commit 218341c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,5 @@ private[csv] class CsvOutputWriter(
gen.write(row)
}

override def close(): Unit = univocityGenerator.map(_.close())
override def close(): Unit = univocityGenerator.foreach(_.close())
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,5 @@ private[json] class JsonOutputWriter(
gen.writeLineEnding()
}

override def close(): Unit = jacksonGenerator.map(_.close())
override def close(): Unit = jacksonGenerator.foreach(_.close())
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class TextOutputWriter(
private var outputStream: Option[OutputStream] = None

override def write(row: InternalRow): Unit = {
val os = outputStream.getOrElse{
val os = outputStream.getOrElse {
val newStream = CodecStreams.createOutputStream(context, new Path(path))
outputStream = Some(newStream)
newStream
Expand All @@ -167,6 +167,6 @@ class TextOutputWriter(
}

override def close(): Unit = {
outputStream.map(_.close())
outputStream.foreach(_.close())
}
}

0 comments on commit 218341c

Please sign in to comment.