Exemplo n.º 1
0
            protected internal override System.Object CreateValue(IndexReader reader, Entry entryKey)
            {
                Entry entry = (Entry)entryKey;

                System.String  field      = entry.field;
                SortComparator comparator = (SortComparator)entry.custom;

                System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
                TermDocs             termDocs = reader.TermDocs();
                TermEnum             termEnum = reader.Terms(new Term(field));

                try
                {
                    do
                    {
                        Term term = termEnum.Term();
                        if (term == null || (System.Object)term.Field() != (System.Object)field)
                        {
                            break;
                        }
                        System.IComparable termval = comparator.GetComparable(term.Text());
                        termDocs.Seek(termEnum);
                        while (termDocs.Next())
                        {
                            retArray[termDocs.Doc()] = termval;
                        }
                    }while (termEnum.Next());
                }
                finally
                {
                    termDocs.Close();
                    termEnum.Close();
                }
                return(retArray);
            }
Exemplo n.º 2
0
        public virtual void  TestCustomSorts()
        {
            sort.SetSort(new SortField("custom", SampleComparable.ComparatorSource));
            AssertMatches(full, queryX, sort, "CAIEG");
            sort.SetSort(new SortField("custom", SampleComparable.ComparatorSource, true));
            AssertMatches(full, queryY, sort, "HJDBF");
            SortComparator custom = SampleComparable.Comparator;

            sort.SetSort(new SortField("custom", custom));
            AssertMatches(full, queryX, sort, "CAIEG");
            sort.SetSort(new SortField("custom", custom, true));
            AssertMatches(full, queryY, sort, "HJDBF");
        }
Exemplo n.º 3
0
        public virtual void  TestRemoteCustomSort()
        {
            Lucene.Net.Search.Searchable searcher = Remote;
            MultiSearcher multi = new MultiSearcher(new Lucene.Net.Search.Searchable[] { searcher });

            sort.SetSort(new SortField("custom", SampleComparable.ComparatorSource));
            AssertMatches(multi, queryX, sort, "CAIEG");
            sort.SetSort(new SortField("custom", SampleComparable.ComparatorSource, true));
            AssertMatches(multi, queryY, sort, "HJDBF");
            SortComparator custom = SampleComparable.Comparator;

            sort.SetSort(new SortField("custom", custom));
            AssertMatches(multi, queryX, sort, "CAIEG");
            sort.SetSort(new SortField("custom", custom, true));
            AssertMatches(multi, queryY, sort, "HJDBF");
        }
Exemplo n.º 4
0
 private void  InitBlock(System.IComparable[] cachedValues, SortComparator enclosingInstance)
 {
     this.cachedValues      = cachedValues;
     this.enclosingInstance = enclosingInstance;
 }
Exemplo n.º 5
0
 public AnonymousClassScoreDocComparator(System.IComparable[] cachedValues, SortComparator enclosingInstance)
 {
     InitBlock(cachedValues, enclosingInstance);
 }
Exemplo n.º 6
0
 public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
 {
     return((System.IComparable[])((Cache)caches[typeof(System.IComparable)]).Get(reader, new Entry(field, comparator)));
 }
Exemplo n.º 7
0
 // inherit javadocs
 public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
 {
     field = String.Intern(field);
     System.Object ret = Lookup(reader, field, comparator);
     if (ret == null)
     {
         System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
         if (retArray.Length > 0)
         {
             TermDocs termDocs = reader.TermDocs();
             TermEnum termEnum = reader.Terms(new Term(field, ""));
             try
             {
                 if (termEnum.Term() == null)
                 {
                     throw new System.SystemException("no terms in field " + field);
                 }
                 do
                 {
                     Term term = termEnum.Term();
                     if (term.Field() != field)
                     {
                         break;
                     }
                     System.IComparable termval = comparator.GetComparable(term.Text());
                     termDocs.Seek(termEnum);
                     while (termDocs.Next())
                     {
                         retArray[termDocs.Doc()] = termval;
                     }
                 }while (termEnum.Next());
             }
             finally
             {
                 termDocs.Close();
                 termEnum.Close();
             }
         }
         Store(reader, field, comparator, retArray);
         return(retArray);
     }
     return((System.IComparable[])ret);
 }
Exemplo n.º 8
0
			private void  InitBlock(System.IComparable[] cachedValues, SortComparator enclosingInstance)
			{
				this.cachedValues = cachedValues;
				this.enclosingInstance = enclosingInstance;
			}
Exemplo n.º 9
0
			public AnonymousClassScoreDocComparator(System.IComparable[] cachedValues, SortComparator enclosingInstance)
			{
				InitBlock(cachedValues, enclosingInstance);
			}
Exemplo n.º 10
0
 public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
 {
     return (System.IComparable[]) ((Cache) caches[typeof(System.IComparable)]).Get(reader, new Entry(field, comparator));
 }
Exemplo n.º 11
0
 // inherit javadocs
 public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
 {
     return((System.IComparable[])customCache.Get(reader, new Entry(field, comparator)));
 }
Exemplo n.º 12
0
		// inherit javadocs
		public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
		{
			return (System.IComparable[]) customCache.Get(reader, new Entry(field, comparator));
		}
Exemplo n.º 13
0
		// inherit javadocs
		public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator)
		{
			field = String.Intern(field);
			System.Object ret = Lookup(reader, field, comparator);
			if (ret == null)
			{
				System.IComparable[] retArray = new System.IComparable[reader.MaxDoc()];
				if (retArray.Length > 0)
				{
					TermDocs termDocs = reader.TermDocs();
					TermEnum termEnum = reader.Terms(new Term(field, ""));
					try
					{
						if (termEnum.Term() == null)
						{
							throw new System.SystemException("no terms in field " + field);
						}
						do 
						{
							Term term = termEnum.Term();
							if (term.Field() != field)
								break;
							System.IComparable termval = comparator.GetComparable(term.Text());
							termDocs.Seek(termEnum);
							while (termDocs.Next())
							{
								retArray[termDocs.Doc()] = termval;
							}
						}
						while (termEnum.Next());
					}
					finally
					{
						termDocs.Close();
						termEnum.Close();
					}
				}
				Store(reader, field, comparator, retArray);
				return retArray;
			}
			return (System.IComparable[]) ret;
		}