private UnaryPipe <TKey, TPayload, TPayload> GetPipe(IStreamObserver <TKey, TPayload> observer) { var lookupKey = CacheKey.Create(); var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => PointAtEndTemplate.Generate(this)); Func <PlanNode, IQueryObject, PlanNode> planNode = ((PlanNode p, IQueryObject o) => new PointAtEndPlanNode(p, o, typeof(TKey), typeof(TPayload), true, generatedPipeType.Item2, false)); var instance = Activator.CreateInstance(generatedPipeType.Item1, this, observer, planNode); var returnValue = (UnaryPipe <TKey, TPayload, TPayload>)instance; return(returnValue); }
/// <summary> /// Generate a batch class definition to be used as a Beat pipe. /// Compile the definition, dynamically load the assembly containing it, and return the Type representing the /// union pipe class. /// </summary> /// <typeparam name="TKey">The key type for both sides.</typeparam> /// <typeparam name="TPayload">The payload type.</typeparam> /// <returns> /// A type that is defined to be a subtype of UnaryPipe<<typeparamref name="TKey"/>,<typeparamref name="TPayload"/>, <typeparamref name="TPayload"/>>. /// </returns> internal static Tuple <Type, string> Generate <TKey, TPayload>(PointAtEndStreamable <TKey, TPayload> stream) { Contract.Requires(stream != null); Contract.Ensures(Contract.Result <Tuple <Type, string> >() == null || typeof(UnaryPipe <TKey, TPayload, TPayload>).GetTypeInfo().IsAssignableFrom(Contract.Result <Tuple <Type, string> >().Item1)); #if CODEGEN_TIMING Stopwatch sw = new Stopwatch(); sw.Start(); #endif var template = new PointAtEndTemplate( string.Format("GeneratedPointAtEnd_{0}", PointAtEndSequenceNumber++), typeof(TKey), typeof(TPayload)); return(template.Generate <TKey, TPayload>(typeof(IStreamable <,>))); }
protected override bool CanGenerateColumnar() { var typeOfTKey = typeof(TKey); var typeOfTPayload = typeof(TPayload); if (typeOfTKey.GetPartitionType() != null) { return(false); } if (!typeOfTPayload.CanRepresentAsColumnar()) { return(false); } var lookupKey = CacheKey.Create(); var generatedPipeType = cachedPipes.GetOrAdd(lookupKey, key => PointAtEndTemplate.Generate(this)); this.errorMessages = generatedPipeType.Item2; return(generatedPipeType.Item1 != null); }