Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Usando Riak com Scala
import scala.collection.JavaConverters._
import com.basho.riak.client.{IRiakClient, RiakFactory}
import com.basho.riak.client.bucket.Bucket
class DBWrapper(private val riakClient:IRiakClient) {
def createHashWrapperFor( bucketName:String ): HashWrapper = {
HashWrapper.buildTableWrapper( buildBucket( bucketName ) )
private def buildBucket( bucketName:String ): Bucket = {
var bucket = riakClient.fetchBucket( bucketName ).execute()
if (bucket == null) bucket = riakClient.createBucket(bucketName).nVal(1).execute()
def listOfTables(): Set[String] = riakClient.listBuckets.asScala.toSet[String]
object DBWrapper {
def buildDBWrapper(host:String, port:Int): DBWrapper = new DBWrapper( RiakFactory.pbcClient(host, port) )
def buildDBWrapper(host:String): DBWrapper = new DBWrapper( RiakFactory.pbcClient(host, 8087) )
def buildDBWrapper(): DBWrapper = new DBWrapper( RiakFactory.pbcClient("", 8087) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.