Пример #1
0
 public static void ExecuteThread(Query q, DataItemPool dip)
 {
     while (true)
     {
         q.Iterate(dip.GetItem, dip.ReleaseItem);
         Thread.Sleep(10);
     }
 }
Пример #2
0
        /// <summary>
        /// Iterate function to work through data items.
        /// The Step functions are called with each data item that arrives from one chosen input
        /// The Final functions are called when EOF is encountered on each input
        /// </summary>
        /// <returns>DataItem objects that can be output from this iteration</returns>
        /// <seealso cref="QueryEngine.Step"/>
        /// <seealso cref="QueryEngine.Final"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            ldiBufferOut.Clear();

            //Which input should we read from next?
            //int iNext = Next();

            for (int iNext = 0; iNext < qopInputs.Count; iNext++)
            {
                iLastInput = iNext;
                if (qopInputs[iNext] != null)
                {
                    SplitPunc(qopInputs[iNext].Iterate(gdi, rdi), ref ldiBuffer, ref lpBuffer);
                    itemsIn += ldiBuffer.Count + lpBuffer.Count;
                    if (rgeof[iNext] == false)
                        rgSteplist[iNext](ldiBuffer, ref ldiBufferOut, out rgeof[iNext]);

                    foreach (Punctuation p in lpBuffer)
                        rgPass[iNext](p, ldiBufferOut);

                    foreach (Punctuation p in lpBuffer)
                    {
                        rgKeep[iNext](p);
                        rgProp[iNext](p, ldiBufferOut);
                    }

                    if (rgeof[iNext])
                        rgFinal[iNext](ldiBufferOut);

                    bool fEOF = true;
                    for (int i = 0; i < qopInputs.Count && fEOF == true; i++)
                        fEOF &= rgeof[i];

                    if (fEOF)
                    {
                        ldiBufferOut.Add(diEOF);
                        eof = true;
                    }
                }
            }
            itemsOut += ldiBufferOut.Count;
            return ldiBufferOut;
        }
Пример #3
0
        /// <summary>
        /// Iterate function to work through data items.
        /// The Step functions are called with each data item that arrives from each input.
        /// The Final functions aer called when EOF is encountered on each input
        /// </summary>
        /// <returns>DataItem objects that can be output from this iteration</returns>
        /// <seealso cref="QueryEngine.Step"/>
        /// <seealso cref="QueryEngine.Final"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            bool fLEOF = false, fREOF = false;

            ldiBufferOut.Clear();
            if (opInLeft != null && opInRight != null)
            {
                algorithm.GetDataItem = gdi;
                algorithm.ReleaseDataItem = rdi;

                SplitPunc(opInLeft.Iterate(gdi, rdi), ref ldiBufferLeft, ref lpBufferLeft);
                SplitPunc(opInRight.Iterate(gdi, rdi), ref ldiBufferRight, ref lpBufferRight);
                itemsIn += (ldiBufferLeft.Count + ldiBufferRight.Count + lpBufferLeft.Count + lpBufferRight.Count);

                algorithm.FnStepListLeft(ldiBufferLeft, ref ldiBufferOut, out fLEOF);
                algorithm.FnStepListRight(ldiBufferRight, ref ldiBufferOut, out fREOF);

                foreach (Punctuation p in lpBufferLeft)
                    algorithm.FnPassLeft(p, ldiBufferOut);
                foreach (Punctuation p in lpBufferRight)
                    algorithm.FnPassRight(p, ldiBufferOut);

                foreach (Punctuation p in lpBufferLeft)
                {
                    algorithm.FnKeepLeft(p);
                    algorithm.FnPropLeft(p, ldiBufferOut);
                }
                foreach (Punctuation p in lpBufferRight)
                {
                    algorithm.FnKeepRight(p);
                    algorithm.FnPropRight(p, ldiBufferOut);
                }

                if (fLEOF)
                {
                    algorithm.FnFinalLeft(ldiBufferOut);
                    fLeftEOF = true; //Don't set main EOF flag until after calling final
                }
                if (fREOF)
                {
                    algorithm.FnFinalRight(ldiBufferOut);
                    fRightEOF = true; //Don't set main EOF flag until after calling final
                }

                if (fLeftEOF && fRightEOF)
                {
                    ldiBufferOut.Add(diEOF);
                    eof = true;
                }
                algorithm.GetDataItem = null;
                algorithm.ReleaseDataItem = null;
            }
            itemsOut += ldiBufferOut.Count;
            return ldiBufferOut;
        }
