Пример #1
0
        public static Stage <ConsumerVertex, Epoch> MakeStage(int numberToConsume, int startProcess, int endProcess, int numberOfWorkers, bool exchange, Stream <Pair <int, int>, Epoch> stream)
        {
            var locations = new List <VertexLocation>();

            for (int i = 0; i < endProcess - startProcess; i++)
            {
                for (int j = 0; j < numberOfWorkers; j++)
                {
                    locations.Add(new VertexLocation(locations.Count, i + startProcess, j));
                }
            }

            Placement placement = new Placement.Explicit(locations);

            Stage <ConsumerVertex, Epoch> stage = Foundry.NewStage(placement, stream.Context, (i, s) => new ConsumerVertex(i, s, numberToConsume), "Consumer");


            if (exchange)
            {
                stage.NewInput(stream, (m, v) => v.OnRecv(m), x => x.Second);
            }
            else
            {
                stage.NewInput(stream, (m, v) => v.OnRecv(m), x => x.First);
            }

            return(stage);
        }
Пример #2
0
        public static Stage <ConsumerVertex, Epoch> MakeStage(int numberToConsume, int numberOfPartitions, Stream <int, Epoch> stream)
        {
            Placement placement = new Placement.Explicit(Enumerable.Range(0, numberOfPartitions).Select(x => new VertexLocation(x, 1, x)));

            Stage <ConsumerVertex, Epoch> stage = Foundry.NewStage(placement, stream.Context, (i, s) => new ConsumerVertex(i, s, numberToConsume), "Consumer");

            stage.NewInput(stream, (m, v) => v.OnRecv(m), x => x);
            return(stage);
        }
Пример #3
0
        public static Stream <int, Epoch> MakeStage(int numberToSend, int numberOfPartitions, Stream <int, Epoch> input)
        {
            Placement placement = new Placement.Explicit(Enumerable.Range(0, numberOfPartitions).Select(x => new VertexLocation(x, 0, x)));

            Stage <ProducerVertex, Epoch> stage = Foundry.NewStage(placement, input.Context, (i, s) => new ProducerVertex(i, s, numberToSend), "Producer");

            stage.NewInput(input, (v, m) => { }, null);
            Stream <int, Epoch> stream = stage.NewOutput(v => v.output);

            return(stream);
        }
Пример #4
0
        public static Stream <Pair <int, int>, Epoch> MakeStage(int numberToSend, int startProcess, int endProcess, int numberOfWorkers, Stream <Pair <int, int>, Epoch> input)
        {
            var locations = new List <VertexLocation>();

            for (int i = 0; i < endProcess - startProcess; i++)
            {
                for (int j = 0; j < numberOfWorkers; j++)
                {
                    locations.Add(new VertexLocation(locations.Count, i + startProcess, j));
                }
            }

            Placement placement = new Placement.Explicit(locations);

            Stage <ProducerVertex, Epoch> stage = Foundry.NewStage(placement, input.Context, (i, s) => new ProducerVertex(i, s, numberToSend), "Producer");

            stage.NewInput(input, (v, m) => { }, null);
            Stream <Pair <int, int>, Epoch> stream = stage.NewOutput(v => v.output);

            return(stream);
        }