private void  InitBlock(Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, AnonymousClassFieldCacheRangeFilter enclosingInstance)
 {
     this.fcsi = fcsi;
     this.inclusiveLowerPoint = inclusiveLowerPoint;
     this.inclusiveUpperPoint = inclusiveUpperPoint;
     this.enclosingInstance   = enclosingInstance;
 }
            public override DocIdSet GetDocIdSet(IndexReader reader)
            {
                Lucene.Net.Search.StringIndex fcsi = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field);
                int lowerPoint = fcsi.BinarySearchLookup((System.String)lowerVal);
                int upperPoint = fcsi.BinarySearchLookup((System.String)upperVal);

                int inclusiveLowerPoint;
                int inclusiveUpperPoint;

                // Hints:
                // * binarySearchLookup returns 0, if value was null.
                // * the value is <0 if no exact hit was found, the returned value
                //   is (-(insertion point) - 1)
                if (lowerPoint == 0)
                {
                    System.Diagnostics.Debug.Assert(lowerVal == null);
                    inclusiveLowerPoint = 1;
                }
                else if (includeLower && lowerPoint > 0)
                {
                    inclusiveLowerPoint = lowerPoint;
                }
                else if (lowerPoint > 0)
                {
                    inclusiveLowerPoint = lowerPoint + 1;
                }
                else
                {
                    inclusiveLowerPoint = System.Math.Max(1, -lowerPoint - 1);
                }

                if (upperPoint == 0)
                {
                    System.Diagnostics.Debug.Assert(upperVal == null);
                    inclusiveUpperPoint = System.Int32.MaxValue;
                }
                else if (includeUpper && upperPoint > 0)
                {
                    inclusiveUpperPoint = upperPoint;
                }
                else if (upperPoint > 0)
                {
                    inclusiveUpperPoint = upperPoint - 1;
                }
                else
                {
                    inclusiveUpperPoint = -upperPoint - 2;
                }

                if (inclusiveUpperPoint <= 0 || inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(DocIdSet.EMPTY_DOCIDSET);
                }

                System.Diagnostics.Debug.Assert(inclusiveLowerPoint > 0 && inclusiveUpperPoint > 0);

                // for this DocIdSet, we never need to use TermDocs,
                // because deleted docs have an order of 0 (null entry in StringIndex)
                return(new AnonymousClassFieldCacheDocIdSet(fcsi, inclusiveLowerPoint, inclusiveUpperPoint, this, reader, false));
            }
Example #3
0
        /*(non-Javadoc) @see Lucene.Net.Search.Function.ValueSource#getValues(Lucene.Net.Index.IndexReader) */
        public override DocValues GetValues(IndexReader reader)
        {
            Lucene.Net.Search.StringIndex sindex = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field);

            int[] arr = sindex.Order;
            int   end = sindex.Lookup.Length;

            return(new AnonymousClassDocValues(end, arr, this));
        }
Example #4
0
            public override void  SetNextReader(IndexReader reader, int docBase, IState state)
            {
                StringIndex currentReaderValues = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field, state);

                currentReaderGen++;
                order  = currentReaderValues.order;
                lookup = currentReaderValues.lookup;
                System.Diagnostics.Debug.Assert(lookup.Length > 0);
                if (bottomSlot != -1)
                {
                    Convert(bottomSlot);
                    bottomOrd = ords[bottomSlot];
                }
            }
 public FieldCacheTermsFilterDocIdSet(FieldCacheTermsFilter enclosingInstance, StringIndex fcsi)
 {
     InitBlock(enclosingInstance);
     this.fcsi  = fcsi;
     openBitSet = new OpenBitSet(this.fcsi.lookup.Length);
     foreach (string t in Enclosing_Instance.terms)
     {
         int termNumber = this.fcsi.BinarySearchLookup(t);
         if (termNumber > 0)
         {
             openBitSet.FastSet(termNumber);
         }
     }
 }
 public FieldCacheTermsFilterDocIdSet(FieldCacheTermsFilter enclosingInstance, Lucene.Net.Search.StringIndex fcsi)
 {
     InitBlock(enclosingInstance);
     this.fcsi  = fcsi;
     openBitSet = new OpenBitSet(this.fcsi.lookup.Length);
     for (int i = 0; i < Enclosing_Instance.terms.Length; i++)
     {
         int termNumber = this.fcsi.BinarySearchLookup(Enclosing_Instance.terms[i]);
         if (termNumber > 0)
         {
             openBitSet.FastSet(termNumber);
         }
     }
 }
 public AnonymousClassScoreDocComparator4(Lucene.Net.Search.StringIndex index)
 {
     InitBlock(index);
 }
 internal AnonymousClassFieldCacheDocIdSet(Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, AnonymousClassFieldCacheRangeFilter enclosingInstance, Lucene.Net.Index.IndexReader Param1, bool Param2) : base(Param1, Param2)
 {
     InitBlock(fcsi, inclusiveLowerPoint, inclusiveUpperPoint, enclosingInstance);
 }
