tree: e9163d2a62c9522528a52e3de4eb010f83e280d7 [path history] [tgz]
  1. project/
  2. src/
  3. build.sbt
  4. README.md
scala-client/README.md

pegasus-scala-client

It's built on top of the java client apache/incubator-pegasus/java-client.

Features:

  • Scala friendly.
  • Serialize/deserialize automatically.

Example:

    import org.apache.pegasus.scalaclient.Serializers._

    val c = ScalaPegasusClientFactory.createClient("resource:///pegasus.properties")
   
    // set/get/del
    val hashKey = 12345L
    c.set(table, hashKey, "sort_1", "value_1")
    val value = c.get(table, hashKey, "sort_1").as[String]
    c.del(table, hashKey, "sort_1")
    c.exists(table, hashKey, "sort_1") 
    c.sortKeyCount(table, hashKey)
    
    // multiset/multiget/multidel
    val values = Seq("sort_1" -> "value_1", "sort_2" -> "value_2", "sort_3" -> "value_3")
    val sortKeys = values.unzip._1 
    
    c.multiSet(table, hashKey, values)
    val count = c.sortKeyCount(table, hashKey)
    val multiGetValues = c.multiGet(table, hashKey, sortKeys).as[String]
    val multiGetSortKeys = c.multiGetSortKeys(table, hashKey)
    c.multiDel(table, hashKey, Seq("sort_1", "sort_2"))
    
    c.close

Development

Format the code

Use scala format tool, see https://github.com/scalameta/scalafmt

sbt scalafmtSbt scalafmt test:scalafmt

Run tests

NOTE: It requires the Pegasus onebox has been started.

Build Java dependency at first, then build and test Scala client.

cd ${PROJECT_ROOT}/java-client/scripts
./recompile_thrift.sh

cd ${PROJECT_ROOT}/java-client
mvn clean package -DskipTests -Dcheckstyle.skip=true
mvn clean install -DskipTests -Dcheckstyle.skip=true

cd ${PROJECT_ROOT}/scala-client
sbt test