Example #1
0
 public override bool SkipTo(int target)
 {
     if (FirstTime) // initialize
     {
         InitList(false);
         for (SpansCell cell = First; More && cell != null; cell = cell.Next_Renamed)
         {
             More = cell.SkipTo(target); // skip all
         }
         if (More)
         {
             ListToQueue();
         }
         FirstTime = false;
     } // normal case
     else
     {
         while (More && Min().Doc() < target) // skip as needed
         {
             if (Min().SkipTo(target))
             {
                 Queue.UpdateTop();
             }
             else
             {
                 More = false;
             }
         }
     }
     return(More && (AtMatch() || Next()));
 }
Example #2
0
            public override bool LessThan(System.Object o1, System.Object o2)
            {
                SpansCell spans1 = (SpansCell)o1;
                SpansCell spans2 = (SpansCell)o2;

                if (spans1.Doc() == spans2.Doc())
                {
                    if (spans1.Start() == spans2.Start())
                    {
                        if (spans1.End() == spans2.End())
                        {
                            return(spans1.index > spans2.index);
                        }
                        else
                        {
                            return(spans1.End() < spans2.End());
                        }
                    }
                    else
                    {
                        return(spans1.Start() < spans2.Start());
                    }
                }
                else
                {
                    return(spans1.Doc() < spans2.Doc());
                }
            }
Example #3
0
 private void FirstToLast()
 {
     last.next = first; // move first to end of list
     last      = first;
     first     = first.next;
     last.next = null;
 }
Example #4
0
        private bool FirstNonOrderedNextToPartialList()
        {
            /* Creates a partial list consisting of first non ordered and earlier.
             * Returns first non ordered .next().
             */
            last = first = null;
            int orderedIndex = 0;

            while (queue.Top() != null)
            {
                SpansCell cell = (SpansCell)queue.Pop();
                AddToList(cell);
                if (cell.index == orderedIndex)
                {
                    orderedIndex++;
                }
                else
                {
                    return(cell.Next());
                    // FIXME: continue here, rename to eg. checkOrderedMatch():
                    // when checkSlop() and not ordered, repeat cell.next().
                    // when checkSlop() and ordered, add to list and repeat queue.pop()
                    // without checkSlop(): no match, rebuild the queue from the partial list.
                    // When queue is empty and checkSlop() and ordered there is a match.
                }
            }
            throw new System.SystemException("Unexpected: ordered");
        }
Example #5
0
 private void  PartialListToQueue()
 {
     for (SpansCell cell = first; cell != null; cell = cell.next)
     {
         queue.Put(cell);                 // add to queue from list
     }
 }
Example #6
0
 private void FirstToLast()
 {
     Last.Next_Renamed = First; // move first to end of list
     Last              = First;
     First             = First.Next_Renamed;
     Last.Next_Renamed = null;
 }
Example #7
0
 public virtual bool SkipTo(int target)
 {
     if (firstTime)
     {
         // initialize
         InitList(false);
         for (SpansCell cell = first; more && cell != null; cell = cell.next)
         {
             more = cell.SkipTo(target);                     // skip all
         }
         if (more)
         {
             ListToQueue();
         }
         firstTime = false;
     }
     else
     {
         // normal case
         while (more && Min().Doc() < target)
         {
             // skip as needed
             if (Min().SkipTo(target))
             {
                 queue.AdjustTop();
             }
             else
             {
                 more = false;
             }
         }
     }
     return(more && (AtMatch() || Next()));
 }
Example #8
0
 public override bool SkipTo(int target)
 {
     if (firstTime) // initialize
     {
         InitList(false);
         for (SpansCell cell = first; more && cell != null; cell = cell.next)
         {
             more = cell.SkipTo(target); // skip all
         }
         if (more)
         {
             ListToQueue();
         }
         firstTime = false;
     } // normal case
     else
     {
         while (more && Min.Doc < target) // skip as needed
         {
             if (Min.SkipTo(target))
             {
                 queue.UpdateTop();
             }
             else
             {
                 more = false;
             }
         }
     }
     return(more && (AtMatch || Next()));
 }
Example #9
0
 private void ListToQueue()
 {
     queue.Clear(); // rebuild queue
     for (SpansCell cell = first; cell != null; cell = cell.next)
     {
         queue.Add(cell); // add to queue from list
     }
 }
Example #10
0
 private void QueueToList()
 {
     Last = First = null;
     while (Queue.Top() != null)
     {
         AddToList(Queue.Pop());
     }
 }
