Label with given name does not exist Exception

660 views
Skip to first unread message

Sotiris Beis

unread,
Dec 5, 2013, 4:08:34 AM12/5/13
to aureliu...@googlegroups.com
Hi, 
I have the following code: 

public class TitanMassiveInsertion {

private TitanGraph titanGraph = null;

private BatchGraph<TitanGraph> batchGraph = null;

public static void main(String args[]) {

TitanMassiveInsertion test = new TitanMassiveInsertion();

test.startup("data/titanDB");

test.createGraph("data/flickrEdges.txt");

test.shutdown();

}

public void startup(String titanDBDir) {

System.out.println("The Titan database is now starting . . . .");

BaseConfiguration config = new BaseConfiguration();

        Configuration storage = config.subset(GraphDatabaseConfiguration.STORAGE_NAMESPACE);

        storage.setProperty(GraphDatabaseConfiguration.STORAGE_BACKEND_KEY, "local");

        storage.setProperty(GraphDatabaseConfiguration.STORAGE_DIRECTORY_KEY, titanDBDir);

        storage.setProperty(GraphDatabaseConfiguration.STORAGE_BATCH_KEY, true);

titanGraph = TitanFactory.open(config);

titanGraph.createKeyIndex("nodeId", Vertex.class);

titanGraph.commit();

batchGraph = new BatchGraph<TitanGraph>(titanGraph, VertexIDType.STRING, 1000);

batchGraph.setVertexIdKey("nodeId");

batchGraph.setLoadingFromScratch(true);

}

public void createGraph(String datasetDir) {

System.out.println("Creating the Titan database . . . .");

try {

BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(datasetDir)));

String line;

int lineCounter = 1;

int nodeCounter = 0;

Vertex srcVertex, dstVertex;

while((line = reader.readLine()) != null) {

if(lineCounter > 4) {

String[] parts = line.split("\t");

srcVertex = batchGraph.getVertex(parts[0]);

if(srcVertex == null) {

srcVertex = batchGraph.addVertex(parts[0]);

srcVertex.setProperty("nodeId", parts[0]);

nodeCounter++;

}

dstVertex = batchGraph.getVertex(parts[1]);

if(dstVertex == null) {

dstVertex = batchGraph.addVertex(parts[1]);

dstVertex.setProperty("nodeId", parts[1]);

nodeCounter++;

}

Edge edge = batchGraph.addEdge(null, batchGraph.getVertex(parts[0]), batchGraph.getVertex(parts[1]), "similar");

System.out.println(edge);

System.out.println(nodeCounter);

}

lineCounter++;

}

reader.close();

}

catch(IOException ioe) {

ioe.printStackTrace();

}

}

public void shutdown() {

System.out.println("The Titan database is now shuting down . . . .");

if(titanGraph != null) {

batchGraph.shutdown();

titanGraph.shutdown();

batchGraph = null;

titanGraph = null;

}

}

}


I keep getting the following error:

Exception in thread "main" java.lang.IllegalArgumentException: Label with given name does not exist

at com.thinkaurelius.titan.graphdb.types.DisableDefaultTypeMaker.makeLabel(DisableDefaultTypeMaker.java:18)

at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.getEdgeLabel(StandardTitanTx.java:646)

at com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsTransaction.addEdge(TitanBlueprintsTransaction.java:124)

at com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsTransaction.addEdge(TitanBlueprintsTransaction.java:116)

at com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsGraph.addEdge(TitanBlueprintsGraph.java:217)

at com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsGraph.addEdge(TitanBlueprintsGraph.java:24)

at com.tinkerpop.blueprints.util.wrappers.batch.BatchGraph.addEdge(BatchGraph.java:380)

at com.tinkerpop.blueprints.util.wrappers.batch.BatchGraph.addEdge(BatchGraph.java:367)

at TitanMassiveInsertion.createGraph(TitanMassiveInsertion.java:106)

at TitanMassiveInsertion.main(TitanMassiveInsertion.java:29) 

Stephen Mallette

unread,
Dec 5, 2013, 6:22:26 AM12/5/13
to aureliu...@googlegroups.com
I think you need to define your types up front when batchloading is turned on.  I don't see where you are defining your schema in your code sample:


Defining types up front is recommended practice with or without batchloading.


--
You received this message because you are subscribed to the Google Groups "Aurelius" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aureliusgraph...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Alex Punnen

unread,
Oct 13, 2016, 7:02:21 AM10/13/16
to Aurelius
This is happening even when label is defined; Seems to be a bug. It is throwing error at the default label tag

mgmt.makeVertexLabel("ID").make()
val serving_cell: Vertex = GraphDBConnectionTest.graph.asScala.addVertex("cell")
or
val serving_cell: Vertex = GraphDBConnectionTest.graph +(s"cell-1", ID -> s"cell-2")
or
val serving_cell: Vertex = GraphDBConnectionTest.graph.addVertex(T.label,"cell")

java.lang.IllegalArgumentException: Vertex Label with given name does not exist: cell

	at com.thinkaurelius.titan.graphdb.types.typemaker.DisableDefaultSchemaMaker.makeVertexLabel(DisableDefaultSchemaMaker.java:37)
	at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.getOrCreateVertexLabel(StandardTitanTx.java:988)
	at com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsTransaction.addVertex(TitanBlueprintsTransaction.java:101)
	at com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsGraph.addVertex(TitanBlueprintsGraph.java:115)

 "com.michaelpollmeier" %% "gremlin-scala" % "3.0.2-incubating.2",
"com.thinkaurelius.titan" % "titan-core" % "1.0.0",
"com.thinkaurelius.titan" % "titan-cassandra" % "1.0.0"


Jason Plurad

unread,
Oct 13, 2016, 6:18:35 PM10/13/16
to Aurelius
Hi Alex,

You must have the schema.default=none in your Titan properties. When automatic schema creation is disabled like this, you must first define the label through the schema management system before attempting to create a vertex that uses it. Make sure you commit() the schema also.

-- Jason
Reply all
Reply to author
Forward
0 new messages