Cole-Greer opened a new pull request, #3485:
URL: https://github.com/apache/tinkerpop/pull/3485
## Summary
Implements **PrimitivePDT**, the provider-defined *primitive* type reserved
in the
GraphBinary (`0xF1`) and GraphSON (`g:PrimitivePdt`) V4 specs, completing the
Provider Defined Types feature begun with CompositePDT in #3433.
A PrimitivePDT represents a value as a single **opaque stringified value**
plus a
provider type name — for types that have no native TinkerPop representation
but can
be expressed as one string (e.g. an unsigned 32-bit integer, a WKT geometry,
a
provider-specific identifier). It complements CompositePDT (a type name + a
map of
fields) for structured types.
Wire/text forms:
- **GraphBinary** `0xF1`: `{type}{value}` — two fully-qualified Strings; the
value is
opaque and never parsed by TinkerPop.
- **GraphSON** `g:PrimitivePdt`: `{"type": "...", "value": "..."}` with an
untyped
string value (response-only in V4).
- **gremlin-lang**: `PDT("name", "value")` — an overload of the composite
`PDT("name", [map])` literal (the second argument's type selects the
variant; this
is unambiguous to the parser).
Provider integration is **adapter-based**: a provider registers a primitive
adapter
(`toValue`/`fromValue`) so the driver auto-dehydrates a native object on
send and
auto-hydrates it on receive, with no per-call configuration. A registered
adapter
takes precedence over the `@ProviderDefined` annotation / `[ProviderDefined]`
attribute on dehydration, consistent across GLVs.
## What's included
**gremlin-core / gremlin-util (Java)**
- `PrimitiveProviderDefinedType` value type and
`PrimitiveProviderDefinedTypeSerializer`
(`DataType.PRIMITIVE_PDT` `0xF1`).
- New `PrimitivePDTAdapter`; extracted a common `ProviderDefinedTypeAdapter`
supertype
with `CompositePDTAdapter` / `PrimitivePDTAdapter` implementations and
explicit
composite/primitive registry accessors.
- Registry hydration (incl. primitive-nested-in-composite), GraphBinary
reader/writer
dispatch, and GraphSON `g:PrimitivePdt` ser/deser.
- gremlin-lang grammar overload + all translator visitors + `GremlinLang`
text emission.
- **Prerequisite fix**: made the GraphBinary/GraphSON *write* path
registry-aware so a
type registered via an adapter (but not annotated) can be serialized on the
server→client response path — a pre-existing CompositePDT gap.
**GLVs** — full support in **Python, JavaScript, Go, .NET** (and the Java
driver):
value type, `0xF1` serializer, registry primitive path, gremlin-lang
`PDT("name","value")`
emission + adapter auto-dehydration, and client wiring (reusing the existing
PDT
registry plumbing).
**Server** — test fixtures (`Uint32`, `TinkerId`, and a composite
`Measurement`
containing a primitive) and end-to-end integration coverage.
**Docs** — provider guide section, gremlin-lang literal reference, upgrade
note, and
CHANGELOG entry. The GraphBinary/GraphSON spec sections already matched the
implementation.
## Key design decisions
- **Adapter-only** provider integration for primitives (no annotation path);
a common
adapter supertype unifies discovery while keeping composite/primitive
distinct.
- **Grammar overload** of `PDT(...)` rather than a new keyword, following
the existing
literal-alternation convention.
- **Opaque value**: TinkerPop never parses the value; round-trip fidelity is
preserved
(leading zeros, large/non-numeric values), with the provider adapter owning
parse/format.
- **Adapter precedence over annotation/attribute** on dehydration, matching
the request
and response paths.
## Testing
- **Unit tests** across all languages (serializer round-trip incl.
opaque-value
fidelity, registry hydration with graceful degradation, dual-registration
rejection,
gremlin-lang text emission, adapter-over-annotation/attribute precedence).
- **Per-GLV integration tests** against the Docker test server, covering the
unregistered/raw round-trip, registered auto de/hydration, and
primitive-nested-in-composite: Java, Python, JavaScript, Go, .NET.
VOTE +1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]