aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala
diff options
context:
space:
mode:
authorChandan Rajah <crajah@parallelai.com>2013-08-07 11:29:57 +0100
committerChandan Rajah <crajah@parallelai.com>2013-08-07 11:29:57 +0100
commit2af55565c99297ddbce5ec9bb29a8e650a2a968f (patch)
treee17b9fccf8ecc72e4a84810869992440dc9c16db /src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala
parent6a2492a8a0a9a977664e7bfe3e0eb048de1a74b4 (diff)
parentde38789a032b586b0e278a81dedb5c8fb6d43e02 (diff)
downloadSpyGlass-SCALA_2.9.3_2.4.0.tar.gz
SpyGlass-SCALA_2.9.3_2.4.0.zip
Merged changes from koertkuipersSCALA_2.9.3_2.4.0
Diffstat (limited to 'src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala')
-rw-r--r--src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala b/src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala
index b6d5742..31ed3ea 100644
--- a/src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala
+++ b/src/main/scala/parallelai/spyglass/hbase/HBaseConversions.scala
@@ -10,15 +10,14 @@ import org.apache.hadoop.hbase.util.Bytes
import cascading.tuple.TupleEntry
class HBasePipeWrapper (pipe: Pipe) {
- def toBytesWritable(f: Fields): Pipe = {
+ def toBytesWritable(f: Fields): Pipe = {
asList(f)
- .foldLeft(pipe){ (p, f) => {
- p.map(f.toString -> f.toString){ from: String => {
- new ImmutableBytesWritable(Bytes.toBytes(
- if (from == null) "" else from))
- }}
- }}
- }
+ .foldLeft(pipe){ (p, f) => {
+ p.map(f.toString -> f.toString){ from: String =>
+ Option(from).map(x => new ImmutableBytesWritable(Bytes.toBytes(x))).getOrElse(null)
+ }}
+ }
+ }
// def toBytesWritable : Pipe = {
// asList(Fields.ALL.asInstanceOf[TupleEntry].getFields()).foldLeft(pipe){ (p, f) => {
@@ -30,13 +29,12 @@ class HBasePipeWrapper (pipe: Pipe) {
def fromBytesWritable(f: Fields): Pipe = {
asList(f)
- .foldLeft(pipe) { (p, fld) =>
- p.map(fld.toString -> fld.toString) { from: ImmutableBytesWritable => {
- Bytes.toString(from.get)
- }
- }
- }
- }
+ .foldLeft(pipe) { (p, fld) => {
+ p.map(fld.toString -> fld.toString) { from: ImmutableBytesWritable =>
+ Option(from).map(x => Bytes.toString(x.get)).getOrElse(null)
+ }
+ }}
+ }
// def fromBytesWritable : Pipe = {
// asList(Fields.ALL.asInstanceOf[TupleEntry].getFields()).foldLeft(pipe) { (p, fld) =>