Thirumal
Thirumal

Reputation: 9646

How to use java `OffsetDateTime` in apache tinkerpop gremlin?

The application can be accessed from a different timezone, so I am trying to store date time using class java.time.OffsetDateTime.

startTime: "1996-12-19T16:39:57-08:00",
endTime: "1996-12-19T16:39:57-08:00"

The application/API receives the time in the above format using OffsetDateTime and I am trying to save the same in AWS Neptune using Apache gremlin but I am getting the following error,

org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"detailedMessage":"Unsupported property value type: java.time.OffsetDateTime","code":"UnsupportedOperationException","requestId":"81e402b0-90ab-4c6d-8839-23542da3437b"}
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:245) ~[gremlin-driver-3.6.1.jar:3.6.1]
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinResponseHandler.channelRead0(Handler.java:200) ~[gremlin-driver-3.6.1.jar:3.6.1]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:126) ~[gremlin-driver-3.6.1.jar:3.6.1]
    at org.apache.tinkerpop.gremlin.driver.Handler$GremlinSaslAuthenticationHandler.channelRead0(Handler.java:68) ~[gremlin-driver-3.6.1.jar:3.6.1]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:99) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.79.Final.jar:4.1.79.Final]

OffsetDateTime is not supported in Gremlin/Neptune? then how to store, and retrieve in an efficient way from the database?

Upvotes: 1

Views: 87

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14391

Amazon Neptune is designed to work with any programming language. As such you cannot store arbitrary Java types/objects into Neptune. You can use the native Date types and they will be converted by the Gremlin GLVs into the appropriate serialization. To store dates you really have two main options.

  1. Store a Date type or use the datetime helper for text queries.
  2. Use Epoch offset integers.

Using real Dates should be slightly more performant (on Neptune).

If you need to store additional TZ information, you will most likely want to store that as an additional property on a node or edge.

More information on Neptune's support for dates when using Gremlin, can be found here.

Upvotes: 1

Related Questions