Пример #4
0
        /// <summary>
        /// Iterate function to work through data items.
        /// The Step function is called with each data item that arrives.
        /// The Final function is called when EOF is encountered
        /// </summary>
        /// <returns>DataItem objects that can be output from this iteration</returns>
        /// <seealso cref="QueryEngine.Step"/>
        /// <seealso cref="QueryEngine.Final"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            bool eofInput = false;

            ldiBufferOut.Clear();
            if (opIn != null)
            {
                algorithm.GetDataItem = gdi;
                algorithm.ReleaseDataItem = rdi;

                List<DataItem> ldiIn = opIn.Iterate(gdi, rdi);
                itemsIn += ldiIn.Count;
                Step step = algorithm.FnStep;

                foreach (DataItem di in ldiIn)
                {
                    if (!(di is Punctuation))
                    {
                        if (!di.EOF)
                            step(di, ldiBufferOut);
                        eofInput |= di.EOF;
                    }
                    else
                    {
                        Punctuation p = di as Punctuation;
                        algorithm.FnPass(p, ldiBufferOut);
                        algorithm.FnKeep(p);
                        algorithm.FnProp(p, ldiBufferOut);
                    }
                }

                if (eofInput)
                {
                    algorithm.FnFinal(ldiBufferOut);
                    ldiBufferOut.Add(diEOF);
                    eof = true;
                }

                algorithm.GetDataItem = null;
                algorithm.ReleaseDataItem = null;
            }
            itemsOut += ldiBufferOut.Count;
            return ldiBufferOut;
        }
Пример #5
0
 /// <summary>
 /// Read DataItems iteratively from the source query operator(s)
 /// </summary>
 /// <returns>Any DataItem objects to be output</returns>
 public virtual List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
 {
     return null;
 }
Пример #6
0
        /// <summary>
        /// Output new data items
        /// </summary>
        /// <returns>The DataItem objects to output</returns>
        /// <seealso cref="Data.DataItem"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            ldiBufferOut.Clear();

            DataItem[] rgdi = gdi(CITERATE);
            for (int i = 0; i < CITERATE && !eof; i++)
            {
                if (iRow < cRows)
                {
                    rgdi[i].AddValue((int)((int)iRow / 7));
                    rgdi[i].AddValue((int)iRow);
                }
                else
                {
                    eof = rgdi[i].EOF = true;
                    Punctuation p = new Punctuation(2);
                    p.AddValue(new Punctuation.WildcardPattern());
                    p.AddValue(new Punctuation.WildcardPattern());
                    ldiBufferOut.Add(p);
                }

                ldiBufferOut.Add(rgdi[i]);

                if (iPunct == 0 && ((int)iRow / 7) != ((int)(iRow + 1) / 7))
                {
                    //Let's add a punctuation
                    Punctuation p = new Punctuation(2);
                    p.AddValue(new Punctuation.LiteralPattern((int)(iRow / 7)));
                    p.AddValue(new Punctuation.WildcardPattern());
                    ldiBufferOut.Add(p);
                }

                if (iPunct == 1)
                {
                    if (iRow >= CPUNCTLISTSIZE && iRow % CPUNCTLISTSIZE == 0)
                    {
                        Punctuation p2 = new Punctuation(2);
                        p2.AddValue(new Punctuation.WildcardPattern());
                        Punctuation.LiteralPattern[] rglp = new Punctuation.LiteralPattern[CPUNCTLISTSIZE];
                        for (int iLit = 0; iLit < CPUNCTLISTSIZE; iLit++)
                            rglp[iLit] = new Punctuation.LiteralPattern((int)iRow - CPUNCTLISTSIZE + iLit);
                        p2.AddValue(new Punctuation.ListPattern(rglp));
                        ldiBufferOut.Add(p2);
                    }
                }

                if (iPunct == 2)
                {
                    if (iRow >= CPUNCTLISTSIZE && iRow % CPUNCTLISTSIZE == 0)
                    {
                        Punctuation p2 = new Punctuation(2);
                        p2.AddValue(new Punctuation.WildcardPattern());
                        int iMin = iRow - CPUNCTLISTSIZE + 1, iMax = iRow;
                        p2.AddValue(new Punctuation.RangePattern(iMin, iMax));
                        ldiBufferOut.Add(p2);
                    }
                }
                iRow++;
            }

            cRowsOutput += ldiBufferOut.Count;
            return ldiBufferOut;
        }
