internal static Tuple <Type, string> Generate <TKey, TPayload, TResult>(PartitionedIntervalArrayObservable <TKey, TPayload, TResult> partitionedIntervalObservable) { #if CODEGEN_TIMING Stopwatch sw = new Stopwatch(); sw.Start(); #endif string errorMessages = null; try { var template = new TemporalArrayEgressTemplate(typeof(TKey), typeof(TPayload), typeof(TResult), "Partitioned", "Interval", partitionedIntervalObservable.source.Properties.IsColumnar); if (partitionedIntervalObservable.constructor != null) { template.intervalFunction = (x, y, z) => partitionedIntervalObservable.constructor.Body.ExpressionToCSharpStringWithParameterSubstitution( new Dictionary <ParameterExpression, string> { { partitionedIntervalObservable.constructor.Parameters[0], "colkey[i].Key" }, { partitionedIntervalObservable.constructor.Parameters[0], x }, { partitionedIntervalObservable.constructor.Parameters[1], y }, { partitionedIntervalObservable.constructor.Parameters[2], z }, }); } var keyType = typeof(PartitionKey <>).MakeGenericType(typeof(TKey)); var expandedCode = template.TransformText(); var assemblyReferences = Transformer.AssemblyReferencesNeededFor(keyType, typeof(TPayload), typeof(TResult)); assemblyReferences.Add(typeof(IStreamable <,>).GetTypeInfo().Assembly); assemblyReferences.Add(Transformer.GeneratedStreamMessageAssembly <PartitionKey <TKey>, TPayload>()); var a = Transformer.CompileSourceCode(expandedCode, assemblyReferences, out errorMessages); var t = a.GetType(template.className); #if CODEGEN_TIMING sw.Stop(); Console.WriteLine("Time to generate and instantiate a IOOEJ operator: {0}ms", sw.ElapsedMilliseconds); #endif return(Tuple.Create(t, errorMessages)); } catch { #if CODEGEN_TIMING sw.Stop(); #endif if (Config.CodegenOptions.DontFallBackToRowBasedExecution) { throw new InvalidOperationException("Code Generation failed when it wasn't supposed to!"); } return(Tuple.Create((Type)null, errorMessages)); } }
internal static Tuple <Type, string> Generate <TKey, TPayload>(PartitionedStreamEventArrayObservable <TKey, TPayload> partitionedStreamEventObservable) { #if CODEGEN_TIMING Stopwatch sw = new Stopwatch(); sw.Start(); #endif string errorMessages = null; try { var template = new TemporalArrayEgressTemplate(typeof(TKey), typeof(TPayload), typeof(TPayload), "Partitioned", "StreamEvent", partitionedStreamEventObservable.source.Properties.IsColumnar); var keyType = typeof(PartitionKey <>).MakeGenericType(typeof(TKey)); var expandedCode = template.TransformText(); var assemblyReferences = Transformer.AssemblyReferencesNeededFor(keyType, typeof(TPayload)); assemblyReferences.Add(typeof(IStreamable <,>).GetTypeInfo().Assembly); assemblyReferences.Add(Transformer.GeneratedStreamMessageAssembly <PartitionKey <TKey>, TPayload>()); var a = Transformer.CompileSourceCode(expandedCode, assemblyReferences, out errorMessages); var t = a.GetType(template.className); #if CODEGEN_TIMING sw.Stop(); Console.WriteLine("Time to generate and instantiate a IOOEJ operator: {0}ms", sw.ElapsedMilliseconds); #endif return(Tuple.Create(t, errorMessages)); } catch { #if CODEGEN_TIMING sw.Stop(); #endif if (Config.CodegenOptions.DontFallBackToRowBasedExecution) { throw new InvalidOperationException("Code Generation failed when it wasn't supposed to!"); } return(Tuple.Create((Type)null, errorMessages)); } }