Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
[[release-4-0-0]]
=== TinkerPop 4.0.0 (Release Date: NOT OFFICIALLY RELEASED YET)

* Added GraphBinary `Tree` (`0x2b`) serialization and deserialization with a native tree-shaped API to `gremlin-python`, `gremlin-dotnet`, `gremlin-go`, and `gremlin-javascript`.
* Standardized `gremlin-dotnet` connection options per the TinkerPop 4.x GLV proposal:
** Renamed the `Auth.BasicAuth`/`Auth.SigV4Auth` factory methods to `Auth.Basic`/`Auth.Sigv4` (breaking; the old methods have been removed). *(breaking)*
** Renamed `MaxConnectionsPerServer` to `MaxConnections`, `IdleConnectionTimeout` to `IdleTimeout`, and `KeepAliveInterval` to `KeepAliveTime` (now wired to a real TCP keep-alive socket option rather than the inert HTTP/2 ping timeout, enabling `SO_KEEPALIVE` and setting the per-socket idle time on Windows, Linux, and macOS, with a no-op fallback to the OS default idle time on other platforms); the old property names have been removed. *(breaking)*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public class DataType : IEquatable<DataType>
public static readonly DataType Binary = new DataType(0x25);
public static readonly DataType Short = new DataType(0x26);
public static readonly DataType Boolean = new DataType(0x27);
// Not yet implemented
// public static readonly DataType Tree = new DataType(0x2B);
public static readonly DataType Tree = new DataType(0x2B);
public static readonly DataType Merge = new DataType(0x2E);
public static readonly DataType CompositePDT = new DataType(0xF0);
// Not yet implemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class TypeSerializerRegistry
{typeof(Edge), new EdgeSerializer()},
{typeof(Graph), new GraphSerializer()},
{typeof(Path), new PathSerializer()},
{typeof(Tree), new TreeSerializer()},
{typeof(Property), new PropertySerializer()},
{typeof(Vertex), new VertexSerializer()},
{typeof(VertexProperty), new VertexPropertySerializer()},
Expand Down Expand Up @@ -84,6 +85,7 @@ public class TypeSerializerRegistry
{DataType.Edge, new EdgeSerializer()},
{DataType.Graph, new GraphSerializer()},
{DataType.Path, new PathSerializer()},
{DataType.Tree, new TreeSerializer()},
{DataType.Property, new PropertySerializer()},
{DataType.Vertex, new VertexSerializer()},
{DataType.VertexProperty, new VertexPropertySerializer()},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#region License

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#endregion

using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace Gremlin.Net.Structure.IO.GraphBinary4.Types
{
/// <summary>
/// A <see cref="Tree"/> serializer.
/// </summary>
public class TreeSerializer : SimpleTypeSerializer<Tree>
{
/// <summary>
/// Initializes a new instance of the <see cref="TreeSerializer" /> class.
/// </summary>
public TreeSerializer() : base(DataType.Tree)
{
}

/// <inheritdoc />
protected override async Task WriteValueAsync(Tree value, Stream stream, GraphBinaryWriter writer,
CancellationToken cancellationToken = default)
{
var rootNodes = value.RootNodes();
await writer.WriteNonNullableValueAsync(rootNodes.Count, stream, cancellationToken).ConfigureAwait(false);

foreach (var key in rootNodes)
{
// key is written fully-qualified (may be null); child is written as a bare value (no
// type code or value flag, never null).
await writer.WriteAsync(key, stream, cancellationToken).ConfigureAwait(false);
await writer.WriteNonNullableValueAsync(value.ChildAt(key), stream, cancellationToken)
.ConfigureAwait(false);
}
}

/// <inheritdoc />
protected override async Task<Tree> ReadValueAsync(Stream stream, GraphBinaryReader reader,
CancellationToken cancellationToken = default)
{
var length = await stream.ReadIntAsync(cancellationToken).ConfigureAwait(false);
var result = new Tree();
for (var i = 0; i < length; i++)
{
var key = await reader.ReadAsync(stream, cancellationToken).ConfigureAwait(false);
var child = (Tree) await reader.ReadNonNullableValueAsync<Tree>(stream, cancellationToken)
.ConfigureAwait(false);
result.GetOrCreateChild(key).AddTree(child);
}
return result;
}
}
}
Loading
Loading