Last active
January 3, 2016 23:59
-
-
Save laughedelic/8538472 to your computer and use it in GitHub Desktop.
TitanDB:
checking, that multi-value property doesn't add duplicates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > import com.thinkaurelius.titan.core._ | |
| > import com.tinkerpop.blueprints.Vertex | |
| > val g = TitanFactory.open(".") | |
| > g.makeKey("k").dataType(classOf[String]).list().unique().indexed(classOf[Vertex]).make() | |
| // is there any nicer way of creating TitanVertex? | |
| > val v = g.addVertex(null).asInstanceOf[TitanVertex] | |
| > v.addProperty("k", "foo") | |
| > v.addProperty("k", "bar") | |
| > v.addProperty("k", "qux") | |
| // checking: | |
| > v.getProperty("k"): java.util.ArrayList[String] | |
| res: java.util.ArrayList[String] = [bar, foo, qux] | |
| > v.addProperty("k", "bar") | |
| java.lang.IllegalArgumentException: The given value [bar] is already used as a property and the property key [k] is defined as graph-unique | |
| at com.google.common.base.Preconditions.checkArgument(Preconditions.java:119) | |
| at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.addPropertyInternal(StandardTitanTx.java:507) | |
| at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.addProperty(StandardTitanTx.java:487) | |
| at com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsTransaction.addProperty(TitanBlueprintsTransaction.java:160) | |
| at com.thinkaurelius.titan.graphdb.vertices.AbstractVertex.addProperty(AbstractVertex.java:203) | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment