简体   繁体   中英

Titan and Cassandra Truncating Long Strings When Persisting Graph

When creating a graph, for example:

TitanGraph graph =  TitanFactory.open("conf/titan-cassandra-es.properties");
Vertex v = graph.addVertex()
v.property("Value", "very very very very very very very very vey long string");
graph.tx().commit();

I find that titan is truncating the string to only 20 characters when committing. I am using the standard configuration as defined here . Is there some additional configuration I am missing ?

What you are seeing is that you are getting the result of VertexProperty.toString() rather than getting the value with VertexProperty.value() . Here is a Gremlin Console session to demonstrate the difference:

gremlin> graph = TitanFactory.build().set('storage.backend','cassandra').set('storage.cassandra.keyspace','fido').open()
==>standardtitangraph[cassandra:[127.0.0.1]]
gremlin> v = graph.addVertex() // create a vertex
==>v[4256]
gremlin> v.property('value', 'very very very very very very very very vey long string') // set a property
==>vp[value->very very very very ]
gremlin> v.property('value').getClass() // check the class on the property
==>class com.thinkaurelius.titan.graphdb.relations.StandardVertexProperty
gremlin> v.property('value').toString() // vertex property object as a string
==>vp[value->very very very very ]
gremlin> v.property('value').value().getClass() // check the class of the value of the vertex property
==>class java.lang.String
gremlin> v.property('value').value() // get the value of the vertex property (explicit syntax)
==>very very very very very very very very vey long string
gremlin> v.values('value').next().getClass() // check the class of the value of the vertex property
==>class java.lang.String
gremlin> v.values('value').next() // get the value of the vertex property (simpler syntax)
==>very very very very very very very very vey long string

There is some discussion about vertex properties worth reading in the TinkerPop3 documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM