Github user davies commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3920#discussion_r24187984
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/pythonconverters/HBaseConverters.scala
 ---
    @@ -23,15 +23,27 @@ import org.apache.spark.api.python.Converter
     import org.apache.hadoop.hbase.client.{Put, Result}
     import org.apache.hadoop.hbase.io.ImmutableBytesWritable
     import org.apache.hadoop.hbase.util.Bytes
    +import org.apache.hadoop.hbase.KeyValue.Type
    +import org.apache.hadoop.hbase.CellUtil
     
     /**
    - * Implementation of [[org.apache.spark.api.python.Converter]] that 
converts an
    - * HBase Result to a String
    + * Implementation of [[org.apache.spark.api.python.Converter]] that 
converts all
    + * the records in an HBase Result to a String
      */
     class HBaseResultToStringConverter extends Converter[Any, String] {
       override def convert(obj: Any): String = {
    +    import collection.JavaConverters._
         val result = obj.asInstanceOf[Result]
    -    Bytes.toStringBinary(result.value())
    +    val output = result.listCells.asScala.map(cell =>
    +        
"{'columnFamily':'%s','qualifier':'%s','timestamp':'%s','type':'%s','value':'%s'}".format(
    --- End diff --
    
    We could the converter still return a string, but in json format, then we 
could decode them in Python using simplejson. Json library will do the escaping 
for us.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to