2016-05-03 5 views
0

Ich habe Probleme mit PartitionStrategy und titanDb und DynamoDb als Backend zu arbeiten. Ich benutze dynamoDb als lokales Backend mit dynamodb-titan-storage-backend plugin. Im Folgenden ist ein einfacher Test Fall, dass ich in Java geschrieben habe:PartitionStrategy mit titanDb und DynamoDb als Backend, das keine Ecke zum Graphen hinzufügt

import com.thinkaurelius.titan.core.TitanEdge; 
import com.thinkaurelius.titan.core.TitanFactory; 
import com.thinkaurelius.titan.core.TitanGraph; 
import com.thinkaurelius.titan.core.TitanGraphQuery; 
import com.thinkaurelius.titan.core.TitanTransaction; 
import com.thinkaurelius.titan.core.TitanVertex; 
import org.apache.commons.configuration.BaseConfiguration; 
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; 
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; 
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy; 
import org.apache.tinkerpop.gremlin.structure.Direction; 
import org.apache.tinkerpop.gremlin.structure.Vertex; 
import org.apache.tinkerpop.gremlin.structure.VertexProperty; 
import org.junit.Before; 
import org.junit.Test; 
import org.junit.runner.RunWith; 
import java.util.Iterator; 

public class TitanTest { 

    TitanGraph titanGraph; 

    @Before 
    public void setUp() { 
     BaseConfiguration conf = new BaseConfiguration(); 
     conf.setProperty("storage.backend", "com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager"); 
     conf.setProperty("storage.dynamodb.client.endpoint", "http://localhost:4567"); 
     titanGraph = TitanFactory.open(conf); 
    } 

    @Test 
    public void testAddVertexToTitanGraph(){ 
     titanGraph.addVertex("name", "Bob", "age", "4.6x10^9"); 
     titanGraph.traversal().V().forEachRemaining(it -> { 
     System.out.println("Found " + it.value("name")); 
     }); 
    } 

    @Test 
    public void addVertexViaPartitionStrategy() { 
     PartitionStrategy partitionStrategy = PartitionStrategy.build().partitionKey("_partition").writePartition("a").addReadPartition("a").create(); 
     GraphTraversalSource graphTraversalSource = GraphTraversalSource.build().with(partitionStrategy).create(titanGraph); 
     GraphTraversal<Vertex, Vertex> marko = graphTraversalSource.addV("name", "marko", "age", 29); 
     graphTraversalSource.V().forEachRemaining(it -> { 
     System.out.println("name:" + it.value("name").toString()); 
     }); 

    } 
} 

aber ich scheine nicht alles raus gedruckt, wenn ich den addVertexViaPartitionStrategy Testfall ausgeführt werden. Ich habe das Beispiel hier folgt: http://tinkerpop.apache.org/docs/3.0.1-incubating/#_partitionstrategy

Ich bin in der Lage auf die Datenbank zu lesen und zu schreiben, siehe Test testAddVertexToTitanGraph, nur nicht in der Lage einen Scheitelpunkt zu erstellen, wenn Partition stratergy verwenden.

Antwort

0

Ich lief gerade in das gleiche Problem mit Titan 1.0.0 mit einem Cassandra-Back-End. Anscheinend müssen Sie das Ergebnis des Durchlaufs holen, damit der Vertex hinzugefügt werden kann.

So funktioniert das:

GraphTraversalSource gA = GraphTraversalSource.build().with(partitionStrategy).create(g); 
    GraphTraversal<Vertex, Vertex> addV = gA.addV(); 
    Vertex v = addV.next(); 
    System.out.println("v: " + v); 

    GraphTraversal<Vertex, Long> count = gA.V().count(); 
    long amt = count.next(); 
    System.out.println("Partition vertex count: " + amt);