Skip to content

Commit

Permalink
use pattern match
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Jun 30, 2017
1 parent f630cbd commit cac8dc6
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,11 @@ object InternalRow {
/**
* Copies the given value if it's string/struct/array/map type.
*/
def copyValue(value: Any): Any = {
if (value.isInstanceOf[UTF8String]) {
value.asInstanceOf[UTF8String].copy()
} else if (value.isInstanceOf[InternalRow]) {
value.asInstanceOf[InternalRow].copy()
} else if (value.isInstanceOf[ArrayData]) {
value.asInstanceOf[ArrayData].copy()
} else if (value.isInstanceOf[MapData]) {
value.asInstanceOf[MapData].copy()
} else {
value
}
def copyValue(value: Any): Any = value match {
case v: UTF8String => v.copy()
case v: InternalRow => v.copy()
case v: ArrayData => v.copy()
case v: MapData => v.copy()
case _ => value
}
}

0 comments on commit cac8dc6

Please sign in to comment.