Example #11
0
 private void QueueToList()
 {
     last = first = null;
     while (queue.Top != null)
     {
         AddToList(queue.Pop());
     }
 }
Example #12
0
 private void ListToQueue()
 {
     Queue.Clear(); // rebuild queue
     for (SpansCell cell = First; cell != null; cell = cell.Next_Renamed)
     {
         Queue.Add(cell); // add to queue from list
     }
 }
        // TODO: Remove warning after API has been finalized

        /// <summary> WARNING: The List is not necessarily in order of the the positions</summary>
        /// <returns> Collection of &amp;lt;c&amp;gt;byte[]&amp;lt;/c&amp;gt; payloads </returns>
        /// <throws>  IOException </throws>
        public override ICollection <byte[]> GetPayload()
        {
            System.Collections.Generic.ISet <byte[]> matchPayload = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet <byte[]>();
            for (SpansCell cell = first; cell != null; cell = cell.next)
            {
                if (cell.IsPayloadAvailable())
                {
                    matchPayload.UnionWith(cell.GetPayload());
                }
            }
            return(matchPayload);
        }
        private int totalLength; // sum of current lengths

        #endregion Fields

        #region Constructors

        public NearSpansUnordered(SpanNearQuery query, IndexReader reader)
        {
            this.query = query;
            this.slop = query.GetSlop();

            SpanQuery[] clauses = query.GetClauses();
            queue = new CellQueue(this, clauses.Length);
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetPayloadSpans(reader), i);
                ordered.Add(cell);
            }
        }
Example #15
0
 private void AddToList(SpansCell cell)
 {
     if (last != null) // add next to end of list
     {
         last.next = cell;
     }
     else
     {
         first = cell;
     }
     last      = cell;
     cell.next = null;
 }
Example #16
0
 private void AddToList(SpansCell cell)
 {
     if (Last != null) // add next to end of list
     {
         Last.Next_Renamed = cell;
     }
     else
     {
         First = cell;
     }
     Last = cell;
     cell.Next_Renamed = null;
 }
Example #17
0
        public NearSpansUnordered(SpanNearQuery query, IndexReader reader)
        {
            this.query = query;
            this.slop  = query.GetSlop();

            SpanQuery[] clauses = query.GetClauses();
            queue = new CellQueue(this, clauses.Length);
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(reader), i);
                ordered.Add(cell);
            }
        }
        public bool IsPayloadAvailable()
        {
            SpansCell pointer = Min();

            while (pointer != null)
            {
                if (pointer.IsPayloadAvailable())
                {
                    return(true);
                }
                pointer = pointer.next;
            }
            return(false);
        }
Example #19
0
            public override bool LessThan(System.Object o1, System.Object o2)
            {
                SpansCell spans1 = (SpansCell)o1;
                SpansCell spans2 = (SpansCell)o2;

                if (spans1.Doc() == spans2.Doc())
                {
                    return(NearSpansOrdered.DocSpansOrdered(spans1, spans2));
                }
                else
                {
                    return(spans1.Doc() < spans2.Doc());
                }
            }
Example #20
0
        public NearSpans(SpanNearQuery query, IndexReader reader)
        {
            this.query   = query;
            this.slop    = query.GetSlop();
            this.inOrder = query.IsInOrder();

            SpanQuery[] clauses = query.GetClauses();             // initialize spans & list
            queue = new CellQueue(this, clauses.Length);
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(reader), i);
                ordered.Add(cell);                 // add to ordered
            }
        }
Example #21
0
 private void  InitList(bool next, IState state)
 {
     for (int i = 0; more && i < ordered.Count; i++)
     {
         SpansCell cell = ordered[i];
         if (next)
         {
             more = cell.Next(state);                     // move to first entry
         }
         if (more)
         {
             AddToList(cell);                     // add to list
         }
     }
 }
Example #22
0
        public NearSpansUnordered(SpanNearQuery query, IndexReader reader, IState state)
        {
            this.query = query;
            this.slop  = query.Slop;

            SpanQuery[] clauses = query.GetClauses();
            queue    = new CellQueue(this, clauses.Length);
            subSpans = new Spans[clauses.Length];
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(reader, state), i);
                ordered.Add(cell);
                subSpans[i] = cell.spans;
            }
        }
