--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/a91ba0a5-9656-413a-8223-a50c2eadfe87%40googlegroups.com.
-- | Convert a logical schema to or from a Protobuf AST
protobufSchemaMapping :: ProtoConfig -> SchemaVocabulary -> Mapping Schema ProtoSchema Sorta
protobufSchemaMapping config vocab = Mapping toProto fromProto
where
toProto schema = ProtoSchema <$> path <*> dotProto <*> comment <*> content
where [...]
fromProto (ProtoSchema path proto comment content) = schema
where [...]
Is the source tree public?I, like Josh, need interop between schema and databases.
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/c2bb8f5c-c403-4874-9964-d860ac240d11%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/58bab547-6037-4b08-a1ed-20beb27f38be%40googlegroups.com.
typeMapping :: ThriftConfig -> SchemaVocabulary -> SchemaName -> Mapping Type (Maybe (TA.Type TMP.SourcePos)) Sorta
typeMapping options vocab sname = Mapping toThrift fromThrift
where
toThrift atype = if isBasicTypedef atype
-- if this is a redundant alias for a primitive type, and does not have a js.type annotation, omit it
then pure Nothing
else byDataType dt
where
Type dt name (CommonInfo _ _ sameAs _ _ _) _ = atype
jsType = jsSameAs sameAs
thriftName = mapTo typeNameMapping name
anns = pure [] -- sameAsAnnotations $ webSameAs sameAs
doc = fmap (Just . T.pack) $ mapTo typeInfoMapping $ typeInfo atype
byDataType dt = case dt of
ZeroType -> byDataType (SumType [])
UnitType -> byDataType (ProductType [])
PrimitiveType dt ->
fmap (Just . TA.TypedefType) $ TA.Typedef <$> target <*> thriftName <*> anns <*> doc <*> pure srcPos
where
target = pure $ datatypeToThrift dt jsType
ProductType fields -> forSumOrProduct fields False
SumType cases -> forSumOrProduct cases True
-- note: irreversible; needs an annotation
OptionalType dt -> byDataType dt
EnumType values -> fmap (Just . TA.EnumType) enum
where
enum = TA.Enum <$> thriftName <*> enumDefs <*> anns <*> doc <*> pure srcPos
enumDefs = catSortas $ L.zipWith (\id v -> emap (v, Just id)) [0..] (rpcEnumValues name values)
emap = mapTo enumValueMapping
ListType _ -> pure Nothing
SetType _ -> pure Nothing
MapType _ _ -> pure Nothing
-- note: ignoring ExceptionKind
forSumOrProduct fields union = fmap Just included
where
included =
fmap TA.StructType $ TA.Struct <$> dt <*> thriftName <*> thriftFields <*> anns <*> doc <*> pure srcPos
thriftFields = catSortas $ fmap map $ L.zipWith withId fields $ propertyIndexes fields
withId (Field tr nm rb (FieldInfo common _ def card) owner) id
= Field tr nm rb (FieldInfo common (Just id) def card) owner
map = mapTo (fieldMapping union options vocab sname (directTypePointer atype))
dt = pure $ if union then TA.UnionKind else TA.StructKind
fromThrift Nothing = fromThrift $
Just $ TA.TypedefType (TA.Typedef (TA.DefinedType (T.pack "UndefinedType") srcPos) (T.pack "UndefinedTypedef") [] Nothing srcPos)
fromThrift (Just t) = byType t
where
toTypeInfo :: Maybe T.Text -> Sorta CommonInfo
toTypeInfo doc = mapFrom typeInfoMapping $ Y.maybe "" T.unpack doc
byType :: (TA.Type TMP.SourcePos) -> Sorta Type
byType t = case t of
TA.EnumType (TA.Enum name values anns doc src) ->
Type <$> dt <*> nm <*> toTypeInfo doc <*> pure sname
where
dt :: Sorta DataType
dt = fmap EnumType $ catSortas $ fmap toValue values
nm :: Sorta String
nm = mapFrom typeNameMapping name
toValue v = fmap fst $ mapFrom enumValueMapping v
TA.TypedefType (TA.Typedef tref name anns doc src) ->
Type <$> dt <*> nm <*> toTypeInfo doc <*> pure sname
where
-- We can safely unwrap the Kinda here, as it is a local typeref
dt :: Sorta DataType
dt = do
s <- fromThriftTypeReference vocab sname tref False
dt <- kindaSorta $ toDataType s
return dt
nm = mapFrom typeNameMapping name
toDataType (NamedType t) = fmap dataType $ typePointerResolver t "type from Thrift" vocab
toDataType dt = pure dt
TA.StructType (TA.Struct thriftKind thriftName thriftFields anns doc src) -> do
nm <- mapFrom typeNameMapping thriftName
let typePointer = localTypePointer sname nm
let mapper x = mapFrom (fieldMapping union options vocab sname typePointer) x
fields <- catSortas $ fmap mapper thriftFields
let dt = if union
then (if L.null fields then ZeroType else SumType fields)
else (if L.null fields then UnitType else ProductType fields)
info <- toTypeInfo doc
return $ Type dt nm info sname
where
union = case thriftKind of
TA.UnionKind -> True
TA.StructKind -> False
TA.ExceptionKind -> False -- TODO: don't make this into a struct
TA.SenumType (TA.Senum name values anns doc src) ->
unsup logicalFormat "SenumType"
> To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_a91ba0a5-2D9656-2D413a-2D8223-2Da50c2eadfe87-2540googlegroups.com&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=ffg4p-8e545v4RN_Vib7RXdHWqv975TBMiHqbF8rVDE&s=i049oMUy3-KjnlAJRHtTu_5fOMItUjQ4LXTyZuMPu8c&e= .
>
> --
> You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
> To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_58bab547-2D6037-2D4b08-2Da1ed-2D20beb27f38be-2540googlegroups.com&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=ffg4p-8e545v4RN_Vib7RXdHWqv975TBMiHqbF8rVDE&s=xMlnoALGqeiFlFxlzBkrkeLVNfqpnaGDPK1vn8cBm3o&e= .
>
> --
> You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
> To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_CAPc0OuudWapkOOPfVsRN4WyRH6-5FYQu16dBqFNskDaehUfdTtiw-2540mail.gmail.com&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=ffg4p-8e545v4RN_Vib7RXdHWqv975TBMiHqbF8rVDE&s=LZLGCPk27ECCdPk4l1nq9NJQfd49gLlLJh5viHAwneo&e= .
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_2B7D49DD-2DF17B-2D4175-2D9AAD-2DD7076E5E71A8-2540conexus.ai&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=ffg4p-8e545v4RN_Vib7RXdHWqv975TBMiHqbF8rVDE&s=u9vhqVURHxqZpE5HSkCV2r3MPQog2hTtTdOoQk_7xDk&e= .
name: position
description: "A schema for GPS sensor data"
status: Production
includes:
- ../basic/datatypes
- ../time/time
- geometry
- name: UnixTimeMillis
description: "A timestamp in milliseconds since the Unix epoch"
type:
integer:
precisionBits: 64
sameAs:
- id: Date
context: JavaScript
seeAlso:
- https://en.wikipedia.org/wiki/Unix_time
- name: TimeEvent
description: "A measurement of time by a device, such as an accelerometer or GPS unit"
type:
record:
fields:
- name: epochMillis
description: "Absolute time of the event in milliseconds"
type: UnixTimeMillis
index: 1
- name: nanosSinceBoot
description: "Elapsed time in nanoseconds since the measuring device became active"
type:
optional: Long
index: 2
- name: Owner
description: "The identity of an owner of a dataset, by email address or user name"
type:
union:
cases:
- name: userName
description: "The user name of the owner"
type: UserName
- name: emailAddress
description: "The email address of the owner"
type: EmailAddress
- name: TemporalUnit
description: "A standard duration, which provides the scale factor for a time extent, or the granularity or precision for a time position"
sameAs:
- id: http://www.w3.org/2006/time#TemporalUnit
context: Web
type:
enumeration:
values:
- YEAR
- MONTH
- WEEK
- DAY
- HOUR
- MINUTE
- SECOND
- MILLISECOND
- MICROSECOND
- NANOSECOND
- name: TemporalUnit
description: "A standard duration, which provides the scale factor for a time extent, or the granularity or precision for a time position"
sameAs:
- id: http://www.w3.org/2006/time#TemporalUnit
context: Web
type:
union:
cases:
- name: year
- name: month
- name: week
- name: day
- name: hour
- name: minute
- name: second
- name: millisecond
- name: microsecond
- name: nanosecond
- name: TripId
description: "An identifier for a trip"
type:
named: UUID
- name: Trip
description: "An actual or potential trip"
sameAs:
- id: https://schema.org/Trip
context: Web
id: TripId[...]
- name: vehicle
description: "The relationship between a trip and the vehicle which was used for the trip"
type:
record:
- name: from
description: "The trip"
type: Trip
- name: to
description: "The vehicle which was used for the trip"
type: Vehicle
> To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_CAPc0OusAhVPqPzEuADnneD-5FjMEw0GUOJbdDA09pK5sp3uOio9w-2540mail.gmail.com&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=zs-cRz81YDlQ17Ul7RSHGyqunCpV6HEhr7vatRNysXk&s=i0DYuFDJ61DSmGJdSvfL4o9hhYikKuGKMQAAMS6quTE&e= .
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_B77A0A2B-2DEAB8-2D4021-2DBF39-2DD99495907342-2540conexus.ai&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=zs-cRz81YDlQ17Ul7RSHGyqunCpV6HEhr7vatRNysXk&s=auxmaYy97oAM4TTvP6CGzk-JulNKBtZ7DBIaRx2V0I0&e= .
As far as interchange formats for algebraic datatypes go, there's also:
>Â Â Â Â context: Web
>Â Â type:
>Â Â Â enumeration:
>Â Â Â Â values:
>Â Â Â Â Â - YEAR
>Â Â Â Â Â - MONTH
>Â Â Â Â Â - WEEK
>Â Â Â Â Â - DAY
>Â Â Â Â Â - HOUR
>Â Â Â Â Â - MINUTE
>Â Â Â Â Â - SECOND
>Â Â Â Â Â - MILLISECOND
>Â Â Â Â Â - MICROSECOND
>Â Â Â Â Â - NANOSECOND
> ...with mandatory SCREAMING_SNAKE_CASE for enumerated values which makes them easy to align with Thrift and Protobuf. However, the same definition could just as well be expressed with union syntax, e.g.
> - name: TemporalUnit
>Â Â description: "A standard duration, which provides the scale factor for a time extent, or the granularity or precision for a time position"
>Â Â sameAs:
>Â Â Â Â context: Web
>Â Â type:
>Â Â Â union:
>Â Â Â Â cases:
>Â Â Â Â Â - name: year
>Â Â Â Â Â - name: month
>Â Â Â Â Â - name: week
>Â Â Â Â Â - name: day
>Â Â Â Â Â - name: hour
>Â Â Â Â Â - name: minute
>Â Â Â Â Â - name: second
>Â Â Â Â Â - name: millisecond
>Â Â Â Â Â - name: microsecond
>Â Â Â Â Â - name: nanosecond
> Note: the sameAs annotation is used loosely; it really means something like "related to". Finally, a slightly more contrived example including a couple of vertex labels and an edge label:
> - name: TripId
>Â Â description: "An identifier for a trip"
>Â Â type:
>Â Â Â named: UUID
>
> - name: Trip
>Â Â description: "An actual or potential trip"
>Â Â sameAs:
> To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_CAPc0OutL-252BLrKGQ9-5FuYWhR0mCFVWps8kbDtTg5PVe78UfFyJkNw-2540mail.gmail.com&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=Nb3RhEfG5MxtSihivcwciw4FrimfLkeaa6mKM9qydpg&s=L88G0_PPbe89JDhwCCB4SepKFT8qJ4J3mDf85N4rOv4&e= .
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://urldefense.proofpoint.com/v2/url?u=https-3A__groups.google.com_d_msgid_gremlin-2Dusers_35DA2C48-2DBD9B-2D4E3A-2D98C7-2D7D42FAD3E848-2540conexus.ai&d=DwIFaQ&c=r2dcLCtU9q6n0vrtnDw9vg&r=yHrezOOUvTAeD_KgsElyJw&m=Nb3RhEfG5MxtSihivcwciw4FrimfLkeaa6mKM9qydpg&s=vUkmg81j_6B4i-XtCl02glAYEQ2nUJwSQ-v_TiDVrPU&e= .