Example #9
0
        // inherit javadocs
        public virtual StringIndex GetStringIndex(IndexReader reader, System.String field)
        {
            field = String.Intern(field);
            System.Object ret = Lookup(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX);
            if (ret == null)
            {
                int[]           retArray = new int[reader.MaxDoc()];
                System.String[] mterms   = new System.String[reader.MaxDoc() + 1];
                if (retArray.Length > 0)
                {
                    TermDocs termDocs = reader.TermDocs();
                    TermEnum termEnum = reader.Terms(new Term(field, ""));
                    int      t        = 0;         // current term number

                    // an entry for documents that have no terms in this field
                    // should a document with no terms be at top or bottom?
                    // this puts them at the top - if it is changed, FieldDocSortedHitQueue
                    // needs to change as well.
                    mterms[t++] = null;

                    try
                    {
                        if (termEnum.Term() == null)
                        {
                            throw new System.SystemException("no terms in field " + field);
                        }
                        do
                        {
                            Term term = termEnum.Term();
                            if (term.Field() != field)
                            {
                                break;
                            }

                            // store term text
                            // we expect that there is at most one term per document
                            if (t >= mterms.Length)
                            {
                                throw new System.SystemException("there are more terms than " + "documents in field \"" + field + "\", but it's impossible to sort on " + "tokenized fields");
                            }
                            mterms[t] = term.Text();

                            termDocs.Seek(termEnum);
                            while (termDocs.Next())
                            {
                                retArray[termDocs.Doc()] = t;
                            }

                            t++;
                        }while (termEnum.Next());
                    }
                    finally
                    {
                        termDocs.Close();
                        termEnum.Close();
                    }

                    if (t == 0)
                    {
                        // if there are no terms, make the term array
                        // have a single null entry
                        mterms = new System.String[1];
                    }
                    else if (t < mterms.Length)
                    {
                        // if there are less terms than documents,
                        // trim off the dead array space
                        System.String[] terms = new System.String[t];
                        Array.Copy(mterms, 0, terms, 0, t);
                        mterms = terms;
                    }
                }
                StringIndex value_Renamed = new StringIndex(retArray, mterms);
                Store(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, value_Renamed);
                return(value_Renamed);
            }
            return((StringIndex)ret);
        }
Example #10
0
 public override void  SetNextReader(IndexReader reader, int docBase, IState state)
 {
     idIndex = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, fieldname, null);
 }
Example #11
0
 private void InitBlock(Lucene.Net.Search.StringIndex index)
 {
     this.index = index;
 }
			public FieldCacheTermsFilterDocIdSet(FieldCacheTermsFilter enclosingInstance, StringIndex fcsi)
			{
				InitBlock(enclosingInstance);
				this.fcsi = fcsi;
				openBitSet = new OpenBitSet(this.fcsi.lookup.Length);
				foreach (string t in Enclosing_Instance.terms)
				{
					int termNumber = this.fcsi.BinarySearchLookup(t);
					if (termNumber > 0)
					{
						openBitSet.FastSet(termNumber);
					}
				}
			}
