You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2021/07/08 23:27:33 UTC
[tinkerpop] branch TINKERPOP-2563-language updated: Miscellaneous
improvements to the graphs-over-thrift demo
This is an automated email from the ASF dual-hosted git repository.
joshsh pushed a commit to branch TINKERPOP-2563-language
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/TINKERPOP-2563-language by this push:
new 0a51d6e Miscellaneous improvements to the graphs-over-thrift demo
0a51d6e is described below
commit 0a51d6e4b3296e118fbe1c8b633ca31d46debd2c
Author: Joshua Shinavier <jo...@uber.com>
AuthorDate: Thu Jul 8 16:24:08 2021 -0700
Miscellaneous improvements to the graphs-over-thrift demo
---
.../examples/graphs-over-thrift/build.gradle | 9 --
.../examples/thrift/AddGraphException.java | 2 +-
.../language/examples/thrift/AddGraphResponse.java | 2 +-
.../language/examples/thrift/ExampleService.java | 2 +-
.../language/property_graphs/AtomicValue.java | 2 +-
.../gremlin/language/property_graphs/Edge.java | 2 +-
.../gremlin/language/property_graphs/Graph.java | 2 +-
.../gremlin/language/property_graphs/Property.java | 2 +-
.../language/property_graphs/SerializedValue.java | 120 ++++++++++-----------
.../gremlin/language/property_graphs/Value.java | 2 +-
.../gremlin/language/property_graphs/Vertex.java | 2 +-
.../gremlin/language/property_graphs.thrift | 12 +--
.../language/examples/thrift/AddGraphHandler.java | 40 +------
.../examples/thrift/ExampleGraphClient.java | 13 ++-
.../language/examples/thrift/GraphEncoding.java | 36 +++++++
.../language/examples/thrift/ValueEncoding.java | 2 +-
.../examples/thrift/ValueEncodingRegistry.java | 10 +-
.../examples/thrift/mydomain/EncodingUtils.java | 2 +-
.../gremlin/language/property_graphs.yaml | 10 +-
19 files changed, 137 insertions(+), 135 deletions(-)
diff --git a/gremlin-language/examples/graphs-over-thrift/build.gradle b/gremlin-language/examples/graphs-over-thrift/build.gradle
index f3d93c3..22cc116 100644
--- a/gremlin-language/examples/graphs-over-thrift/build.gradle
+++ b/gremlin-language/examples/graphs-over-thrift/build.gradle
@@ -1,6 +1,5 @@
plugins {
id 'java'
-// id 'application'
}
apply plugin : 'java'
@@ -13,14 +12,6 @@ sourceSets {
}
}
-//ext {
-// javaMainClass = "org.apache.tinkerpop.gremlin.language.examples.thrift.ExampleGraphServer"
-//}
-//
-//application {
-// mainClassName = javaMainClass
-//}
-
dependencies {
implementation 'org.apache.thrift:libthrift:0.14.0'
implementation 'org.apache.tinkerpop:tinkergraph-gremlin:3.5.0'
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphException.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphException.java
index 6d04d7c..f5aa4b9 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphException.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphException.java
@@ -7,7 +7,7 @@
package org.apache.tinkerpop.gremlin.language.examples.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class AddGraphException extends org.apache.thrift.TException implements org.apache.thrift.TBase<AddGraphException, AddGraphException._Fields>, java.io.Serializable, Cloneable, Comparable<AddGraphException> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AddGraphException");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphResponse.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphResponse.java
index 97f2a20..ee9ed30 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphResponse.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphResponse.java
@@ -7,7 +7,7 @@
package org.apache.tinkerpop.gremlin.language.examples.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class AddGraphResponse implements org.apache.thrift.TBase<AddGraphResponse, AddGraphResponse._Fields>, java.io.Serializable, Cloneable, Comparable<AddGraphResponse> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AddGraphResponse");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleService.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleService.java
index 2fb7299..e367c8d 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleService.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleService.java
@@ -7,7 +7,7 @@
package org.apache.tinkerpop.gremlin.language.examples.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class ExampleService {
public interface Iface {
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/AtomicValue.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/AtomicValue.java
index a98ae17..12d729f 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/AtomicValue.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/AtomicValue.java
@@ -10,7 +10,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
/**
* A simple value like a boolean, number, or string
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class AtomicValue extends org.apache.thrift.TUnion<AtomicValue, AtomicValue._Fields> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AtomicValue");
private static final org.apache.thrift.protocol.TField BOOLEAN_ESC_FIELD_DESC = new org.apache.thrift.protocol.TField("booleanEsc", org.apache.thrift.protocol.TType.BOOL, (short)1);
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Edge.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Edge.java
index 9b9dd64..4f49dc9 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Edge.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Edge.java
@@ -10,7 +10,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
/**
* A edge, or binary relationship connecting two vertices
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class Edge implements org.apache.thrift.TBase<Edge, Edge._Fields>, java.io.Serializable, Cloneable, Comparable<Edge> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Edge");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Graph.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Graph.java
index 02b825b..3a6a7b4 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Graph.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Graph.java
@@ -12,7 +12,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
*
* @comments As a basic integrity constraint, the out- and in- vertex ids of the graph's edges must be among the ids of the graph's vertices.
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class Graph implements org.apache.thrift.TBase<Graph, Graph._Fields>, java.io.Serializable, Cloneable, Comparable<Graph> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Graph");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Property.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Property.java
index c09d690..77d8155 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Property.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Property.java
@@ -10,7 +10,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
/**
* A property, or key/value pair which may be attached to vertices, edges, and occasionally other properties.
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class Property implements org.apache.thrift.TBase<Property, Property._Fields>, java.io.Serializable, Cloneable, Comparable<Property> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Property");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/SerializedValue.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/SerializedValue.java
index cb5f7c6..4379941 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/SerializedValue.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/SerializedValue.java
@@ -11,11 +11,11 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
* A value of a provided type which has been serialized in accordance with an encoding which is understood on the basis
* of the type.
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class SerializedValue implements org.apache.thrift.TBase<SerializedValue, SerializedValue._Fields>, java.io.Serializable, Cloneable, Comparable<SerializedValue> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SerializedValue");
- private static final org.apache.thrift.protocol.TField TYPE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("typeName", org.apache.thrift.protocol.TType.STRING, (short)1);
+ private static final org.apache.thrift.protocol.TField ENCODING_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("encodingName", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField ENCODED_FIELD_DESC = new org.apache.thrift.protocol.TField("encoded", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new SerializedValueStandardSchemeFactory();
@@ -24,9 +24,9 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
/**
* The unique name of the type of the serialized value
*
- * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.EncodingName
*/
- public @org.apache.thrift.annotation.Nullable java.lang.String typeName; // required
+ public @org.apache.thrift.annotation.Nullable java.lang.String encodingName; // required
/**
* The encoded (serialized) value as a string
*
@@ -39,9 +39,9 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
/**
* The unique name of the type of the serialized value
*
- * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.EncodingName
*/
- TYPE_NAME((short)1, "typeName"),
+ ENCODING_NAME((short)1, "encodingName"),
/**
* The encoded (serialized) value as a string
*
@@ -63,8 +63,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
@org.apache.thrift.annotation.Nullable
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
- case 1: // TYPE_NAME
- return TYPE_NAME;
+ case 1: // ENCODING_NAME
+ return ENCODING_NAME;
case 2: // ENCODED
return ENCODED;
default:
@@ -111,8 +111,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
- tmpMap.put(_Fields.TYPE_NAME, new org.apache.thrift.meta_data.FieldMetaData("typeName", org.apache.thrift.TFieldRequirementType.REQUIRED,
- new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "TypeName")));
+ tmpMap.put(_Fields.ENCODING_NAME, new org.apache.thrift.meta_data.FieldMetaData("encodingName", org.apache.thrift.TFieldRequirementType.REQUIRED,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "EncodingName")));
tmpMap.put(_Fields.ENCODED, new org.apache.thrift.meta_data.FieldMetaData("encoded", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
@@ -123,11 +123,11 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
}
public SerializedValue(
- java.lang.String typeName,
+ java.lang.String encodingName,
java.lang.String encoded)
{
this();
- this.typeName = typeName;
+ this.encodingName = encodingName;
this.encoded = encoded;
}
@@ -135,8 +135,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
* Performs a deep copy on <i>other</i>.
*/
public SerializedValue(SerializedValue other) {
- if (other.isSetTypeName()) {
- this.typeName = other.typeName;
+ if (other.isSetEncodingName()) {
+ this.encodingName = other.encodingName;
}
if (other.isSetEncoded()) {
this.encoded = other.encoded;
@@ -149,42 +149,42 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
@Override
public void clear() {
- this.typeName = null;
+ this.encodingName = null;
this.encoded = null;
}
/**
* The unique name of the type of the serialized value
*
- * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.EncodingName
*/
@org.apache.thrift.annotation.Nullable
- public java.lang.String getTypeName() {
- return this.typeName;
+ public java.lang.String getEncodingName() {
+ return this.encodingName;
}
/**
* The unique name of the type of the serialized value
*
- * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.EncodingName
*/
- public SerializedValue setTypeName(@org.apache.thrift.annotation.Nullable java.lang.String typeName) {
- this.typeName = typeName;
+ public SerializedValue setEncodingName(@org.apache.thrift.annotation.Nullable java.lang.String encodingName) {
+ this.encodingName = encodingName;
return this;
}
- public void unsetTypeName() {
- this.typeName = null;
+ public void unsetEncodingName() {
+ this.encodingName = null;
}
- /** Returns true if field typeName is set (has been assigned a value) and false otherwise */
- public boolean isSetTypeName() {
- return this.typeName != null;
+ /** Returns true if field encodingName is set (has been assigned a value) and false otherwise */
+ public boolean isSetEncodingName() {
+ return this.encodingName != null;
}
- public void setTypeNameIsSet(boolean value) {
+ public void setEncodingNameIsSet(boolean value) {
if (!value) {
- this.typeName = null;
+ this.encodingName = null;
}
}
@@ -225,11 +225,11 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
- case TYPE_NAME:
+ case ENCODING_NAME:
if (value == null) {
- unsetTypeName();
+ unsetEncodingName();
} else {
- setTypeName((java.lang.String)value);
+ setEncodingName((java.lang.String)value);
}
break;
@@ -247,8 +247,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
- case TYPE_NAME:
- return getTypeName();
+ case ENCODING_NAME:
+ return getEncodingName();
case ENCODED:
return getEncoded();
@@ -264,8 +264,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
}
switch (field) {
- case TYPE_NAME:
- return isSetTypeName();
+ case ENCODING_NAME:
+ return isSetEncodingName();
case ENCODED:
return isSetEncoded();
}
@@ -285,12 +285,12 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
if (this == that)
return true;
- boolean this_present_typeName = true && this.isSetTypeName();
- boolean that_present_typeName = true && that.isSetTypeName();
- if (this_present_typeName || that_present_typeName) {
- if (!(this_present_typeName && that_present_typeName))
+ boolean this_present_encodingName = true && this.isSetEncodingName();
+ boolean that_present_encodingName = true && that.isSetEncodingName();
+ if (this_present_encodingName || that_present_encodingName) {
+ if (!(this_present_encodingName && that_present_encodingName))
return false;
- if (!this.typeName.equals(that.typeName))
+ if (!this.encodingName.equals(that.encodingName))
return false;
}
@@ -310,9 +310,9 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
public int hashCode() {
int hashCode = 1;
- hashCode = hashCode * 8191 + ((isSetTypeName()) ? 131071 : 524287);
- if (isSetTypeName())
- hashCode = hashCode * 8191 + typeName.hashCode();
+ hashCode = hashCode * 8191 + ((isSetEncodingName()) ? 131071 : 524287);
+ if (isSetEncodingName())
+ hashCode = hashCode * 8191 + encodingName.hashCode();
hashCode = hashCode * 8191 + ((isSetEncoded()) ? 131071 : 524287);
if (isSetEncoded())
@@ -329,12 +329,12 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
int lastComparison = 0;
- lastComparison = java.lang.Boolean.compare(isSetTypeName(), other.isSetTypeName());
+ lastComparison = java.lang.Boolean.compare(isSetEncodingName(), other.isSetEncodingName());
if (lastComparison != 0) {
return lastComparison;
}
- if (isSetTypeName()) {
- lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.typeName, other.typeName);
+ if (isSetEncodingName()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encodingName, other.encodingName);
if (lastComparison != 0) {
return lastComparison;
}
@@ -370,11 +370,11 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
java.lang.StringBuilder sb = new java.lang.StringBuilder("SerializedValue(");
boolean first = true;
- sb.append("typeName:");
- if (this.typeName == null) {
+ sb.append("encodingName:");
+ if (this.encodingName == null) {
sb.append("null");
} else {
- sb.append(this.typeName);
+ sb.append(this.encodingName);
}
first = false;
if (!first) sb.append(", ");
@@ -391,8 +391,8 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
public void validate() throws org.apache.thrift.TException {
// check for required fields
- if (typeName == null) {
- throw new org.apache.thrift.protocol.TProtocolException("Required field 'typeName' was not present! Struct: " + toString());
+ if (encodingName == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field 'encodingName' was not present! Struct: " + toString());
}
if (encoded == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'encoded' was not present! Struct: " + toString());
@@ -434,10 +434,10 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
break;
}
switch (schemeField.id) {
- case 1: // TYPE_NAME
+ case 1: // ENCODING_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
- struct.typeName = iprot.readString();
- struct.setTypeNameIsSet(true);
+ struct.encodingName = iprot.readString();
+ struct.setEncodingNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@@ -465,9 +465,9 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
- if (struct.typeName != null) {
- oprot.writeFieldBegin(TYPE_NAME_FIELD_DESC);
- oprot.writeString(struct.typeName);
+ if (struct.encodingName != null) {
+ oprot.writeFieldBegin(ENCODING_NAME_FIELD_DESC);
+ oprot.writeString(struct.encodingName);
oprot.writeFieldEnd();
}
if (struct.encoded != null) {
@@ -492,15 +492,15 @@ public class SerializedValue implements org.apache.thrift.TBase<SerializedValue,
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, SerializedValue struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
- oprot.writeString(struct.typeName);
+ oprot.writeString(struct.encodingName);
oprot.writeString(struct.encoded);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, SerializedValue struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
- struct.typeName = iprot.readString();
- struct.setTypeNameIsSet(true);
+ struct.encodingName = iprot.readString();
+ struct.setEncodingNameIsSet(true);
struct.encoded = iprot.readString();
struct.setEncodedIsSet(true);
}
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Value.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Value.java
index 990da6a..9e46fa4 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Value.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Value.java
@@ -10,7 +10,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
/**
* An id or property value; either an atomic (simple) value, or a list, map, or set value
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class Value extends org.apache.thrift.TUnion<Value, Value._Fields> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Value");
private static final org.apache.thrift.protocol.TField ATOMIC_FIELD_DESC = new org.apache.thrift.protocol.TField("atomic", org.apache.thrift.protocol.TType.STRUCT, (short)1);
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Vertex.java b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Vertex.java
index 6cce6a7..4777ce3 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Vertex.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/Vertex.java
@@ -10,7 +10,7 @@ package org.apache.tinkerpop.gremlin.language.property_graphs;
/**
* A vertex, or simple element in a graph; vertices are typically connected by edges
*/
-@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-07")
+@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.14.1)", date = "2021-07-08")
public class Vertex implements org.apache.thrift.TBase<Vertex, Vertex._Fields>, java.io.Serializable, Cloneable, Comparable<Vertex> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Vertex");
diff --git a/gremlin-language/examples/graphs-over-thrift/src/gen/thrift/org/apache/tinkerpop/gremlin/language/property_graphs.thrift b/gremlin-language/examples/graphs-over-thrift/src/gen/thrift/org/apache/tinkerpop/gremlin/language/property_graphs.thrift
index d0eeaec..97a5831 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/gen/thrift/org/apache/tinkerpop/gremlin/language/property_graphs.thrift
+++ b/gremlin-language/examples/graphs-over-thrift/src/gen/thrift/org/apache/tinkerpop/gremlin/language/property_graphs.thrift
@@ -16,18 +16,18 @@ namespace java org.apache.tinkerpop.gremlin.language.property_graphs
typedef string EdgeLabel
/**
- * The key of a property. Property keys are part of a graph's schema, like vertex and edge labels.
+ * The unique name of an encoding used for serialization and deserialization of domain-specific values of a known type
*
* @type string
*/
-typedef string PropertyKey
+typedef string EncodingName
/**
- * The unique name of a type used for serialization and deserialization of domain-specific values
+ * The key of a property. Property keys are part of a graph's schema, like vertex and edge labels.
*
* @type string
*/
-typedef string TypeName
+typedef string PropertyKey
/**
* The label of a vertex, sometimes indicating its type
@@ -129,9 +129,9 @@ struct SerializedValue {
/**
* The unique name of the type of the serialized value
*
- * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.EncodingName
*/
- 1: required TypeName typeName;
+ 1: required EncodingName encodingName;
/**
* The encoded (serialized) value as a string
*
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphHandler.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphHandler.java
index 4b8764d..ea7fe7f 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphHandler.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/AddGraphHandler.java
@@ -5,16 +5,11 @@ import org.apache.commons.configuration2.Configuration;
import org.apache.thrift.TException;
import org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain.MyApplication;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Property;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
public class AddGraphHandler implements ExampleService.Iface {
private final GraphEncoding encoding = new GraphEncoding(MyApplication.SUPPORTED_ENCODINGS);
@@ -35,8 +30,7 @@ public class AddGraphHandler implements ExampleService.Iface {
Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.graphLocation", "/tmp/graphs-over-thrift.json");
conf.setProperty("gremlin.tinkergraph.graphFormat", "graphson");
- //conf.setProperty("gremlin.tinkergraph.graphLocation", "/tmp/graphs-over-thrift.xml");
- //conf.setProperty("gremlin.tinkergraph.graphFormat", "graphml");
+
Graph graph;
try {
@@ -45,37 +39,7 @@ public class AddGraphHandler implements ExampleService.Iface {
throw new AddGraphException("could not open graph: " + e.getMessage());
}
- // Add vertices
- Map<Object, Vertex> vertices = new HashMap<>();
- for (org.apache.tinkerpop.gremlin.language.property_graphs.Vertex v0 : g0.vertices) {
- Object id = encoding.toNativeAtomicValue(v0.id);
- Vertex v = graph.addVertex(T.id, id);
- for (org.apache.tinkerpop.gremlin.language.property_graphs.Property p0 : v0.properties) {
- v.property(p0.key, encoding.toNativeValue(p0.value));
- }
-
- vertices.put(id, v);
- }
-
- // Add edges
- for (org.apache.tinkerpop.gremlin.language.property_graphs.Edge e0 : g0.edges) {
- Object id = encoding.toNativeAtomicValue(e0.id);
- Object outId = encoding.toNativeAtomicValue(e0.outVertexId);
- Object inId = encoding.toNativeAtomicValue(e0.inVertexId);
-
- Vertex out = vertices.get(outId);
- Vertex in = vertices.get(inId);
- if (out == null || in == null) {
- throw new AddGraphException("edge references vertices which are not in the graph");
- }
-
- Edge e = out.addEdge(e0.label, in, T.id, id);
-
- for (org.apache.tinkerpop.gremlin.language.property_graphs.Property p0 : e0.properties) {
- e.property(p0.key, encoding.toNativeValue(p0.value));
- //System.out.println("Thrift value: " + p0.value + ", native value: " + GraphThriftUtils.toNativeValue(p0.value));
- }
- }
+ encoding.toNativeGraph(graph, g0);
GraphTraversalSource g = graph.traversal();
long vertexCount = g.V().count().next();
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleGraphClient.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleGraphClient.java
index 22faf18..e66523d 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleGraphClient.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ExampleGraphClient.java
@@ -14,6 +14,15 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import java.io.IOException;
+/*
+Inspect the resulting graph in Gremlin Console with:
+
+ graph = TinkerGraph.open();
+ reader = GraphSONReader.build().create()
+ stream = new FileInputStream("/tmp/graphs-over-thrift.json")
+ reader.readGraph(stream, graph);
+ g = graph.traversal()
+ */
public class ExampleGraphClient {
private static final GraphEncoding encoding = new GraphEncoding(MyApplication.SUPPORTED_ENCODINGS);
@@ -41,8 +50,8 @@ public class ExampleGraphClient {
g.V(4L).next().property("awesomeness", 1.0);
g.V(4L).next().property("livesIn",
new BoundingBox(
- new GeoPoint(37.5632261f,-122.1990871f, null),
- new GeoPoint(37.5632261f,-122.1990871f, null)));
+ new GeoPoint(37.8578475f,-122.5817373f, null),
+ new GeoPoint(37.1720048f,-121.6200625f, null)));
AddGraphResponse response;
try {
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
index 02a4776..564142d 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
@@ -5,6 +5,7 @@ import org.apache.tinkerpop.gremlin.language.property_graphs.Value;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -161,6 +162,41 @@ public class GraphEncoding {
}
}
+ public void toNativeGraph(Graph graph, org.apache.tinkerpop.gremlin.language.property_graphs.Graph g0)
+ throws IOException {
+ // Add vertices
+ Map<Object, Vertex> vertices = new HashMap<>();
+ for (org.apache.tinkerpop.gremlin.language.property_graphs.Vertex v0 : g0.vertices) {
+ Object id = toNativeAtomicValue(v0.id);
+ Vertex v = graph.addVertex(T.id, id);
+ for (org.apache.tinkerpop.gremlin.language.property_graphs.Property p0 : v0.properties) {
+ v.property(p0.key, toNativeValue(p0.value));
+ }
+
+ vertices.put(id, v);
+ }
+
+ // Add edges
+ for (org.apache.tinkerpop.gremlin.language.property_graphs.Edge e0 : g0.edges) {
+ Object id = toNativeAtomicValue(e0.id);
+ Object outId = toNativeAtomicValue(e0.outVertexId);
+ Object inId = toNativeAtomicValue(e0.inVertexId);
+
+ Vertex out = vertices.get(outId);
+ Vertex in = vertices.get(inId);
+ if (out == null || in == null) {
+ throw new IllegalArgumentException("edge references vertices which are not in the graph");
+ }
+
+ Edge e = out.addEdge(e0.label, in, T.id, id);
+
+ for (org.apache.tinkerpop.gremlin.language.property_graphs.Property p0 : e0.properties) {
+ e.property(p0.key, toNativeValue(p0.value));
+ //System.out.println("Thrift value: " + p0.value + ", native value: " + GraphThriftUtils.toNativeValue(p0.value));
+ }
+ }
+ }
+
public Object toNativeValue(Value v) throws IOException {
if (v.isSetAtomic()) {
return toNativeAtomicValue(v.getAtomic());
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncoding.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncoding.java
index 1b388f8..afb8d54 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncoding.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncoding.java
@@ -3,7 +3,7 @@ package org.apache.tinkerpop.gremlin.language.examples.thrift;
import java.io.IOException;
public interface ValueEncoding {
- String getTypeName();
+ String getEncodingName();
Class getJavaClass();
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncodingRegistry.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncodingRegistry.java
index 3900dd9..8ed9feb 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncodingRegistry.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncodingRegistry.java
@@ -9,20 +9,20 @@ import java.util.Optional;
public class ValueEncodingRegistry {
private final Map<Class, ValueEncoding> encodingByClass;
- private final Map<String, ValueEncoding> encodingByTypeName;
+ private final Map<String, ValueEncoding> encodingByName;
public ValueEncodingRegistry(ValueEncoding... encodings) {
encodingByClass = new HashMap<>();
- encodingByTypeName = new HashMap<>();
+ encodingByName = new HashMap<>();
for (ValueEncoding encoding : encodings) {
encodingByClass.put(encoding.getJavaClass(), encoding);
- encodingByTypeName.put(encoding.getTypeName(), encoding);
+ encodingByName.put(encoding.getEncodingName(), encoding);
}
}
public Object decode(SerializedValue encoded) throws IOException {
- ValueEncoding encoding = encodingByTypeName.get(encoded.getTypeName());
+ ValueEncoding encoding = encodingByName.get(encoded.getEncodingName());
if (null == encoding) {
// If there is no encoding, simply embed the serialized value as an object.
return encoded;
@@ -44,7 +44,7 @@ public class ValueEncodingRegistry {
return Optional.empty();
} else {
String encoded = encoding.encode(decoded);
- return Optional.of(new SerializedValue(encoding.getTypeName(), encoded));
+ return Optional.of(new SerializedValue(encoding.getEncodingName(), encoded));
}
}
}
diff --git a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/EncodingUtils.java b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/EncodingUtils.java
index 7688442..b61e7b6 100644
--- a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/EncodingUtils.java
+++ b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/EncodingUtils.java
@@ -11,7 +11,7 @@ public final class EncodingUtils {
public static ValueEncoding createEncoding(String typeName, Class javaClass) {
return new ValueEncoding() {
@Override
- public String getTypeName() {
+ public String getEncodingName() {
return typeName;
}
diff --git a/gremlin-language/src/main/yaml/org/apache/tinkerpop/gremlin/language/property_graphs.yaml b/gremlin-language/src/main/yaml/org/apache/tinkerpop/gremlin/language/property_graphs.yaml
index 18b59b2..ed0b2e1 100644
--- a/gremlin-language/src/main/yaml/org/apache/tinkerpop/gremlin/language/property_graphs.yaml
+++ b/gremlin-language/src/main/yaml/org/apache/tinkerpop/gremlin/language/property_graphs.yaml
@@ -130,16 +130,18 @@ definitions:
with an encoding which is understood on the basis of the type.
type:
record:
- - name: typeName
+ - name: encodingName
description: "The unique name of the type of the serialized value"
- type: TypeName
+ type: EncodingName
- name: encoded
description: "The encoded (serialized) value as a string"
type: string
- - name: TypeName
- description: "The unique name of a type used for serialization and deserialization of domain-specific values"
+ - name: EncodingName
+ description: >
+ The unique name of an encoding used for serialization and deserialization of domain-specific values
+ of a known type
type: string
- name: Value