コード例 #1
0
        protected override void Initialize() {

            Register(new EntityKeysPartial(_process, _entity));

            if (_entity.Input.Count == 1) {
                Register(_entity.Input.First().Connection.Extract(_process, _entity, _process.IsFirstRun));
            } else {
                var union = new ParallelUnionAllOperation();
                foreach (var input in _entity.Input) {
                    union.Add(input.Connection.Extract(_process, _entity, Process.IsFirstRun));
                }
                Register(union);
            }

            if (!_entity.Sampled && _entity.Sample > 0m && _entity.Sample < 100m) {
                Register(new SampleOperation(_entity.Sample) { EntityName = _entity.Name });
            }

            Register(new ApplyDefaults(true, new Fields(_entity.Fields, _entity.CalculatedFields)) { EntityName = _entity.Name });

            foreach (var transform in _entity.OperationsBeforeAggregation) {
                Register(transform);
            }

            if (_entity.HasSort()) {
                Register(new SortOperation(_entity) { EntityName = _entity.Name });
            }

            if (_entity.Group) {
                Register(new EntityAggregation(_entity));
            }

            foreach (var transform in _entity.OperationsAfterAggregation) {
                Register(transform);
            }

            Register(new TruncateOperation(_entity.Name, _entity.Fields, _entity.CalculatedFields));

            var standardOutput = new NamedConnection { Connection = _process.OutputConnection, Name = STANDARD_OUTPUT };

            if (_entity.Output.Count > 0) {
                var branch = new BranchingOperation()
                    .Add(PrepareOutputOperation(_process, standardOutput));
                foreach (var output in _entity.Output) {
                    _collectors[output.Name] = new CollectorOperation();
                    branch.Add(PrepareOutputOperation(_process, output));
                }
                Register(branch);
            } else {
                Register(PrepareOutputOperation(_process, standardOutput));
            }

        }
コード例 #2
0
        private PartialProcessOperation PrepareOutputOperation(Process process, NamedConnection output) {

            var partial = new PartialProcessOperation(process);
            partial.Register(new FilterOutputOperation(output.ShouldRun) { EntityName = _entity.Name });

            if (output.Connection.Type == ProviderType.Internal) {
                partial.Register(_collectors[output.Name]);
            } else {
                if (Process.IsFirstRun || !_entity.DetectChanges) {
                    partial.Register(new EntityAddTflFields(process, _entity));
                    partial.Register(output.Connection.Insert(process, _entity));
                } else {
                    partial.Register(new EntityJoinAction(process, _entity).Right(output.Connection.ExtractCorrespondingKeysFromOutput(_entity)));
                    var branch = new BranchingOperation()
                        .Add(new PartialProcessOperation(process)
                            .Register(new EntityActionFilter(process, _entity, EntityAction.Insert))
                            .Register(output.Connection.Insert(process, _entity)))
                        .Add(new PartialProcessOperation(process)
                            .Register(new EntityActionFilter(process, _entity, EntityAction.Update))
                            .Register(output.Connection.Update(_entity)));

                    partial.Register(branch);
                }
            }
            return partial;
        }