From 68be6f07a31598d6464c01e9f9ca42957cdd2bf1 Mon Sep 17 00:00:00 2001 From: David Noble Date: Tue, 17 Sep 2019 23:59:56 -0700 Subject: [PATCH] code cleanup in prep for next step: loading a namespace that includes a schema with a udt: the one that the Spark connector team needs. --- .../hybridrow/schemas/PropertyType.java | 21 ++++++- .../hybridrow/schemas/TypeKind.java | 2 +- .../hybridrow/schemas/UdtPropertyType.java | 55 +++++++++++++------ 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java index b767670..5fcdd91 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/PropertyType.java @@ -25,9 +25,28 @@ import java.util.PrimitiveIterator; @Type(value = TaggedPropertyType.class, name="tagged"), @Type(value = TuplePropertyType.class, name="tuple"), // Primitive types + @Type(value = PrimitivePropertyType.class, name="null"), + @Type(value = PrimitivePropertyType.class, name="bool"), + @Type(value = PrimitivePropertyType.class, name="int8"), + @Type(value = PrimitivePropertyType.class, name="int16"), @Type(value = PrimitivePropertyType.class, name="int32"), + @Type(value = PrimitivePropertyType.class, name="int64"), + @Type(value = PrimitivePropertyType.class, name="varint"), + @Type(value = PrimitivePropertyType.class, name="uint8"), + @Type(value = PrimitivePropertyType.class, name="uint16"), @Type(value = PrimitivePropertyType.class, name="uint32"), - @Type(value = PrimitivePropertyType.class, name="utf8") + @Type(value = PrimitivePropertyType.class, name="uint64"), + @Type(value = PrimitivePropertyType.class, name="varuint"), + @Type(value = PrimitivePropertyType.class, name="float32"), + @Type(value = PrimitivePropertyType.class, name="float64"), + @Type(value = PrimitivePropertyType.class, name="float128"), + @Type(value = PrimitivePropertyType.class, name="decimal"), + @Type(value = PrimitivePropertyType.class, name="datetime"), + @Type(value = PrimitivePropertyType.class, name="unixdatetime"), + @Type(value = PrimitivePropertyType.class, name="binary"), + @Type(value = PrimitivePropertyType.class, name="guid"), + @Type(value = PrimitivePropertyType.class, name="utf8"), + @Type(value = PrimitivePropertyType.class, name="any") }) public abstract class PropertyType { diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java index 75e2b07..6a8de90 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/TypeKind.java @@ -186,7 +186,7 @@ public enum TypeKind { /** * An untyped sparse field. *

- * May only be used to define the type within a nested scope. + * May only be used to define the type of a field within a nested scope. */ ANY(30, "any"); diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java index 1e382c7..b20ba58 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/schemas/UdtPropertyType.java @@ -4,54 +4,73 @@ package com.azure.data.cosmos.serialization.hybridrow.schemas; import com.azure.data.cosmos.serialization.hybridrow.SchemaId; +import com.fasterxml.jackson.annotation.JsonProperty; /** * UDT properties represent nested structures with an independent schema. *

- * UDT properties include a nested row within an existing row as a column. The schema of the - * nested row may be evolved independently of the outer row. Changes to the independent schema affect - * all outer schemas where the UDT is used. + * UDT properties include a nested row within an existing row as a column. The schema of the nested row may be evolved + * independently of the outer row. Changes to the independent schema affect all outer schemas where the UDT is used. */ public class UdtPropertyType extends ScopePropertyType { + @JsonProperty(required = true) private String name; + + @JsonProperty(required = true) private SchemaId schemaId; /** - * Initializes a new {@link UdtPropertyType}. - */ - public UdtPropertyType() { - this.schemaId(SchemaId.INVALID); - } - - /** - * The identifier of the UDT schema defining the structure for the nested row. + * The name of the UDT schema defining the structure of a nested row. *

* The UDT schema MUST be defined within the same {@link Namespace} as the schema that references it. + * + * @return the identifier of the UDT schema defining the structure of a nested row. */ public final String name() { return this.name; } - public final void name(String value) { + /** + * Sets the name of the UDT schema defining the structure of a nested row. + *

+ * The UDT schema MUST be defined within the same {@link Namespace} as the schema that references it. + * + * @param value the name of the UDT schema defining the structure of a nested row. + * @return a reference to this {@link UdtPropertyType}. + */ + public final UdtPropertyType name(String value) { this.name = value; + return this; } /** - * The unique identifier for a schema. + * The unique identifier of the UDT schema defining the structure of a nested row. *

- * Optional uniquifier if multiple versions of {@link #name} appears within the Namespace. + * Optional uniqueifier if multiple versions of {@link #name} appears within the {@link Namespace}. *

- * If multiple versions of a UDT are defined within the {@link Namespace} then the globally - * unique identifier of the specific version referenced MUST be provided. - *

+ * If multiple versions of a UDT are defined within a {@link Namespace} the globally unique identifier of the + * specific version referenced MUST be provided. + * + * @return the unique identifier of the UDT schema defining the structure of a nested row or {@code null}. */ public final SchemaId schemaId() { return this.schemaId; } + /** + * Sets the unique identifier of the UDT schema defining the structure of a nested row. + *

+ * Optional uniqueifier if multiple versions of {@link #name} appears within the {@link Namespace}. + *

+ * If multiple versions of a UDT are defined within a {@link Namespace} the globally unique identifier of the + * specific version referenced MUST be provided. + * + * @param value the unique identifier of the UDT schema defining the structure of a nested row or {@code null}. + * @return a reference to this {@link UdtPropertyType}. + */ public final UdtPropertyType schemaId(SchemaId value) { this.schemaId = value; return this; } -} \ No newline at end of file +}