Пример #7
0
        /// <summary>
        /// Output new data items
        /// </summary>
        /// <returns>The DataItem objects to output</returns>
        /// <seealso cref="Data.DataItem"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            ldiBufferOut.Clear();

            lock (queBuffer)
            {
                if (queBuffer.Count > 0)
                {
                    int cData = (queBuffer.Count > MAXDATA) ? MAXDATA : queBuffer.Count;
                    DataItem[] rgdi = gdi(cData);
                    for (int i = 0; i < cData; i++)
                        rgdi[i] = queBuffer.Dequeue();
                    ldiBufferOut.AddRange(rgdi);
                }

                //if (queBuffer.Count > 0)
                //    Console.WriteLine("queue size: {0}", queBuffer.Count);
            }

            return ldiBufferOut;
        }
Пример #8
0
        /// <summary>
        /// Iterate through input data items. For a queue, just 
        /// output up to maximum data items
        /// </summary>
        /// <returns></returns>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            List<DataItem> ldiOut;
            bool fEOF = false;

            lock (data)
            {
                int c = (maxData > data.Count) ? data.Count : maxData;
                ldiOut = new List<DataItem>(c);
                while (c > 0)
                {
                    DataItem di = data.Dequeue();
                    ldiOut.Add(di);
                    fEOF |= di.EOF;
                    c--;
                }
                if (ldiOut.Count > 0)
                    eof = fEOF;
            }
            return ldiOut;
        }
Пример #9
0
        /// <summary>
        /// Iterate function to work through data items.
        /// The Step function is called with each data item that arrives.
        /// The Final function is called when EOF is encountered
        /// </summary>
        /// <returns>DataItem objects that can be output from this iteration</returns>
        /// <seealso cref="QueryEngine.Step"/>
        /// <seealso cref="QueryEngine.Final"/>
        public override List<DataItem> Iterate(DataItemPool.GetDataItem gdi, DataItemPool.ReleaseDataItem rdi)
        {
            bool eofInput;

            ldiBufferOut.Clear();
            if (opIn != null)
            {
                algorithm.GetDataItem = gdi;
                algorithm.ReleaseDataItem = rdi;

                SplitPunc(opIn.Iterate(gdi, rdi), ref ldiBuffer, ref lpBuffer);
                algorithm.FnStepList(ldiBuffer, ref ldiBufferOut, out eofInput);
                foreach (Punctuation p in lpBuffer)
                {
                    algorithm.FnPass(p, ldiBufferOut);
                    algorithm.FnKeep(p);
                    algorithm.FnProp(p, ldiBufferOut);
                }
                if (eofInput)
                {
                    algorithm.FnFinal(ldiBufferOut);

                    ldiBufferOut.Add(diEOF);
                    eof = true;
                }

                algorithm.GetDataItem = null;
                algorithm.ReleaseDataItem = null;
            }
            return ldiBufferOut;
        }