Example #23
0
 private void InitList(bool next)
 {
     for (int i = 0; More && i < Ordered.Count; i++)
     {
         SpansCell cell = Ordered[i];
         if (next)
         {
             More = cell.Next(); // move to first entry
         }
         if (More)
         {
             AddToList(cell); // add to list
         }
     }
 }
Example #24
0
        public NearSpansUnordered(SpanNearQuery query, AtomicReaderContext context, Bits acceptDocs, IDictionary <Term, TermContext> termContexts)
        {
            this.Query = query;
            this.Slop  = query.Slop;

            SpanQuery[] clauses = query.Clauses;
            Queue    = new CellQueue(this, clauses.Length);
            subSpans = new Spans[clauses.Length];
            for (int i = 0; i < clauses.Length; i++)
            {
                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(context, acceptDocs, termContexts), i);
                Ordered.Add(cell);
                subSpans[i] = cell.Spans;
            }
        }
        public ICollection <byte[]> GetPayload()
        {
            Dictionary <byte[], byte[]> matchPayload = new Dictionary <byte[], byte[]>();

            for (SpansCell cell = first; cell != null; cell = cell.next)
            {
                if (cell.IsPayloadAvailable())
                {
                    for (IEnumerator <byte[]> e = cell.GetPayload().GetEnumerator(); e.MoveNext();)
                    {
                        matchPayload[e.Current] = e.Current;
                    }
                }
            }
            return(matchPayload.Keys);
        }
Example #26
0
 // TODO: Remove warning after API has been finalized
 /// <summary> WARNING: The List is not necessarily in order of the the positions</summary>
 /// <returns> Collection of <code>byte[]</code> payloads
 /// </returns>
 /// <throws>  IOException </throws>
 public override System.Collections.Generic.ICollection <byte[]> GetPayload()
 {
     //mgarski: faking out another HashSet<T>...
     System.Collections.Generic.Dictionary <byte[], byte[]> matchPayload = new System.Collections.Generic.Dictionary <byte[], byte[]>();
     for (SpansCell cell = first; cell != null; cell = cell.next)
     {
         if (cell.IsPayloadAvailable())
         {
             System.Collections.Generic.ICollection <byte[]> cellPayload = cell.GetPayload();
             foreach (byte[] val in cellPayload)
             {
                 if (!matchPayload.ContainsKey(val))
                 {
                     matchPayload.Add(val, val);
                 }
             }
         }
     }
     return(matchPayload.Keys);
 }
Example #27
0
		private void  QueueToList()
		{
			last = first = null;
			while (queue.Top() != null)
			{
				AddToList((SpansCell) queue.Pop());
			}
		}
		public NearSpans(SpanNearQuery query, Monodoc.Lucene.Net.Index.IndexReader reader)
		{
			this.query = query;
			this.slop = query.GetSlop();
			this.inOrder = query.IsInOrder();
			
			SpanQuery[] clauses = query.GetClauses(); // initialize spans & list
			queue = new CellQueue(this, clauses.Length);
			for (int i = 0; i < clauses.Length; i++)
			{
				SpansCell cell = new SpansCell(this, clauses[i].GetSpans(reader), i);
				ordered.Add(cell); // add to ordered
			}
		}
		private bool FirstNonOrderedNextToPartialList()
		{
			/* Creates a partial list consisting of first non ordered and earlier.
			* Returns first non ordered .next().
			*/
			last = first = null;
			int orderedIndex = 0;
			while (queue.Top() != null)
			{
				SpansCell cell = (SpansCell) queue.Pop();
				AddToList(cell);
				if (cell.index == orderedIndex)
				{
					orderedIndex++;
				}
				else
				{
					return cell.Next();
					// FIXME: continue here, rename to eg. checkOrderedMatch():
					// when checkSlop() and not ordered, repeat cell.next().
					// when checkSlop() and ordered, add to list and repeat queue.pop()
					// without checkSlop(): no match, rebuild the queue from the partial list.
					// When queue is empty and checkSlop() and ordered there is a match.
				}
			}
			throw new System.SystemException("Unexpected: ordered");
		}
Example #30
0
		private void  AddToList(SpansCell cell)
		{
			if (last != null)
			{
				// add next to end of list
				last.next = cell;
			}
			else
				first = cell;
			last = cell;
			cell.next = null;
		}
Example #31
0
		private void  FirstToLast()
		{
			last.next = first; // move first to end of list
			last = first;
			first = first.next;
			last.next = null;
		}