{"action":"created","issue":{"url":"https://api.github.com/repos/thinkaurelius/titan/issues/853","labels_url":"https://api.github.com/repos/thinkaurelius/titan/issues/853/labels{/name}","comments_url":"https://api.github.com/repos/thinkaurelius/titan/issues/853/comments","events_url":"https://api.github.com/repos/thinkaurelius/titan/issues/853/events","html_url":"https://github.com/thinkaurelius/titan/issues/853","id":50432598,"number":853,"title":"Timestamp conversion issues","user":{"login":"dkuppitz","id":572377,"avatar_url":"https://avatars.githubusercontent.com/u/572377?v=3","gravatar_id":"","url":"https://api.github.com/users/dkuppitz","html_url":"https://github.com/dkuppitz","followers_url":"https://api.github.com/users/dkuppitz/followers","following_url":"https://api.github.com/users/dkuppitz/following{/other_user}","gists_url":"https://api.github.com/users/dkuppitz/gists{/gist_id}","starred_url":"https://api.github.com/users/dkuppitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkuppitz/subscriptions","organizations_url":"https://api.github.com/users/dkuppitz/orgs","repos_url":"https://api.github.com/users/dkuppitz/repos","events_url":"https://api.github.com/users/dkuppitz/events{/privacy}","received_events_url":"https://api.github.com/users/dkuppitz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thinkaurelius/titan/labels/support","name":"support","color":"009800"}],"state":"closed","locked":false,"assignee":{"login":"mbroecheler","id":758061,"avatar_url":"https://avatars.githubusercontent.com/u/758061?v=3","gravatar_id":"","url":"https://api.github.com/users/mbroecheler","html_url":"https://github.com/mbroecheler","followers_url":"https://api.github.com/users/mbroecheler/followers","following_url":"https://api.github.com/users/mbroecheler/following{/other_user}","gists_url":"https://api.github.com/users/mbroecheler/gists{/gist_id}","starred_url":"https://api.github.com/users/mbroecheler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbroecheler/subscriptions","organizations_url":"https://api.github.com/users/mbroecheler/orgs","repos_url":"https://api.github.com/users/mbroecheler/repos","events_url":"https://api.github.com/users/mbroecheler/events{/privacy}","received_events_url":"https://api.github.com/users/mbroecheler/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/thinkaurelius/titan/milestones/18","labels_url":"https://api.github.com/repos/thinkaurelius/titan/milestones/18/labels","id":864220,"number":18,"title":"Titan0.5.3","description":"","creator":{"login":"mbroecheler","id":758061,"avatar_url":"https://avatars.githubusercontent.com/u/758061?v=3","gravatar_id":"","url":"https://api.github.com/users/mbroecheler","html_url":"https://github.com/mbroecheler","followers_url":"https://api.github.com/users/mbroecheler/followers","following_url":"https://api.github.com/users/mbroecheler/following{/other_user}","gists_url":"https://api.github.com/users/mbroecheler/gists{/gist_id}","starred_url":"https://api.github.com/users/mbroecheler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbroecheler/subscriptions","organizations_url":"https://api.github.com/users/mbroecheler/orgs","repos_url":"https://api.github.com/users/mbroecheler/repos","events_url":"https://api.github.com/users/mbroecheler/events{/privacy}","received_events_url":"https://api.github.com/users/mbroecheler/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":20,"state":"open","created_at":"2014-11-12T23:27:25Z","updated_at":"2015-01-08T20:57:45Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2014-11-29T18:00:26Z","updated_at":"2015-01-09T23:12:35Z","closed_at":"2015-01-08T20:57:45Z","body":"If you use timestamps created by Titan (see http://s3.thinkaurelius.com/docs/titan/0.5.2/titan-config-ref.html#_storage_meta) in a query, e.g.\r\n\r\n```groovy\r\nyesterday = System.currentTimeMillis() - 1000 * 60 * 60 * 24\r\ntimestamp = new StandardTimestamp(yesterday, TimeUnit.MILLISECONDS)\r\nv.bothE().has('$timestamp', Compare.LESS_THAN, timestamp).remove()\r\n```\r\n\r\n...then all you get is an exception:\r\n\r\n```\r\ncom.thinkaurelius.titan.core.SchemaViolationException: Value [Timestamp[1417100515434 ms]] is not an instance of the expected data type for property key [$timestamp] and cannot be converted. Expected: interface com.thinkaurelius.titan.core.attribute.Timestamp, found: class com.thinkaurelius.titan.diskstorage.util.time.StandardTimestamp\r\n at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.verifyAttribute(StandardTitanTx.java:547)\r\n at com.thinkaurelius.titan.graphdb.query.QueryUtil.addConstraint(QueryUtil.java:182)\r\n at com.thinkaurelius.titan.graphdb.query.QueryUtil.constraints2QNF(QueryUtil.java:172)\r\n at com.thinkaurelius.titan.graphdb.query.vertex.BasicVertexCentricQueryBuilder.constructQuery(BasicVertexCentricQueryBuilder.java:385)\r\n at com.thinkaurelius.titan.graphdb.query.vertex.VertexCentricQueryBuilder.execute(VertexCentricQueryBuilder.java:62)\r\n at com.thinkaurelius.titan.graphdb.query.vertex.VertexCentricQueryBuilder.titanEdges(VertexCentricQueryBuilder.java:79)\r\n at com.thinkaurelius.titan.graphdb.query.vertex.VertexCentricQueryBuilder.edges(VertexCentricQueryBuilder.java:98)\r\n at com.tinkerpop.pipes.transform.VertexQueryPipe.processNextStart(VertexQueryPipe.java:113)\r\n at com.tinkerpop.pipes.transform.VertexQueryPipe.processNextStart(VertexQueryPipe.java:19)\r\n at com.tinkerpop.pipes.AbstractPipe.next(AbstractPipe.java:89)\r\n at com.tinkerpop.pipes.IdentityPipe.processNextStart(IdentityPipe.java:19)\r\n at com.tinkerpop.pipes.AbstractPipe.next(AbstractPipe.java:89)\r\n at com.tinkerpop.pipes.IdentityPipe.processNextStart(IdentityPipe.java:19)\r\n at com.tinkerpop.pipes.AbstractPipe.hasNext(AbstractPipe.java:98)\r\n at com.tinkerpop.pipes.util.Pipeline.hasNext(Pipeline.java:105)\r\n at com.tinkerpop.gremlin.java.GremlinPipeline.remove(GremlinPipeline.java:1607)\r\n<snip>\r\n```\r\n\r\nI'm not sure whether the property name is indeed ```$timestamp```, the client who reported the bug used a String constant in the original query, I just took the property name from the stacktrace."},"comment":{"url":"https://api.github.com/repos/thinkaurelius/titan/issues/comments/69416729","html_url":"https://github.com/thinkaurelius/titan/issues/853#issuecomment-69416729","issue_url":"https://api.github.com/repos/thinkaurelius/titan/issues/853","id":69416729,"user":{"login":"dkuppitz","id":572377,"avatar_url":"https://avatars.githubusercontent.com/u/572377?v=3","gravatar_id":"","url":"https://api.github.com/users/dkuppitz","html_url":"https://github.com/dkuppitz","followers_url":"https://api.github.com/users/dkuppitz/followers","following_url":"https://api.github.com/users/dkuppitz/following{/other_user}","gists_url":"https://api.github.com/users/dkuppitz/gists{/gist_id}","starred_url":"https://api.github.com/users/dkuppitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkuppitz/subscriptions","organizations_url":"https://api.github.com/users/dkuppitz/orgs","repos_url":"https://api.github.com/users/dkuppitz/repos","events_url":"https://api.github.com/users/dkuppitz/events{/privacy}","received_events_url":"https://api.github.com/users/dkuppitz/received_events","type":"User","site_admin":false},"created_at":"2015-01-09T23:12:35Z","updated_at":"2015-01-09T23:12:35Z","body":":+1:\r\n\r\n**Before:**\r\n```\r\ngremlin> Titan.version()\r\n==>0.5.2\r\ngremlin> import com.thinkaurelius.titan.diskstorage.util.time.StandardTimestamp\r\ngremlin> import java.util.concurrent.TimeUnit\r\n...\r\ngremlin> g = TitanFactory.open(\"conf/titan-cassandra-es.properties\")\r\n==>titangraph[cassandrathrift:[127.0.0.1]]\r\ngremlin> v1 = g.addVertex(null)\r\n==>v[256]\r\ngremlin> v2 = g.addVertex(null)\r\n==>v[512]\r\ngremlin> v1.addEdge(\"knows\", v2)\r\n==>e[dc-74-1lh-e8][256-knows->512]\r\ngremlin> g.commit()\r\n==>null\r\ngremlin> yesterday = System.currentTimeMillis() - 1000 * 60 * 60 * 24\r\n==>1420757188022\r\ngremlin> g.V().bothE().has('$timestamp', Compare.GREATER_THAN_EQUAL, new StandardTimestamp(yesterday, TimeUnit.MILLISECONDS))\r\nValue [Timestamp[1420757188022 ms]] is not an instance of the expected data type for property key [$timestamp] and cannot be converted. Expected: interface com.thinkaurelius.titan.core.attribute.Timestamp, found: class com.thinkaurelius.titan.diskstorage.util.time.StandardTimestamp\r\nDisplay stack trace? [yN] N\r\n```\r\n\r\n**After:**\r\n```\r\ngremlin> Titan.version()\r\n==>0.5.3-SNAPSHOT\r\ngremlin> import java.util.concurrent.TimeUnit\r\ngremlin> import com.thinkaurelius.titan.core.attribute.Timestamp\r\n...\r\ngremlin> g = TitanFactory.open(\"conf/titan-cassandra-es.properties\")\r\n==>titangraph[cassandrathrift:[127.0.0.1]]\r\ngremlin> v1 = g.addVertex(null)\r\n==>v[256]\r\ngremlin> v2 = g.addVertex(null)\r\n==>v[512]\r\ngremlin> v1.addEdge(\"knows\", v2)\r\n==>e[dc-74-1lh-e8][256-knows->512]\r\ngremlin> g.commit()\r\n==>null\r\ngremlin> yesterday = System.currentTimeMillis() - 1000 * 60 * 60 * 24\r\n==>1420758191198\r\ngremlin> g.V().bothE().has('$timestamp', Compare.GREATER_THAN_EQUAL, new Timestamp(yesterday, TimeUnit.MILLISECONDS))\r\n==>e[dc-74-1lh-e8][256-knows->512]\r\n==>e[dc-74-1lh-e8][256-knows->512]\r\n```"}}