Example #13
0
 private void InitBlock(Lucene.Net.Search.StringIndex fcsi, int inclusiveLowerPoint, int inclusiveUpperPoint, AnonymousClassFieldCacheRangeFilter enclosingInstance)
 {
     this.fcsi = fcsi;
     this.inclusiveLowerPoint = inclusiveLowerPoint;
     this.inclusiveUpperPoint = inclusiveUpperPoint;
     this.enclosingInstance = enclosingInstance;
 }
 public FieldCacheTermsFilterDocIdSet(FieldCacheTermsFilter enclosingInstance, Lucene.Net.Search.StringIndex fcsi)
 {
     InitBlock(enclosingInstance);
     this.fcsi = fcsi;
     openBitSet = new OpenBitSet(this.fcsi.lookup.Length);
     for (int i = 0; i < Enclosing_Instance.terms.Length; i++)
     {
         int termNumber = this.fcsi.BinarySearchLookup(Enclosing_Instance.terms[i]);
         if (termNumber > 0)
         {
             openBitSet.FastSet(termNumber);
         }
     }
 }
 private void  InitBlock(Lucene.Net.Search.StringIndex index)
 {
     this.index = index;
 }
			public override void  SetNextReader(IndexReader reader, int docBase)
			{
				idIndex = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, fieldname);
			}
 /// <summary> Returns a comparator for sorting hits according to a field containing strings.</summary>
 /// <param name="reader"> Index to use.
 /// </param>
 /// <param name="fieldname"> Fieldable containg string values.
 /// </param>
 /// <returns>  Comparator for sorting hits.
 /// </returns>
 /// <throws>  IOException If an error occurs reading the index. </throws>
 internal static ScoreDocComparator ComparatorString(IndexReader reader, System.String fieldname)
 {
     System.String field = String.Intern(fieldname);
     Lucene.Net.Search.StringIndex index = Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetStringIndex(reader, field);
     return(new AnonymousClassScoreDocComparator4(index));
 }
Example #18
0
		// inherit javadocs
		public virtual StringIndex GetStringIndex(IndexReader reader, System.String field)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX);
			if (ret == null)
			{
				int[] retArray = new int[reader.MaxDoc()];
				System.String[] mterms = new System.String[reader.MaxDoc() + 1];
				if (retArray.Length > 0)
				{
					TermDocs termDocs = reader.TermDocs();
					TermEnum termEnum = reader.Terms(new Term(field, ""));
					int t = 0; // current term number
					
					// an entry for documents that have no terms in this field
					// should a document with no terms be at top or bottom?
					// this puts them at the top - if it is changed, FieldDocSortedHitQueue
					// needs to change as well.
					mterms[t++] = null;
					
					try
					{
						if (termEnum.Term() == null)
						{
							throw new System.SystemException("no terms in field " + field);
						}
						do 
						{
							Term term = termEnum.Term();
							if (term.Field() != field)
								break;
							
							// store term text
							// we expect that there is at most one term per document
							if (t >= mterms.Length)
								throw new System.SystemException("there are more terms than " + "documents in field \"" + field + "\", but it's impossible to sort on " + "tokenized fields");
							mterms[t] = term.Text();
							
							termDocs.Seek(termEnum);
							while (termDocs.Next())
							{
								retArray[termDocs.Doc()] = t;
							}
							
							t++;
						}
						while (termEnum.Next());
					}
					finally
					{
						termDocs.Close();
						termEnum.Close();
					}
					
					if (t == 0)
					{
						// if there are no terms, make the term array
						// have a single null entry
						mterms = new System.String[1];
					}
					else if (t < mterms.Length)
					{
						// if there are less terms than documents,
						// trim off the dead array space
						System.String[] terms = new System.String[t];
						Array.Copy(mterms, 0, terms, 0, t);
						mterms = terms;
					}
				}
				StringIndex value_Renamed = new StringIndex(retArray, mterms);
				Store(reader, field, Lucene.Net.Search.FieldCache_Fields.STRING_INDEX, value_Renamed);
				return value_Renamed;
			}
			return (StringIndex) ret;
		}