janusgraph-dotnet
janusgraph-dotnet copied to clipboard
Unable to specify value for JANUSGRAPH_RELATION_DELIMITER when creating JanusGraphGraphSONMessageSerializer
JanusGraph server allows users to specify an environment variable (JANUSGRAPH_RELATION_DELIMITER) to override the default relation delimiter char. If this is used then the JanusGraphGraphSONMessageSerializer throws an exception when (de)serializing a response that contains relationships.
System.ArgumentException: Not a valid relation identifier: odxce:Sfoo-entity-1:mxh:Sfoo-entity-2
at JanusGraph.Net.RelationIdentifier..ctor(String stringRepresentation)
at JanusGraph.Net.IO.GraphSON.RelationIdentifierDeserializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.MapSerializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.ListSerializer.Objectify(JsonElement graphsonObject, GraphSONReader reader)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadValueOfType(JsonElement typedValue, String graphSONType)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
at Gremlin.Net.Structure.IO.GraphSON.GraphSONMessageSerializer.DeserializeMessageAsync(Byte[] message, CancellationToken cancellationToken) │
at JanusGraph.Net.IO.GraphSON.JanusGraphGraphSONMessageSerializer.DeserializeMessageAsync(Byte[] message, CancellationToken cancellationToken) │
at Gremlin.Net.Driver.Connection.HandleReceivedAsync(Byte[] received)
at Gremlin.Net.Driver.Connection.ReceiveMessagesAsync()
at Gremlin.Net.Driver.ProxyConnection.SubmitAsync[T](RequestMessage requestMessage, CancellationToken cancellationToken)
at Gremlin.Net.Driver.GremlinClient.SubmitAsync[T](RequestMessage requestMessage, CancellationToken cancellationToken)
This can be seen to be caused by the RelationIdentifier class code:
private const char ToStringDelimiter = '-';
/// <summary>
/// Initializes a new instance of the <see cref="RelationIdentifier" /> class.
/// </summary>
/// <param name="stringRepresentation">The underlying relation id.</param>
public RelationIdentifier(string stringRepresentation)
{
StringRepresentation = stringRepresentation;
var elements = stringRepresentation.Split(ToStringDelimiter);
if (elements.Length != 3 && elements.Length != 4)
throw new ArgumentException($"Not a valid relation identifier: {stringRepresentation}");
if (elements[1][0] == LongEncoding.StringEncodingMarker)
{
OutVertexId = elements[1].Substring(1);
}
else
{
OutVertexId = LongEncoding.Decode(elements[1]);
}
TypeId = LongEncoding.Decode(elements[2]);
RelationId = LongEncoding.Decode(elements[0]);
if (elements.Length == 4)
{
if (elements[3][0] == LongEncoding.StringEncodingMarker)
{
InVertexId = elements[3].Substring(1);
}
else
{
InVertexId = LongEncoding.Decode(elements[3]);
}
}
}
where the relation delimiter is hard coded to "-"
Right, looks like this isn't supported by JanusGraph.Net. Do you want to submit a PR for this?