bio4j / dynamograph

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

Meeting 16.07.2014 - question and notes #42

Closed alberskib closed 10 years ago

alberskib commented 10 years ago

Questions:

 case object edgeItem    extends Item(edgeTables.edgeTable, edgeTables.edgeTable.hashKey :~: sourceId :~: targetId :~: ∅)
  case object edgeInItem  extends Item(edgeTables.inTable, edgeTables.inTable.hashKey :~: edgeTables.inTable.rangeKey :~: ∅)
  case object edgeOutItem extends Item(edgeTables.outTable, edgeTables.outTable.hashKey :~: edgeTables.outTable.rangeKey :~: ∅)

  def write(rep: element.Rep): List[WriteType] = {
    val edgeRep = edgeItem ->> (
        (relationId   ->> rep get(relationId.label)) :~:
        (sourceId     ->> rep get(sourceId.label)) :~:
        (targetId     ->> rep get(targetId.label)) :~:
        ∅
    )
    val inTableRequest  = InTable(edgeTables.inTable,   Active(edgeTables.inTable,    ServiceProvider.service.account,
      ThroughputStatus(1,1))) putItem edgeInItem  withValue (edgeRep ->> edgeInItem)
    val outTableRequest = InTable(edgeTables.outTable,  Active(edgeTables.outTable,   ServiceProvider.service.account,
      ThroughputStatus(1,1))) putItem edgeOutItem withValue (edgeRep ->> edgeOutItem)
    val tableRequest    = InTable(edgeTables.edgeTable, Active(edgeTables.edgeTable,  ServiceProvider.service.account,
      ThroughputStatus(1,1))) putItem edgeItem    withValue  edgeRep

    List(inTableRequest, outTableRequest, tableRequest)
alberskib commented 10 years ago

remove:

    val edgeRep = edgeItem ->> (
        (relationId   ->> rep get(relationId.label)) :~:
        (sourceId     ->> rep get(sourceId.label)) :~:
        (targetId     ->> rep get(targetId.label)) :~:
        ∅
    )

and insteadOf:

val inTableRequest  = InTable(edgeTables.inTable,   Active(edgeTables.inTable,    ServiceProvider.service.account,
      ThroughputStatus(1,1))) putItem edgeInItem  withValue (edgeRep ->> edgeInItem)

use:

val inTableRequest  = InTable(edgeTables.inTable,   Active(edgeTables.inTable,    ServiceProvider.service.account,
      ThroughputStatus(1,1))) putItem edgeInItem  withValue (rep ->> edgeInItem)
eparejatobes commented 10 years ago
eparejatobes commented 10 years ago
eparejatobes commented 10 years ago
eparejatobes commented 10 years ago
laughedelic commented 10 years ago

@alberskib using HLists and Poly from shapeless can be hard and confusing at the beginning, so ask me/us if you have any difficulties (there are no stupid questions regarding this topic)

alberskib commented 10 years ago

@laughedelic Thanks. I really appreciate it: Could I write in some kind dynamic poly? Sth like this:

 object createTable extends Poly1{
    implicit def caseAnyTable = at[T <: scala.Singleton with ohnosequences.tabula.AnyTable](x =>
      service please CreateTable(x, InitialState(x, service.account, InitialThroughput(1,1))))
  }

Or I must write implicit for each specific type I could find in Hlist (GoVertexTable, GoNamespaceTable)?

eparejatobes commented 10 years ago

sure, you can make generic cases

alberskib commented 10 years ago

Notes:

laughedelic commented 10 years ago

Ok, I see that you already got it, but maybe this can bit a bit more generic:

 object createTable extends Poly1{
    implicit def caseAnyTable[T <: Singleton with AnyTable, E <: Executor.For[CreateTable[T]]]
      (implicit exec: CreateTable[T] => E) =
      at[T](t => service please CreateTable(t, InitialState(t, service.account, InitialThroughput(1,1))))
  }

the point here is that you require an implicit executor to create this poly-case and then you don't need to do import ServiceProvider.executors._ (only in the place where you will call this poly)