bio4j / dynamograph

GSoC 2014 project - a DynamoDB based graph DB
GNU Affero General Public License v3.0
4 stars 1 forks source link

Tabula - newest SNAPSHOT #31

Closed alberskib closed 10 years ago

alberskib commented 10 years ago

@bio4j/dynamograph Hello, I updated dynamograph to the newest version of tabula (just checkout master branch from github and release SNAPSHOT) ... Next I create some kind of TableModelInitializer which should create tables for GO. In code it looks more or less like this:

class TableModelInitializer {
  case object service extends AnyDynamoDBService {
    type Region = EU.type
    val region = EU
    type Account = ohnosequences.tabula.Account
    val account: Account = Account("", "")
    def endpoint: String = "" //shouldn't be here
  }
  val executors = new DynamoDBExecutors(
    new DynamoDBClient(EU,
      new AmazonDynamoDBClient(CredentialProviderChains.default)) {
      client.setRegion(Region.getRegion(Regions.EU_WEST_1))
    }
  )
  def initialize() = {
    service please CreateTable(GoTermTable, InitialState(GoTermTable, service.account, InitialThroughput(1,1)))
  }
}

But when I try to compile it I receive error:

No implicit view available from ohnosequences.tabula.CreateTable[com.bio4j.dynamograph.model.go.TableGoImplementation.GoTermTable.type] => E

Such implicit must be created for each type of the Table or I am missing sth?

laughedelic commented 10 years ago

I'll explain you how to deal with it. It's a pity that we cannot improve much the error message in this case (but I'll think about it).

Here is the signature of the service's please moethod:

  def please[A <: AnyAction, E <: Executor.For[A]](action: A)
    (implicit mkE: A => E): E#Out = {
      val exec = mkE(action)
      exec()
    }

So it requires an implicit that constructs an executor for the given action. In your case, the action is CreateTable(...). And you have a val executors, which are actually implicit defs from actions to executors (that's what we need). So the solution here is that inside of initialize you have to import those implicit conversions (just import executors._). Tell me if it helps or not.

alberskib commented 10 years ago

Great. Works perfectly. I was thinking that if I create executors inside commong object it will work correctly.