Exemple #1
0
        /// <summary>
        /// Makes a reader for the current input.
        /// </summary>
        /// <typeparam name="T">The record type of the input.</typeparam>
        /// <param name="readerFactory">The reader factory.</param>
        /// <returns>A reader for the current input.</returns>
        public DryadLinqVertexReader <T> MakeReader <T>(DryadLinqFactory <T> readerFactory)
        {
            bool   keepPortOrder = this.m_vertexParams.KeepInputPortOrder(this.m_nextInput);
            UInt32 startPort     = this.m_nextInputPort;

            this.m_nextInputPort += this.m_vertexParams.InputPortCount(this.m_nextInput);
            UInt32 endPort = this.m_nextInputPort;

            this.m_nextInput++;
            return(new DryadLinqVertexReader <T>(this, readerFactory, startPort, endPort, keepPortOrder));
        }
Exemple #2
0
        public DryadLinqVertexWriter(VertexEnv denv, DryadLinqFactory <T> writerFactory, UInt32 portNum)
        {
            this.m_dvertexEnv      = denv;
            this.m_nativeHandle    = denv.NativeHandle;
            this.m_startPort       = portNum;
            this.m_numberOfOutputs = 1;
            this.m_writerFactory   = writerFactory;
            Int32 buffSize = this.m_dvertexEnv.GetWriteBuffSize();
            DryadLinqRecordWriter <T> writer = writerFactory.MakeWriter(this.m_nativeHandle, portNum, buffSize);

            this.m_writers = new DryadLinqRecordWriter <T>[] { writer };
        }
Exemple #3
0
        public DryadLinqVertexReader(VertexEnv denv, DryadLinqFactory <T> readerFactory, UInt32 portNum)
        {
            this.m_dvertexEnv         = denv;
            this.m_nativeHandle       = denv.NativeHandle;
            this.m_readerFactory      = readerFactory;
            this.m_startPort          = portNum;
            this.m_numberOfInputs     = 1;
            this.m_keepInputPortOrder = false;
            this.m_portPermArray      = new UInt32[] { 0 };
            DryadLinqRecordReader <T> reader = readerFactory.MakeReader(this.m_nativeHandle, portNum);

            this.m_readers = new DryadLinqRecordReader <T>[] { reader };
            this.m_isUsed  = false;
        }
Exemple #4
0
 /// <summary>
 /// Make a writer for the current output.
 /// </summary>
 /// <typeparam name="T">The record type of the output.</typeparam>
 /// <param name="writerFactory">The writer factory.</param>
 /// <returns>A writer for the current output.</returns>
 public DryadLinqVertexWriter <T> MakeWriter <T>(DryadLinqFactory <T> writerFactory)
 {
     if (this.m_nextOutputPort + 1 < this.m_vertexParams.OutputArity)
     {
         UInt32 portNum = this.m_nextOutputPort++;
         return(new DryadLinqVertexWriter <T>(this, writerFactory, portNum));
     }
     else
     {
         UInt32 startPort = this.m_nextOutputPort;
         UInt32 endPort   = this.NumberOfOutputs;
         return(new DryadLinqVertexWriter <T>(this, writerFactory, startPort, endPort));
     }
 }
Exemple #5
0
        public DryadLinqVertexWriter(VertexEnv denv, DryadLinqFactory <T> writerFactory, UInt32 startPort, UInt32 endPort)
        {
            this.m_dvertexEnv      = denv;
            this.m_nativeHandle    = denv.NativeHandle;
            this.m_startPort       = startPort;
            this.m_numberOfOutputs = endPort - startPort;
            this.m_writerFactory   = writerFactory;
            this.m_writers         = new DryadLinqRecordWriter <T> [this.m_numberOfOutputs];
            Int32 buffSize = this.m_dvertexEnv.GetWriteBuffSize();

            for (UInt32 i = 0; i < this.m_numberOfOutputs; i++)
            {
                this.m_writers[i] = writerFactory.MakeWriter(this.m_nativeHandle, i + startPort, buffSize);
            }
        }
Exemple #6
0
        public DryadLinqVertexReader(VertexEnv denv,
                                     DryadLinqFactory <T> readerFactory,
                                     UInt32 startPort,
                                     UInt32 endPort,
                                     bool keepInputPortOrder)
        {
            this.m_dvertexEnv         = denv;
            this.m_nativeHandle       = denv.NativeHandle;
            this.m_readerFactory      = readerFactory;
            this.m_startPort          = startPort;
            this.m_numberOfInputs     = endPort - startPort;
            this.m_keepInputPortOrder = keepInputPortOrder;

            this.m_portPermArray = new UInt32[this.NumberOfInputs];
            for (UInt32 i = 0; i < this.NumberOfInputs; i++)
            {
                this.m_portPermArray[i] = i;
            }
            if (!keepInputPortOrder)
            {
                Random rdm = new Random(System.Diagnostics.Process.GetCurrentProcess().Id);
                Int32  max = (Int32)this.NumberOfInputs;
                for (UInt32 i = 1; i < this.NumberOfInputs; i++)
                {
                    int    idx = rdm.Next(max);
                    UInt32 n   = this.m_portPermArray[max - 1];
                    this.m_portPermArray[max - 1] = this.m_portPermArray[idx];
                    this.m_portPermArray[idx]     = n;
                    max--;
                }
            }

            this.m_readers = new DryadLinqRecordReader <T> [this.NumberOfInputs];
            for (UInt32 i = 0; i < this.NumberOfInputs; i++)
            {
                this.m_readers[i] = this.m_readerFactory.MakeReader(this.m_nativeHandle, startPort + i);
            }
            this.m_isUsed = false;
        }