Graph 具有给定名称的顶点标签不存在
我正在尝试执行以下代码:Graph 具有给定名称的顶点标签不存在,graph,cassandra,graph-databases,titan,gremlin,Graph,Cassandra,Graph Databases,Titan,Gremlin,我正在尝试执行以下代码: public class Friendster { /** * @param args * @throws FileNotFoundException */ public static void load(final TitanGraph graph,String filePath) throws FileNotFoundException { Scanner sc = new Scanner(new File(filePath)); Sy
public class Friendster {
/**
* @param args
* @throws FileNotFoundException
*/
public static void load(final TitanGraph graph,String filePath) throws FileNotFoundException {
Scanner sc = new Scanner(new File(filePath));
System.out.println("Inside Load Function");
for (int i =0 ; sc.hasNext();i++)
{
TitanTransaction tx = graph.newTransaction();
String friendLine = sc.nextLine();
String friendList[]= friendLine.split(":");
if(friendList.length==1)
{
continue;
}
else if(friendList[1].equals("notfound"))
{
String human="human";
tx.addVertex(T.label, human, "Name", "Not Found","No of Friends",0);
// tx.commit();
}
else if(friendList[1].equals("private"))
{
String human="human";
tx.addVertex(T.label, human, "Name", ""+friendList[0],"No of Freinds", "Private");
System.out.println("Node Added : "+ friendList[0]);
// tx.commit();
}
else
{
String human="human";
int friends_count=friendList[1].split(",").length;
tx.addVertex(T.label, human, "Name", ""+friendList[0],"No of Friends",friends_count);
System.out.println("Node Added : "+ friendList[0]);
String totalList[]=friendList[1].split(",");
for(int j=0;j<totalList.length;j++)
{
Iterator<Vertex> itr2=graph.traversal().V().has("Name", ""+totalList[j]);
if(!itr2.hasNext())
{
tx.addVertex(T.label, human, "Name", ""+totalList[j],"No of Friends",999);
System.out.println("Node Added : "+ totalList[j]);
// tx.commit();
}
}
}
tx.commit();
}
}
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
TitanGraph g = TitanFactory.open("titan-cassandra.properties");
//LOADING FROM FILE
load(g,"/media/laxmikant/New Volume/friends.txt");
g.close();
}
它之前执行正确,突然开始抛出错误
如果我们在GremlinShell中运行单个查询,它不会给出错误,但在java代码中它会抛出错误,这是为什么
这里的代码有什么问题 问题是您在titan-cassandra.properties文件中设置了schema.default=none,因此禁用了自动模式创建。禁用自动模式创建时,需要先定义模式,包括顶点和边上的所有标签、属性和索引,然后才能使用它们
有关如何定义架构的详细信息,请参阅Titan文档中的。问题是您在Titan-cassandra.properties文件中设置了schema.default=none,因此禁用了自动架构创建。禁用自动模式创建时,需要先定义模式,包括顶点和边上的所有标签、属性和索引,然后才能使用它们
有关如何定义架构的详细信息,请参阅Titan文档中的。如果将storage.batch-loading设置为true,则还会禁用自动架构创建,并且必须显式设置架构 请注意,当前使用TitanGraph时,这些设置似乎存在一个错误,它阻止使用标签-
但是,当将storage.batch-loading设置为true时,您可以创建不带标签的顶点并添加上述定义的属性,然后自动模式创建也会被禁用,并且您必须显式设置模式 请注意,当前使用TitanGraph时,这些设置似乎存在一个错误,它阻止使用标签-
但是,您可以创建一个不带标签的顶点,并添加上述定义的属性,感谢您的解决方案。它起作用了。。你能在这个问题上给我一点帮助吗?。谢谢你的解决方案。它起作用了。。你能在这个问题上给我一点帮助吗。
Exception in thread "main" java.lang.IllegalArgumentException: Vertex Label with given name does not exist: human
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 Friendster.load(Friendster.java:79)
at Friendster.main(Friendster.java:133)
lazy val graph = TitanFactory.build()
.set("storage.backend", storage_backend)
.set("storage.hostname", "127.0.0.1")
.set("storage.cassandra.keyspace", "titan_graph_test")
.set("storage.batch-loading", "true") //this removes the consitency lock ,which don't work well with NSQL backends
.open()
mgmt.makePropertyKey(TIME).dataType(classOf[String]).cardinality(Cardinality.SET).make()
mgmt.makeEdgeLabel("interference").make()