spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From haosdent <...@git.apache.org>
Subject [GitHub] spark pull request: SPARK-1127 Add spark-hbase.
Date Sat, 22 Mar 2014 17:30:20 GMT
Github user haosdent commented on a diff in the pull request:

    https://github.com/apache/spark/pull/194#discussion_r10863237
  
    --- Diff: external/hbase/src/test/scala/org/apache/spark/nosql/hbase/HBaseSuite.scala
---
    @@ -0,0 +1,48 @@
    +package org.apache.spark.nosql.hbase
    +
    +import org.scalatest.FunSuite
    +import org.apache.hadoop.io.Text
    +import org.apache.spark.{SparkContext, LocalSparkContext}
    +import org.apache.hadoop.hbase.util.Bytes
    +import org.apache.hadoop.hbase.{HConstants, HBaseTestingUtility}
    +import org.apache.hadoop.hbase.client.{Scan, HTable}
    +
    +class HBaseSuite extends FunSuite with LocalSparkContext {
    +
    +  test("write SequenceFile using HBase") {
    +    sc = new SparkContext("local", "test")
    +    val nums = sc.makeRDD(1 to 3).map(x => new Text("a" + x + " 1.0"))
    +
    +    val table = "test"
    +    val rowkeyType = HBaseType.String
    +    val cfBytes = Bytes.toBytes("cf")
    +    val qualBytes = Bytes.toBytes("qual0")
    +    val columns = List[HBaseColumn](new HBaseColumn(cfBytes, qualBytes, HBaseType.Float))
    +    val delimiter = ' '
    +
    +    val util = new HBaseTestingUtility()
    +    util.startMiniCluster()
    +    util.createTable(Bytes.toBytes(table), cfBytes)
    +    val conf = util.getConfiguration
    +    val zkHost = conf.get(HConstants.ZOOKEEPER_QUORUM)
    +    val zkPort = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT)
    +    val zkNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT)
    +
    +    HBaseUtils.saveAsHBaseTable(nums, zkHost, zkPort, zkNode, table, rowkeyType, columns,
delimiter)
    +
    +    val htable = new HTable(conf, table)
    +    val scan = new Scan()
    +    val rs = htable.getScanner(scan)
    --- End diff --
    
    Sorry, I forgot it. Have fixed it.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message