public static CreateSchemaClauseTypeDef MapToSoda(this AssignedType value) { switch (value) { case AssignedType.VARIANT: return(CreateSchemaClauseTypeDef.VARIANT); case AssignedType.MAP: return(CreateSchemaClauseTypeDef.MAP); case AssignedType.OBJECTARRAY: return(CreateSchemaClauseTypeDef.OBJECTARRAY); case AssignedType.AVRO: return(CreateSchemaClauseTypeDef.AVRO); case AssignedType.JSON: return(CreateSchemaClauseTypeDef.JSON); case AssignedType.XML: return(CreateSchemaClauseTypeDef.XML); } return(CreateSchemaClauseTypeDef.NONE); }
/// <summary> /// Ctor. /// </summary> /// <param name="schemaName">name</param> /// <param name="types">event type Name(s)</param> /// <param name="columns">column definition</param> /// <param name="inherits">supertypes</param> /// <param name="assignedType">any type assignment such as Map, Object-array or variant or none-specified</param> /// <param name="startTimestampProperty">The start timestamp property.</param> /// <param name="endTimestampProperty">The end timestamp property.</param> /// <param name="copyFrom">The copy from.</param> public CreateSchemaDesc(String schemaName, ICollection <String> types, IList <ColumnDesc> columns, ICollection <String> inherits, AssignedType assignedType, String startTimestampProperty, String endTimestampProperty, ICollection <String> copyFrom) { SchemaName = schemaName; Types = types; Columns = columns; Inherits = inherits; AssignedType = assignedType; StartTimestampProperty = startTimestampProperty; EndTimestampProperty = endTimestampProperty; CopyFrom = copyFrom; }
public static EventUnderlyingType GetRepresentation( Attribute[] annotations, Configuration configs, AssignedType assignedType) { switch (assignedType) { // assigned type has priority case AssignedType.OBJECTARRAY: return EventUnderlyingType.OBJECTARRAY; case AssignedType.MAP: return EventUnderlyingType.MAP; case AssignedType.AVRO: return EventUnderlyingType.AVRO; case AssignedType.JSON: return EventUnderlyingType.JSON; } if (assignedType == AssignedType.VARIANT || assignedType != AssignedType.NONE) { throw new IllegalStateException("Not handled by event representation: " + assignedType); } // annotation has second priority var annotation = AnnotationUtil.FindAnnotation(annotations, typeof(EventRepresentationAttribute)); if (annotation != null) { var eventRepresentation = (EventRepresentationAttribute) annotation; return eventRepresentation.Value switch { EventUnderlyingType.AVRO => EventUnderlyingType.AVRO, EventUnderlyingType.JSON => EventUnderlyingType.JSON, EventUnderlyingType.OBJECTARRAY => EventUnderlyingType.OBJECTARRAY, EventUnderlyingType.MAP => EventUnderlyingType.MAP, _ => throw new IllegalStateException("Unrecognized enum " + eventRepresentation.Value) }; } // use runtime-wide default var configured = configs.Common.EventMeta.DefaultEventRepresentation; return configured switch { EventUnderlyingType.OBJECTARRAY => EventUnderlyingType.OBJECTARRAY, EventUnderlyingType.MAP => EventUnderlyingType.MAP, EventUnderlyingType.AVRO => EventUnderlyingType.AVRO, EventUnderlyingType.JSON => EventUnderlyingType.JSON, _ => EventUnderlyingType.MAP }; } } } // end of namespace
public static CreateSchemaClauseTypeDef MapToSoda(this AssignedType value) { switch (value) { case AssignedType.VARIANT: return(CreateSchemaClauseTypeDef.VARIANT); case AssignedType.MAP: return(CreateSchemaClauseTypeDef.MAP); case AssignedType.OBJECTARRAY: return(CreateSchemaClauseTypeDef.OBJECTARRAY); default: return(CreateSchemaClauseTypeDef.NONE); } }
private static CreateSchemaDesc GetSchemaDesc(EsperEPL2GrammarParser.CreateSchemaDefContext ctx, AssignedType assignedType) { var schemaName = ctx.name.Text; var columnTypes = GetColTypeList(ctx.createColumnList()); // get model-after types (could be multiple for variants) ISet <string> typeNames = new LinkedHashSet <string>(); if (ctx.variantList() != null) { IList <EsperEPL2GrammarParser.VariantListElementContext> variantCtxs = ctx.variantList().variantListElement(); foreach (var variantCtx in variantCtxs) { typeNames.Add(variantCtx.GetText().UnmaskTypeName()); } } // get inherited and start timestamp and end timestamps string startTimestamp = null; string endTimestamp = null; ISet <string> inherited = new LinkedHashSet <string>(); ISet <string> copyFrom = new LinkedHashSet <string>(); if (ctx.createSchemaQual() != null) { IList <EsperEPL2GrammarParser.CreateSchemaQualContext> qualCtxs = ctx.createSchemaQual(); foreach (var qualCtx in qualCtxs) { var qualName = qualCtx.i.Text.ToLower(); var cols = ASTUtil.GetIdentList(qualCtx.columnList()); var qualNameLower = qualName.ToLower(); switch (qualNameLower) { case "inherits": inherited.AddAll(cols); continue; case "starttimestamp": startTimestamp = cols[0]; continue; case "endtimestamp": endTimestamp = cols[0]; continue; case "copyfrom": copyFrom.AddAll(cols); continue; } throw new EPException("Expected 'inherits', 'starttimestamp', 'endtimestamp' or 'copyfrom' keyword after create-schema clause but encountered '" + qualName + "'"); } } return(new CreateSchemaDesc(schemaName, typeNames, columnTypes, inherited, assignedType, startTimestamp, endTimestamp, copyFrom)); }
public static EventUnderlyingType GetRepresentation( Attribute[] annotations, ConfigurationInformation configs, AssignedType assignedType) { // assigned type has priority if (assignedType == AssignedType.OBJECTARRAY) { return(EventUnderlyingType.OBJECTARRAY); } else if (assignedType == AssignedType.MAP) { return(EventUnderlyingType.MAP); } else if (assignedType == AssignedType.AVRO) { return(EventUnderlyingType.AVRO); } if (assignedType == AssignedType.VARIANT || assignedType != AssignedType.NONE) { throw new IllegalStateException("Not handled by event representation: " + assignedType); } // annotation has second priority var annotation = AnnotationUtil.FindAnnotation(annotations, typeof(EventRepresentationAttribute)); if (annotation != null) { EventRepresentationAttribute eventRepresentation = (EventRepresentationAttribute)annotation; if (eventRepresentation.Value == EventUnderlyingType.AVRO) { return(EventUnderlyingType.AVRO); } else if (eventRepresentation.Value == EventUnderlyingType.OBJECTARRAY) { return(EventUnderlyingType.OBJECTARRAY); } else if (eventRepresentation.Value == EventUnderlyingType.MAP) { return(EventUnderlyingType.MAP); } else { throw new IllegalStateException("Unrecognized enum " + eventRepresentation.Value); } } // use engine-wide default EventUnderlyingType configured = configs.EngineDefaults.EventMeta.DefaultEventRepresentation; if (configured == EventUnderlyingType.OBJECTARRAY) { return(EventUnderlyingType.OBJECTARRAY); } else if (configured == EventUnderlyingType.MAP) { return(EventUnderlyingType.MAP); } else if (configured == EventUnderlyingType.AVRO) { return(EventUnderlyingType.AVRO); } return(EventUnderlyingType.MAP); }
public static bool IsMap(Attribute[] annotations, ConfigurationInformation configs, AssignedType assignedType) { // assigned type has priority if (assignedType == AssignedType.OBJECTARRAY) { return(false); } if (assignedType == AssignedType.MAP) { return(true); } if (assignedType == AssignedType.VARIANT || assignedType != AssignedType.NONE) { throw new IllegalStateException("Not handled by event representation: " + assignedType); } // annotation has second priority Attribute annotation = epl.annotation.AnnotationUtil.FindAttribute((IEnumerable <Attribute>)annotations, typeof(EventRepresentationAttribute)); if (annotation != null) { var eventRepresentation = (EventRepresentationAttribute)annotation; return(!eventRepresentation.Array); } // use engine-wide default return(configs.EngineDefaults.EventMetaConfig.DefaultEventRepresentation == EventRepresentation.MAP); }