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 176177a Extend the graphs-over-thrift example to demonstrate sending
domain-specific objects over the wire
176177a is described below
commit 176177a4774a464e313dd93ed0385324c546637e
Author: Joshua Shinavier <[email protected]>
AuthorDate: Wed Jul 7 15:12:21 2021 -0700
Extend the graphs-over-thrift example to demonstrate sending
domain-specific objects over the wire
---
.../examples/graphs-over-thrift/README.md | 2 +-
.../examples/thrift/AddGraphException.java | 2 +-
.../language/examples/thrift/AddGraphResponse.java | 116 ++++-
.../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 | 513 +++++++++++++++++++++
.../gremlin/language/property_graphs/Value.java | 42 +-
.../gremlin/language/property_graphs/Vertex.java | 2 +-
.../gremlin/language/property_graphs.thrift | 30 +-
.../language/examples/thrift/AddGraphHandler.java | 30 +-
.../examples/thrift/ExampleGraphClient.java | 20 +-
.../{GraphThriftUtils.java => GraphEncoding.java} | 30 +-
.../language/examples/thrift/ValueEncoding.java | 13 +
.../examples/thrift/ValueEncodingRegistry.java | 51 ++
.../examples/thrift/mydomain/BoundingBox.java | 35 ++
.../examples/thrift/mydomain/EncodingUtils.java | 34 ++
.../examples/thrift/mydomain/GeoPoint.java | 45 ++
.../examples/thrift/mydomain/MyApplication.java | 9 +
.../src/main/thrift/graphs_over_thrift.thrift | 1 +
.../gremlin/language/property_graphs.yaml | 20 +-
23 files changed, 951 insertions(+), 54 deletions(-)
diff --git a/gremlin-language/examples/graphs-over-thrift/README.md
b/gremlin-language/examples/graphs-over-thrift/README.md
index 456bb34..3b5dbb5 100644
--- a/gremlin-language/examples/graphs-over-thrift/README.md
+++ b/gremlin-language/examples/graphs-over-thrift/README.md
@@ -25,7 +25,7 @@ This is a reconstituted version of the graph which is
constructed by the client
## Generating sources
Some of the sources in this directory are hand-written, while others are
generated.
-Follow the steps below in order to re-created all of the generated sources.
+Follow the steps below in order to re-create all of the generated sources.
Note: the first step requires Dragon, which is a proprietary tool.
### Generate property_graphs.thrift:
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 d599ff6..6d04d7c 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"})
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 9e0b507..97f2a20 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,23 +7,26 @@
package org.apache.tinkerpop.gremlin.language.examples.thrift;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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");
private static final org.apache.thrift.protocol.TField
TOTAL_VERTICES_AFTER_OPERATION_FIELD_DESC = new
org.apache.thrift.protocol.TField("totalVerticesAfterOperation",
org.apache.thrift.protocol.TType.I64, (short)1);
private static final org.apache.thrift.protocol.TField
TOTAL_EDGES_AFTER_OPERATION_FIELD_DESC = new
org.apache.thrift.protocol.TField("totalEdgesAfterOperation",
org.apache.thrift.protocol.TType.I64, (short)2);
+ private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC =
new org.apache.thrift.protocol.TField("message",
org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.scheme.SchemeFactory
STANDARD_SCHEME_FACTORY = new AddGraphResponseStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory
TUPLE_SCHEME_FACTORY = new AddGraphResponseTupleSchemeFactory();
public long totalVerticesAfterOperation; // required
public long totalEdgesAfterOperation; // required
+ public @org.apache.thrift.annotation.Nullable java.lang.String message; //
optional
/** The set of fields this struct contains, along with convenience methods
for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
TOTAL_VERTICES_AFTER_OPERATION((short)1, "totalVerticesAfterOperation"),
- TOTAL_EDGES_AFTER_OPERATION((short)2, "totalEdgesAfterOperation");
+ TOTAL_EDGES_AFTER_OPERATION((short)2, "totalEdgesAfterOperation"),
+ MESSAGE((short)3, "message");
private static final java.util.Map<java.lang.String, _Fields> byName = new
java.util.HashMap<java.lang.String, _Fields>();
@@ -43,6 +46,8 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
return TOTAL_VERTICES_AFTER_OPERATION;
case 2: // TOTAL_EDGES_AFTER_OPERATION
return TOTAL_EDGES_AFTER_OPERATION;
+ case 3: // MESSAGE
+ return MESSAGE;
default:
return null;
}
@@ -87,6 +92,7 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
private static final int __TOTALVERTICESAFTEROPERATION_ISSET_ID = 0;
private static final int __TOTALEDGESAFTEROPERATION_ISSET_ID = 1;
private byte __isset_bitfield = 0;
+ private static final _Fields optionals[] = {_Fields.MESSAGE};
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);
@@ -94,6 +100,8 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
new
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.TOTAL_EDGES_AFTER_OPERATION, new
org.apache.thrift.meta_data.FieldMetaData("totalEdgesAfterOperation",
org.apache.thrift.TFieldRequirementType.DEFAULT,
new
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
+ tmpMap.put(_Fields.MESSAGE, new
org.apache.thrift.meta_data.FieldMetaData("message",
org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AddGraphResponse.class,
metaDataMap);
}
@@ -119,6 +127,9 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
__isset_bitfield = other.__isset_bitfield;
this.totalVerticesAfterOperation = other.totalVerticesAfterOperation;
this.totalEdgesAfterOperation = other.totalEdgesAfterOperation;
+ if (other.isSetMessage()) {
+ this.message = other.message;
+ }
}
public AddGraphResponse deepCopy() {
@@ -131,6 +142,7 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
this.totalVerticesAfterOperation = 0;
setTotalEdgesAfterOperationIsSet(false);
this.totalEdgesAfterOperation = 0;
+ this.message = null;
}
public long getTotalVerticesAfterOperation() {
@@ -179,6 +191,31 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
__isset_bitfield =
org.apache.thrift.EncodingUtils.setBit(__isset_bitfield,
__TOTALEDGESAFTEROPERATION_ISSET_ID, value);
}
+ @org.apache.thrift.annotation.Nullable
+ public java.lang.String getMessage() {
+ return this.message;
+ }
+
+ public AddGraphResponse setMessage(@org.apache.thrift.annotation.Nullable
java.lang.String message) {
+ this.message = message;
+ return this;
+ }
+
+ public void unsetMessage() {
+ this.message = null;
+ }
+
+ /** Returns true if field message is set (has been assigned a value) and
false otherwise */
+ public boolean isSetMessage() {
+ return this.message != null;
+ }
+
+ public void setMessageIsSet(boolean value) {
+ if (!value) {
+ this.message = null;
+ }
+ }
+
public void setFieldValue(_Fields field,
@org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case TOTAL_VERTICES_AFTER_OPERATION:
@@ -197,6 +234,14 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
}
break;
+ case MESSAGE:
+ if (value == null) {
+ unsetMessage();
+ } else {
+ setMessage((java.lang.String)value);
+ }
+ break;
+
}
}
@@ -209,6 +254,9 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
case TOTAL_EDGES_AFTER_OPERATION:
return getTotalEdgesAfterOperation();
+ case MESSAGE:
+ return getMessage();
+
}
throw new java.lang.IllegalStateException();
}
@@ -224,6 +272,8 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
return isSetTotalVerticesAfterOperation();
case TOTAL_EDGES_AFTER_OPERATION:
return isSetTotalEdgesAfterOperation();
+ case MESSAGE:
+ return isSetMessage();
}
throw new java.lang.IllegalStateException();
}
@@ -259,6 +309,15 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
return false;
}
+ boolean this_present_message = true && this.isSetMessage();
+ boolean that_present_message = true && that.isSetMessage();
+ if (this_present_message || that_present_message) {
+ if (!(this_present_message && that_present_message))
+ return false;
+ if (!this.message.equals(that.message))
+ return false;
+ }
+
return true;
}
@@ -270,6 +329,10 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
hashCode = hashCode * 8191 +
org.apache.thrift.TBaseHelper.hashCode(totalEdgesAfterOperation);
+ hashCode = hashCode * 8191 + ((isSetMessage()) ? 131071 : 524287);
+ if (isSetMessage())
+ hashCode = hashCode * 8191 + message.hashCode();
+
return hashCode;
}
@@ -301,6 +364,16 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
return lastComparison;
}
}
+ lastComparison = java.lang.Boolean.compare(isSetMessage(),
other.isSetMessage());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetMessage()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.message,
other.message);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
return 0;
}
@@ -329,6 +402,16 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
sb.append("totalEdgesAfterOperation:");
sb.append(this.totalEdgesAfterOperation);
first = false;
+ if (isSetMessage()) {
+ if (!first) sb.append(", ");
+ sb.append("message:");
+ if (this.message == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.message);
+ }
+ first = false;
+ }
sb.append(")");
return sb.toString();
}
@@ -390,6 +473,14 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
}
break;
+ case 3: // MESSAGE
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
+ }
+ break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
}
@@ -411,6 +502,13 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
oprot.writeFieldBegin(TOTAL_EDGES_AFTER_OPERATION_FIELD_DESC);
oprot.writeI64(struct.totalEdgesAfterOperation);
oprot.writeFieldEnd();
+ if (struct.message != null) {
+ if (struct.isSetMessage()) {
+ oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
+ oprot.writeString(struct.message);
+ oprot.writeFieldEnd();
+ }
+ }
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@@ -435,19 +533,25 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
if (struct.isSetTotalEdgesAfterOperation()) {
optionals.set(1);
}
- oprot.writeBitSet(optionals, 2);
+ if (struct.isSetMessage()) {
+ optionals.set(2);
+ }
+ oprot.writeBitSet(optionals, 3);
if (struct.isSetTotalVerticesAfterOperation()) {
oprot.writeI64(struct.totalVerticesAfterOperation);
}
if (struct.isSetTotalEdgesAfterOperation()) {
oprot.writeI64(struct.totalEdgesAfterOperation);
}
+ if (struct.isSetMessage()) {
+ oprot.writeString(struct.message);
+ }
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot,
AddGraphResponse struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot =
(org.apache.thrift.protocol.TTupleProtocol) prot;
- java.util.BitSet incoming = iprot.readBitSet(2);
+ java.util.BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.totalVerticesAfterOperation = iprot.readI64();
struct.setTotalVerticesAfterOperationIsSet(true);
@@ -456,6 +560,10 @@ public class AddGraphResponse implements
org.apache.thrift.TBase<AddGraphRespons
struct.totalEdgesAfterOperation = iprot.readI64();
struct.setTotalEdgesAfterOperationIsSet(true);
}
+ if (incoming.get(2)) {
+ struct.message = iprot.readString();
+ struct.setMessageIsSet(true);
+ }
}
}
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 da9d745..2fb7299 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"})
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 d8ce6be..a98ae17 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
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 0a42290..9b9dd64 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
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 c6fda05..02b825b 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.
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 f02d9a0..c09d690 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.
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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
new file mode 100644
index 0000000..cb5f7c6
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/gen/java/org/apache/tinkerpop/gremlin/language/property_graphs/SerializedValue.java
@@ -0,0 +1,513 @@
+/**
+ * Autogenerated by Thrift Compiler (0.14.1)
+ *
+ * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+ * @generated
+ */
+package org.apache.tinkerpop.gremlin.language.property_graphs;
+
+@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
+/**
+ * A value of a provided type which has been serialized in accordance with an
encoding which is understood on the basis
+ * of the type.
+ */
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
+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 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();
+ private static final org.apache.thrift.scheme.SchemeFactory
TUPLE_SCHEME_FACTORY = new SerializedValueTupleSchemeFactory();
+
+ /**
+ * The unique name of the type of the serialized value
+ *
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ */
+ public @org.apache.thrift.annotation.Nullable java.lang.String typeName; //
required
+ /**
+ * The encoded (serialized) value as a string
+ *
+ * @type string
+ */
+ public @org.apache.thrift.annotation.Nullable java.lang.String encoded; //
required
+
+ /** The set of fields this struct contains, along with convenience methods
for finding and manipulating them. */
+ public enum _Fields implements org.apache.thrift.TFieldIdEnum {
+ /**
+ * The unique name of the type of the serialized value
+ *
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ */
+ TYPE_NAME((short)1, "typeName"),
+ /**
+ * The encoded (serialized) value as a string
+ *
+ * @type string
+ */
+ ENCODED((short)2, "encoded");
+
+ private static final java.util.Map<java.lang.String, _Fields> byName = new
java.util.HashMap<java.lang.String, _Fields>();
+
+ static {
+ for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
+ byName.put(field.getFieldName(), field);
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, or null if its not
found.
+ */
+ @org.apache.thrift.annotation.Nullable
+ public static _Fields findByThriftId(int fieldId) {
+ switch(fieldId) {
+ case 1: // TYPE_NAME
+ return TYPE_NAME;
+ case 2: // ENCODED
+ return ENCODED;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Find the _Fields constant that matches fieldId, throwing an exception
+ * if it is not found.
+ */
+ public static _Fields findByThriftIdOrThrow(int fieldId) {
+ _Fields fields = findByThriftId(fieldId);
+ if (fields == null) throw new java.lang.IllegalArgumentException("Field
" + fieldId + " doesn't exist!");
+ return fields;
+ }
+
+ /**
+ * Find the _Fields constant that matches name, or null if its not found.
+ */
+ @org.apache.thrift.annotation.Nullable
+ public static _Fields findByName(java.lang.String name) {
+ return byName.get(name);
+ }
+
+ private final short _thriftId;
+ private final java.lang.String _fieldName;
+
+ _Fields(short thriftId, java.lang.String fieldName) {
+ _thriftId = thriftId;
+ _fieldName = fieldName;
+ }
+
+ public short getThriftFieldId() {
+ return _thriftId;
+ }
+
+ public java.lang.String getFieldName() {
+ return _fieldName;
+ }
+ }
+
+ // isset id assignments
+ 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.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);
+
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SerializedValue.class,
metaDataMap);
+ }
+
+ public SerializedValue() {
+ }
+
+ public SerializedValue(
+ java.lang.String typeName,
+ java.lang.String encoded)
+ {
+ this();
+ this.typeName = typeName;
+ this.encoded = encoded;
+ }
+
+ /**
+ * Performs a deep copy on <i>other</i>.
+ */
+ public SerializedValue(SerializedValue other) {
+ if (other.isSetTypeName()) {
+ this.typeName = other.typeName;
+ }
+ if (other.isSetEncoded()) {
+ this.encoded = other.encoded;
+ }
+ }
+
+ public SerializedValue deepCopy() {
+ return new SerializedValue(this);
+ }
+
+ @Override
+ public void clear() {
+ this.typeName = null;
+ this.encoded = null;
+ }
+
+ /**
+ * The unique name of the type of the serialized value
+ *
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ */
+ @org.apache.thrift.annotation.Nullable
+ public java.lang.String getTypeName() {
+ return this.typeName;
+ }
+
+ /**
+ * The unique name of the type of the serialized value
+ *
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ */
+ public SerializedValue setTypeName(@org.apache.thrift.annotation.Nullable
java.lang.String typeName) {
+ this.typeName = typeName;
+ return this;
+ }
+
+ public void unsetTypeName() {
+ this.typeName = null;
+ }
+
+ /** Returns true if field typeName is set (has been assigned a value) and
false otherwise */
+ public boolean isSetTypeName() {
+ return this.typeName != null;
+ }
+
+ public void setTypeNameIsSet(boolean value) {
+ if (!value) {
+ this.typeName = null;
+ }
+ }
+
+ /**
+ * The encoded (serialized) value as a string
+ *
+ * @type string
+ */
+ @org.apache.thrift.annotation.Nullable
+ public java.lang.String getEncoded() {
+ return this.encoded;
+ }
+
+ /**
+ * The encoded (serialized) value as a string
+ *
+ * @type string
+ */
+ public SerializedValue setEncoded(@org.apache.thrift.annotation.Nullable
java.lang.String encoded) {
+ this.encoded = encoded;
+ return this;
+ }
+
+ public void unsetEncoded() {
+ this.encoded = null;
+ }
+
+ /** Returns true if field encoded is set (has been assigned a value) and
false otherwise */
+ public boolean isSetEncoded() {
+ return this.encoded != null;
+ }
+
+ public void setEncodedIsSet(boolean value) {
+ if (!value) {
+ this.encoded = null;
+ }
+ }
+
+ public void setFieldValue(_Fields field,
@org.apache.thrift.annotation.Nullable java.lang.Object value) {
+ switch (field) {
+ case TYPE_NAME:
+ if (value == null) {
+ unsetTypeName();
+ } else {
+ setTypeName((java.lang.String)value);
+ }
+ break;
+
+ case ENCODED:
+ if (value == null) {
+ unsetEncoded();
+ } else {
+ setEncoded((java.lang.String)value);
+ }
+ break;
+
+ }
+ }
+
+ @org.apache.thrift.annotation.Nullable
+ public java.lang.Object getFieldValue(_Fields field) {
+ switch (field) {
+ case TYPE_NAME:
+ return getTypeName();
+
+ case ENCODED:
+ return getEncoded();
+
+ }
+ throw new java.lang.IllegalStateException();
+ }
+
+ /** Returns true if field corresponding to fieldID is set (has been assigned
a value) and false otherwise */
+ public boolean isSet(_Fields field) {
+ if (field == null) {
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ switch (field) {
+ case TYPE_NAME:
+ return isSetTypeName();
+ case ENCODED:
+ return isSetEncoded();
+ }
+ throw new java.lang.IllegalStateException();
+ }
+
+ @Override
+ public boolean equals(java.lang.Object that) {
+ if (that instanceof SerializedValue)
+ return this.equals((SerializedValue)that);
+ return false;
+ }
+
+ public boolean equals(SerializedValue that) {
+ if (that == null)
+ return false;
+ 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))
+ return false;
+ if (!this.typeName.equals(that.typeName))
+ return false;
+ }
+
+ boolean this_present_encoded = true && this.isSetEncoded();
+ boolean that_present_encoded = true && that.isSetEncoded();
+ if (this_present_encoded || that_present_encoded) {
+ if (!(this_present_encoded && that_present_encoded))
+ return false;
+ if (!this.encoded.equals(that.encoded))
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hashCode = 1;
+
+ hashCode = hashCode * 8191 + ((isSetTypeName()) ? 131071 : 524287);
+ if (isSetTypeName())
+ hashCode = hashCode * 8191 + typeName.hashCode();
+
+ hashCode = hashCode * 8191 + ((isSetEncoded()) ? 131071 : 524287);
+ if (isSetEncoded())
+ hashCode = hashCode * 8191 + encoded.hashCode();
+
+ return hashCode;
+ }
+
+ @Override
+ public int compareTo(SerializedValue other) {
+ if (!getClass().equals(other.getClass())) {
+ return getClass().getName().compareTo(other.getClass().getName());
+ }
+
+ int lastComparison = 0;
+
+ lastComparison = java.lang.Boolean.compare(isSetTypeName(),
other.isSetTypeName());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetTypeName()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.typeName,
other.typeName);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ lastComparison = java.lang.Boolean.compare(isSetEncoded(),
other.isSetEncoded());
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ if (isSetEncoded()) {
+ lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encoded,
other.encoded);
+ if (lastComparison != 0) {
+ return lastComparison;
+ }
+ }
+ return 0;
+ }
+
+ @org.apache.thrift.annotation.Nullable
+ public _Fields fieldForId(int fieldId) {
+ return _Fields.findByThriftId(fieldId);
+ }
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot) throws
org.apache.thrift.TException {
+ scheme(iprot).read(iprot, this);
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot) throws
org.apache.thrift.TException {
+ scheme(oprot).write(oprot, this);
+ }
+
+ @Override
+ public java.lang.String toString() {
+ java.lang.StringBuilder sb = new
java.lang.StringBuilder("SerializedValue(");
+ boolean first = true;
+
+ sb.append("typeName:");
+ if (this.typeName == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.typeName);
+ }
+ first = false;
+ if (!first) sb.append(", ");
+ sb.append("encoded:");
+ if (this.encoded == null) {
+ sb.append("null");
+ } else {
+ sb.append(this.encoded);
+ }
+ first = false;
+ sb.append(")");
+ return sb.toString();
+ }
+
+ 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 (encoded == null) {
+ throw new org.apache.thrift.protocol.TProtocolException("Required field
'encoded' was not present! Struct: " + toString());
+ }
+ // check for sub-struct validity
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws
java.io.IOException {
+ try {
+ write(new org.apache.thrift.protocol.TCompactProtocol(new
org.apache.thrift.transport.TIOStreamTransport(out)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private void readObject(java.io.ObjectInputStream in) throws
java.io.IOException, java.lang.ClassNotFoundException {
+ try {
+ read(new org.apache.thrift.protocol.TCompactProtocol(new
org.apache.thrift.transport.TIOStreamTransport(in)));
+ } catch (org.apache.thrift.TException te) {
+ throw new java.io.IOException(te);
+ }
+ }
+
+ private static class SerializedValueStandardSchemeFactory implements
org.apache.thrift.scheme.SchemeFactory {
+ public SerializedValueStandardScheme getScheme() {
+ return new SerializedValueStandardScheme();
+ }
+ }
+
+ private static class SerializedValueStandardScheme extends
org.apache.thrift.scheme.StandardScheme<SerializedValue> {
+
+ public void read(org.apache.thrift.protocol.TProtocol iprot,
SerializedValue struct) throws org.apache.thrift.TException {
+ org.apache.thrift.protocol.TField schemeField;
+ iprot.readStructBegin();
+ while (true)
+ {
+ schemeField = iprot.readFieldBegin();
+ if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
+ break;
+ }
+ switch (schemeField.id) {
+ case 1: // TYPE_NAME
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.typeName = iprot.readString();
+ struct.setTypeNameIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
+ }
+ break;
+ case 2: // ENCODED
+ if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
+ struct.encoded = iprot.readString();
+ struct.setEncodedIsSet(true);
+ } else {
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
+ }
+ break;
+ default:
+ org.apache.thrift.protocol.TProtocolUtil.skip(iprot,
schemeField.type);
+ }
+ iprot.readFieldEnd();
+ }
+ iprot.readStructEnd();
+
+ // check for required fields of primitive type, which can't be checked
in the validate method
+ struct.validate();
+ }
+
+ public void write(org.apache.thrift.protocol.TProtocol oprot,
SerializedValue struct) throws org.apache.thrift.TException {
+ struct.validate();
+
+ oprot.writeStructBegin(STRUCT_DESC);
+ if (struct.typeName != null) {
+ oprot.writeFieldBegin(TYPE_NAME_FIELD_DESC);
+ oprot.writeString(struct.typeName);
+ oprot.writeFieldEnd();
+ }
+ if (struct.encoded != null) {
+ oprot.writeFieldBegin(ENCODED_FIELD_DESC);
+ oprot.writeString(struct.encoded);
+ oprot.writeFieldEnd();
+ }
+ oprot.writeFieldStop();
+ oprot.writeStructEnd();
+ }
+
+ }
+
+ private static class SerializedValueTupleSchemeFactory implements
org.apache.thrift.scheme.SchemeFactory {
+ public SerializedValueTupleScheme getScheme() {
+ return new SerializedValueTupleScheme();
+ }
+ }
+
+ private static class SerializedValueTupleScheme extends
org.apache.thrift.scheme.TupleScheme<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.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.encoded = iprot.readString();
+ struct.setEncodedIsSet(true);
+ }
+ }
+
+ private static <S extends org.apache.thrift.scheme.IScheme> S
scheme(org.apache.thrift.protocol.TProtocol proto) {
+ return
(org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ?
STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
+ }
+}
+
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 5634fb3..990da6a 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
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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);
@@ -18,7 +18,7 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
private static final org.apache.thrift.protocol.TField ARRAY_FIELD_DESC =
new org.apache.thrift.protocol.TField("array",
org.apache.thrift.protocol.TType.LIST, (short)3);
private static final org.apache.thrift.protocol.TField MAP_ESC_FIELD_DESC =
new org.apache.thrift.protocol.TField("mapEsc",
org.apache.thrift.protocol.TType.MAP, (short)4);
private static final org.apache.thrift.protocol.TField SET_ESC_FIELD_DESC =
new org.apache.thrift.protocol.TField("setEsc",
org.apache.thrift.protocol.TType.SET, (short)5);
- private static final org.apache.thrift.protocol.TField SERIALIZED_FIELD_DESC
= new org.apache.thrift.protocol.TField("serialized",
org.apache.thrift.protocol.TType.STRING, (short)6);
+ private static final org.apache.thrift.protocol.TField SERIALIZED_FIELD_DESC
= new org.apache.thrift.protocol.TField("serialized",
org.apache.thrift.protocol.TType.STRUCT, (short)6);
/** The set of fields this struct contains, along with convenience methods
for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
@@ -57,7 +57,7 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
/**
* A serialized object which the application should be capable of decoding
*
- * @type string
+ * @type
org/apache/tinkerpop/gremlin/language/property_graphs.SerializedValue
*/
SERIALIZED((short)6, "serialized");
@@ -146,7 +146,7 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
new
org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET,
new
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT
, "Value"))));
tmpMap.put(_Fields.SERIALIZED, new
org.apache.thrift.meta_data.FieldMetaData("serialized",
org.apache.thrift.TFieldRequirementType.OPTIONAL,
- new
org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
+ new
org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
SerializedValue.class)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Value.class,
metaDataMap);
}
@@ -196,7 +196,7 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
return x;
}
- public static Value serialized(java.lang.String value) {
+ public static Value serialized(SerializedValue value) {
Value x = new Value();
x.setSerialized(value);
return x;
@@ -232,10 +232,10 @@ public class Value extends
org.apache.thrift.TUnion<Value, Value._Fields> {
}
throw new java.lang.ClassCastException("Was expecting value of type
java.util.Set<Value> for field 'setEsc', but got " +
value.getClass().getSimpleName());
case SERIALIZED:
- if (value instanceof java.lang.String) {
+ if (value instanceof SerializedValue) {
break;
}
- throw new java.lang.ClassCastException("Was expecting value of type
java.lang.String for field 'serialized', but got " +
value.getClass().getSimpleName());
+ throw new java.lang.ClassCastException("Was expecting value of type
SerializedValue for field 'serialized', but got " +
value.getClass().getSimpleName());
default:
throw new java.lang.IllegalArgumentException("Unknown field id " +
setField);
}
@@ -340,8 +340,9 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
}
case SERIALIZED:
if (field.type == SERIALIZED_FIELD_DESC.type) {
- java.lang.String serialized;
- serialized = iprot.readString();
+ SerializedValue serialized;
+ serialized = new SerializedValue();
+ serialized.read(iprot);
return serialized;
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
@@ -409,8 +410,8 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
}
return;
case SERIALIZED:
- java.lang.String serialized = (java.lang.String)value_;
- oprot.writeString(serialized);
+ SerializedValue serialized = (SerializedValue)value_;
+ serialized.write(oprot);
return;
default:
throw new java.lang.IllegalStateException("Cannot write union with
unknown field " + setField_);
@@ -490,8 +491,9 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
}
return setEsc;
case SERIALIZED:
- java.lang.String serialized;
- serialized = iprot.readString();
+ SerializedValue serialized;
+ serialized = new SerializedValue();
+ serialized.read(iprot);
return serialized;
default:
throw new java.lang.IllegalStateException("setField wasn't null, but
didn't match any of the case statements!");
@@ -554,8 +556,8 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
}
return;
case SERIALIZED:
- java.lang.String serialized = (java.lang.String)value_;
- oprot.writeString(serialized);
+ SerializedValue serialized = (SerializedValue)value_;
+ serialized.write(oprot);
return;
default:
throw new java.lang.IllegalStateException("Cannot write union with
unknown field " + setField_);
@@ -720,11 +722,11 @@ public class Value extends
org.apache.thrift.TUnion<Value, Value._Fields> {
/**
* A serialized object which the application should be capable of decoding
*
- * @type string
+ * @type
org/apache/tinkerpop/gremlin/language/property_graphs.SerializedValue
*/
- public java.lang.String getSerialized() {
+ public SerializedValue getSerialized() {
if (getSetField() == _Fields.SERIALIZED) {
- return (java.lang.String)getFieldValue();
+ return (SerializedValue)getFieldValue();
} else {
throw new java.lang.RuntimeException("Cannot get field 'serialized'
because union is currently set to " + getFieldDesc(getSetField()).name);
}
@@ -733,9 +735,9 @@ public class Value extends org.apache.thrift.TUnion<Value,
Value._Fields> {
/**
* A serialized object which the application should be capable of decoding
*
- * @type string
+ * @type
org/apache/tinkerpop/gremlin/language/property_graphs.SerializedValue
*/
- public void setSerialized(java.lang.String value) {
+ public void setSerialized(SerializedValue value) {
setField_ = _Fields.SERIALIZED;
value_ = java.util.Objects.requireNonNull(value,"_Fields.SERIALIZED");
}
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 3a6f8fc..6cce6a7 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
*/
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-06")
[email protected](value = "Autogenerated by Thrift Compiler
(0.14.1)", date = "2021-07-07")
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 820db6c..d0eeaec 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
@@ -23,6 +23,13 @@ typedef string EdgeLabel
typedef string PropertyKey
/**
+ * The unique name of a type used for serialization and deserialization of
domain-specific values
+ *
+ * @type string
+ */
+typedef string TypeName
+
+/**
* The label of a vertex, sometimes indicating its type
*
* @type string
@@ -115,6 +122,25 @@ struct Property {
}
/**
+ * A value of a provided type which has been serialized in accordance with an
encoding which is understood on the basis
+ * of the type.
+ */
+struct SerializedValue {
+ /**
+ * The unique name of the type of the serialized value
+ *
+ * @type org/apache/tinkerpop/gremlin/language/property_graphs.TypeName
+ */
+ 1: required TypeName typeName;
+ /**
+ * The encoded (serialized) value as a string
+ *
+ * @type string
+ */
+ 2: required string encoded;
+}
+
+/**
* An id or property value; either an atomic (simple) value, or a list, map,
or set value
*/
union Value {
@@ -153,9 +179,9 @@ union Value {
/**
* A serialized object which the application should be capable of decoding
*
- * @type string
+ * @type
org/apache/tinkerpop/gremlin/language/property_graphs.SerializedValue
*/
- 6: optional string serialized;
+ 6: optional SerializedValue serialized;
}
/**
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 15383bf..4b8764d 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
@@ -3,21 +3,35 @@ package org.apache.tinkerpop.gremlin.language.examples.thrift;
import org.apache.commons.configuration2.BaseConfiguration;
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);
@Override
public AddGraphResponse
addGraph(org.apache.tinkerpop.gremlin.language.property_graphs.Graph g0)
throws AddGraphException, TException {
+ try {
+ return addGraphInternal(g0);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new AddGraphException("IO exception: " + e.getMessage());
+ }
+ }
+
+ private AddGraphResponse
addGraphInternal(org.apache.tinkerpop.gremlin.language.property_graphs.Graph g0)
+ throws AddGraphException, IOException {
Configuration conf = new BaseConfiguration();
conf.setProperty("gremlin.tinkergraph.graphLocation",
"/tmp/graphs-over-thrift.json");
conf.setProperty("gremlin.tinkergraph.graphFormat", "graphson");
@@ -34,10 +48,10 @@ public class AddGraphHandler implements
ExampleService.Iface {
// Add vertices
Map<Object, Vertex> vertices = new HashMap<>();
for (org.apache.tinkerpop.gremlin.language.property_graphs.Vertex v0 :
g0.vertices) {
- Object id = GraphThriftUtils.toNativeAtomicValue(v0.id);
+ 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, GraphThriftUtils.toNativeValue(p0.value));
+ v.property(p0.key, encoding.toNativeValue(p0.value));
}
vertices.put(id, v);
@@ -45,9 +59,9 @@ public class AddGraphHandler implements ExampleService.Iface {
// Add edges
for (org.apache.tinkerpop.gremlin.language.property_graphs.Edge e0 :
g0.edges) {
- Object id = GraphThriftUtils.toNativeAtomicValue(e0.id);
- Object outId =
GraphThriftUtils.toNativeAtomicValue(e0.outVertexId);
- Object inId = GraphThriftUtils.toNativeAtomicValue(e0.inVertexId);
+ 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);
@@ -58,7 +72,7 @@ public class AddGraphHandler implements ExampleService.Iface {
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, GraphThriftUtils.toNativeValue(p0.value));
+ e.property(p0.key, encoding.toNativeValue(p0.value));
//System.out.println("Thrift value: " + p0.value + ", native
value: " + GraphThriftUtils.toNativeValue(p0.value));
}
}
@@ -67,6 +81,10 @@ public class AddGraphHandler implements ExampleService.Iface
{
long vertexCount = g.V().count().next();
long edgeCount = g.E().count().next();
+ for (Property<Object> p : g.V().properties("livesIn").toList()) {
+ System.out.println("Found a livesIn value: " + p.value());
+ }
+
try {
// This should cause the graph to be saved to the configured
location
graph.close();
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 0fdbf8a..22faf18 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
@@ -5,11 +5,17 @@ import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
+import
org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain.BoundingBox;
+import org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain.GeoPoint;
+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.Graph;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import java.io.IOException;
+
public class ExampleGraphClient {
+ private static final GraphEncoding encoding = new
GraphEncoding(MyApplication.SUPPORTED_ENCODINGS);
public static void main(String[] args) {
try {
@@ -32,9 +38,19 @@ public class ExampleGraphClient {
private static void perform(ExampleService.Client client) throws
TException {
Graph graph = TinkerFactory.createClassic();
GraphTraversalSource g = graph.traversal();
- g.V(4L).next().property("awesomenessLevel", 1.0);
+ 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)));
+
+ AddGraphResponse response;
+ try {
+ response = client.addGraph(encoding.fromNativeGraph(graph));
+ } catch (IOException e) {
+ throw new TException(e);
+ }
- AddGraphResponse response =
client.addGraph(GraphThriftUtils.fromNativeGraph(graph));
System.out.println("resulting graph has " +
response.totalVerticesAfterOperation + " vertices and "
+ response.totalEdgesAfterOperation + " edges.");
}
diff --git
a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphThriftUtils.java
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
similarity index 87%
rename from
gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphThriftUtils.java
rename to
gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
index cc04c3b..02a4776 100644
---
a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphThriftUtils.java
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/GraphEncoding.java
@@ -8,6 +8,7 @@ import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -17,8 +18,14 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-public class GraphThriftUtils {
- public static AtomicValue fromNativeAtomicValue(Object o) {
+public class GraphEncoding {
+ private final ValueEncodingRegistry encodings;
+
+ public GraphEncoding(ValueEncodingRegistry encodings) {
+ this.encodings = encodings;
+ }
+
+ public AtomicValue fromNativeAtomicValue(Object o) {
if (o instanceof Boolean) {
return AtomicValue.booleanEsc((Boolean) o);
} else if (o instanceof Short) {
@@ -35,11 +42,12 @@ public class GraphThriftUtils {
} else if (o instanceof String) {
return AtomicValue.stringEsc((String) o);
} else {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("cannot decode object of class
" + o.getClass());
}
}
- public static org.apache.tinkerpop.gremlin.language.property_graphs.Graph
fromNativeGraph(Graph graph) {
+ public org.apache.tinkerpop.gremlin.language.property_graphs.Graph
fromNativeGraph(Graph graph)
+ throws IOException {
Set<org.apache.tinkerpop.gremlin.language.property_graphs.Vertex>
vertices0 = new HashSet<>();
Iterator<Vertex> vertices = graph.vertices();
while (vertices.hasNext()) {
@@ -90,7 +98,8 @@ public class GraphThriftUtils {
return graph0;
}
- public static
org.apache.tinkerpop.gremlin.language.property_graphs.Property
fromNativeProperty(Property prop) {
+ public org.apache.tinkerpop.gremlin.language.property_graphs.Property
fromNativeProperty(Property<Object> prop)
+ throws IOException {
org.apache.tinkerpop.gremlin.language.property_graphs.Property p0
= new
org.apache.tinkerpop.gremlin.language.property_graphs.Property();
p0.setKey(prop.key());
@@ -102,7 +111,7 @@ public class GraphThriftUtils {
return p0;
}
- public static Value fromNativeValue(Object o) {
+ public Value fromNativeValue(Object o) throws IOException {
if (o.getClass().isArray()) {
List<Value> coll = new ArrayList<>();
for (Object o1 : (Object[]) o) {
@@ -128,11 +137,11 @@ public class GraphThriftUtils {
}
return Value.mapEsc(coll);
} else {
- return Value.atomic(fromNativeAtomicValue(o));
+ return encodings.encode(o).map(Value::serialized).orElseGet(() ->
Value.atomic(fromNativeAtomicValue(o)));
}
}
- public static Object toNativeAtomicValue(AtomicValue v) {
+ public Object toNativeAtomicValue(AtomicValue v) {
if (v.isSetBooleanEsc()) {
return v.getBooleanEsc();
} else if (v.isSetByteEsc()) {
@@ -152,7 +161,7 @@ public class GraphThriftUtils {
}
}
- public static Object toNativeValue(Value v) {
+ public Object toNativeValue(Value v) throws IOException {
if (v.isSetAtomic()) {
return toNativeAtomicValue(v.getAtomic());
} else if (v.isSetListEsc()) {
@@ -181,8 +190,7 @@ public class GraphThriftUtils {
}
return coll;
} else if (v.isSetSerialized()) {
- // Note: an appropriate deserializer should be used here
- return v.getSerialized();
+ return encodings.decode(v.getSerialized());
} else {
throw new IllegalArgumentException();
}
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
new file mode 100644
index 0000000..1b388f8
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncoding.java
@@ -0,0 +1,13 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift;
+
+import java.io.IOException;
+
+public interface ValueEncoding {
+ String getTypeName();
+
+ Class getJavaClass();
+
+ Object decode(String encoded) throws IOException;
+
+ String encode(Object decoded) throws IOException;
+}
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
new file mode 100644
index 0000000..3900dd9
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/ValueEncodingRegistry.java
@@ -0,0 +1,51 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift;
+
+import org.apache.tinkerpop.gremlin.language.property_graphs.SerializedValue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+public class ValueEncodingRegistry {
+ private final Map<Class, ValueEncoding> encodingByClass;
+ private final Map<String, ValueEncoding> encodingByTypeName;
+
+ public ValueEncodingRegistry(ValueEncoding... encodings) {
+ encodingByClass = new HashMap<>();
+ encodingByTypeName = new HashMap<>();
+
+ for (ValueEncoding encoding : encodings) {
+ encodingByClass.put(encoding.getJavaClass(), encoding);
+ encodingByTypeName.put(encoding.getTypeName(), encoding);
+ }
+ }
+
+ public Object decode(SerializedValue encoded) throws IOException {
+ ValueEncoding encoding = encodingByTypeName.get(encoded.getTypeName());
+ if (null == encoding) {
+ // If there is no encoding, simply embed the serialized value as
an object.
+ return encoded;
+ } else {
+ return encoding.decode(encoded.getEncoded());
+ }
+ }
+
+ public Optional<SerializedValue> encode(Object decoded) throws IOException
{
+ if (decoded instanceof SerializedValue) {
+ // One way a SerializedValue can enter the graph is if the value's
type was not understood at decoding time.
+ return Optional.of((SerializedValue) decoded);
+ } else {
+ // Note: subclass relationships are not taken into account.
+ // The object must be a direct instance of the supported class.
+ ValueEncoding encoding = encodingByClass.get(decoded.getClass());
+
+ if (null == encoding) {
+ return Optional.empty();
+ } else {
+ String encoded = encoding.encode(decoded);
+ return Optional.of(new SerializedValue(encoding.getTypeName(),
encoded));
+ }
+ }
+ }
+}
diff --git
a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/BoundingBox.java
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/BoundingBox.java
new file mode 100644
index 0000000..aaae063
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/BoundingBox.java
@@ -0,0 +1,35 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain;
+
+import org.apache.tinkerpop.gremlin.language.examples.thrift.ValueEncoding;
+
+public class BoundingBox {
+ public static final ValueEncoding BOUNDINGBOX_ENCODING =
EncodingUtils.createEncoding(
+
"org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain.BoundingBox",
+ BoundingBox.class);
+
+ private GeoPoint northwest;
+ private GeoPoint southeast;
+
+ public BoundingBox() {}
+
+ public BoundingBox(GeoPoint northwest, GeoPoint southeast) {
+ this.northwest = northwest;
+ this.southeast = southeast;
+ }
+
+ public GeoPoint getNorthwest() {
+ return northwest;
+ }
+
+ public void setNorthwest(GeoPoint northwest) {
+ this.northwest = northwest;
+ }
+
+ public GeoPoint getSoutheast() {
+ return southeast;
+ }
+
+ public void setSoutheast(GeoPoint southeast) {
+ this.southeast = southeast;
+ }
+}
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
new file mode 100644
index 0000000..7688442
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/EncodingUtils.java
@@ -0,0 +1,34 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain;
+
+import org.apache.tinkerpop.gremlin.language.examples.thrift.ValueEncoding;
+import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+
+public final class EncodingUtils {
+ private static final ObjectMapper objectMapper = new ObjectMapper();
+
+ public static ValueEncoding createEncoding(String typeName, Class
javaClass) {
+ return new ValueEncoding() {
+ @Override
+ public String getTypeName() {
+ return typeName;
+ }
+
+ @Override
+ public Class getJavaClass() {
+ return javaClass;
+ }
+
+ @Override
+ public Object decode(String encoded) throws IOException {
+ return objectMapper.readValue(encoded, javaClass);
+ }
+
+ @Override
+ public String encode(Object decoded) throws IOException {
+ return objectMapper.writeValueAsString(decoded);
+ }
+ };
+ }
+}
diff --git
a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/GeoPoint.java
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/GeoPoint.java
new file mode 100644
index 0000000..2ad481e
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/GeoPoint.java
@@ -0,0 +1,45 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain;
+
+import org.apache.tinkerpop.gremlin.language.examples.thrift.ValueEncoding;
+
+public class GeoPoint {
+ public static final ValueEncoding GEOPOINT_ENCODING =
EncodingUtils.createEncoding(
+
"org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain.GeoPoint",
+ GeoPoint.class);
+
+ private float latitudeDegrees;
+ private float longitudeDegrees;
+ private Float altitudeMeters;
+
+ public GeoPoint() {}
+
+ public GeoPoint(float latitudeDegrees, float longitudeDegrees, Float
altitudeMeters) {
+ this.latitudeDegrees = latitudeDegrees;
+ this.longitudeDegrees = longitudeDegrees;
+ this.altitudeMeters = altitudeMeters;
+ }
+
+ public float getLatitudeDegrees() {
+ return latitudeDegrees;
+ }
+
+ public void setLatitudeDegrees(float latitudeDegrees) {
+ this.latitudeDegrees = latitudeDegrees;
+ }
+
+ public float getLongitudeDegrees() {
+ return longitudeDegrees;
+ }
+
+ public void setLongitudeDegrees(float longitudeDegrees) {
+ this.longitudeDegrees = longitudeDegrees;
+ }
+
+ public Float getAltitudeMeters() {
+ return altitudeMeters;
+ }
+
+ public void setAltitudeMeters(Float altitudeMeters) {
+ this.altitudeMeters = altitudeMeters;
+ }
+}
diff --git
a/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/MyApplication.java
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/MyApplication.java
new file mode 100644
index 0000000..0d24130
--- /dev/null
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/java/org/apache/tinkerpop/gremlin/language/examples/thrift/mydomain/MyApplication.java
@@ -0,0 +1,9 @@
+package org.apache.tinkerpop.gremlin.language.examples.thrift.mydomain;
+
+import
org.apache.tinkerpop.gremlin.language.examples.thrift.ValueEncodingRegistry;
+
+public class MyApplication {
+ public static final ValueEncodingRegistry SUPPORTED_ENCODINGS = new
ValueEncodingRegistry(
+ BoundingBox.BOUNDINGBOX_ENCODING,
+ GeoPoint.GEOPOINT_ENCODING);
+}
diff --git
a/gremlin-language/examples/graphs-over-thrift/src/main/thrift/graphs_over_thrift.thrift
b/gremlin-language/examples/graphs-over-thrift/src/main/thrift/graphs_over_thrift.thrift
index e8ed1f5..beec7b8 100644
---
a/gremlin-language/examples/graphs-over-thrift/src/main/thrift/graphs_over_thrift.thrift
+++
b/gremlin-language/examples/graphs-over-thrift/src/main/thrift/graphs_over_thrift.thrift
@@ -9,6 +9,7 @@ exception AddGraphException {
struct AddGraphResponse {
1: i64 totalVerticesAfterOperation;
2: i64 totalEdgesAfterOperation;
+ 3: optional string message;
}
service ExampleService {
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 f481ecb..18b59b2 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
@@ -124,6 +124,24 @@ definitions:
description: "The key of a property. Property keys are part of a graph's
schema, like vertex and edge labels."
type: string
+ - name: SerializedValue
+ description: >
+ A value of a provided type which has been serialized in accordance
+ with an encoding which is understood on the basis of the type.
+ type:
+ record:
+ - name: typeName
+ description: "The unique name of the type of the serialized value"
+ type: TypeName
+
+ - 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"
+ type: string
+
- name: Value
description: "An id or property value; either an atomic (simple) value, or
a list, map, or set value"
type:
@@ -156,7 +174,7 @@ definitions:
- name: serialized
description: "A serialized object which the application should be
capable of decoding"
- type: string
+ type: SerializedValue
- name: Vertex
description: "A vertex, or simple element in a graph; vertices are
typically connected by edges"