예제 #1
0
        private void  Remove(HitDoc hitDoc)
        {
            // remove from cache
            if (hitDoc.doc == null)
            {
                // it's not in the list
                return;                  // abort
            }

            if (hitDoc.next == null)
            {
                last = hitDoc.prev;
            }
            else
            {
                hitDoc.next.prev = hitDoc.prev;
            }

            if (hitDoc.prev == null)
            {
                first = hitDoc.next;
            }
            else
            {
                hitDoc.prev.next = hitDoc.next;
            }

            numDocs--;
        }
예제 #2
0
        /// <summary>Returns the stored fields of the n<sup>th</sup> document in this set.
        /// <p>Documents are cached, so that repeated requests for the same element may
        /// return the same Document object. If the fieldselector is changed, then the new
        /// fields will not be loaded.
        /// </summary>
        public Document Doc(int n, FieldSelector fieldSelector)
        {
            HitDoc hitDoc = HitDoc(n);

            // Update LRU cache of documents
            Remove(hitDoc);             // remove from list, if there
            AddToFront(hitDoc);         // add to front of list
            if (numDocs > maxDocs)
            {
                // if cache is full
                HitDoc oldLast = last;
                Remove(last);                 // flush last
                oldLast.doc = null;           // let doc get gc'd
            }

            if (hitDoc.doc == null)
            {
                if (fieldSelector == null)
                {
                    hitDoc.doc = searcher.Doc(hitDoc.id);                     // cache miss: read document
                }
                else
                {
                    hitDoc.doc = searcher.Doc(hitDoc.id, fieldSelector);                     // cache miss: read document
                }
            }

            return(hitDoc.doc);
        }
예제 #3
0
        private void  AddToFront(HitDoc hitDoc)
        {
            // insert at front of cache
            if (first == null)
            {
                last = hitDoc;
            }
            else
            {
                first.prev = hitDoc;
            }

            hitDoc.next = first;
            first       = hitDoc;
            hitDoc.prev = null;

            numDocs++;
        }
예제 #4
0
		private void  Remove(HitDoc hitDoc)
		{
			// remove from cache
			if (hitDoc.doc == null)
			{
				// it's not in the list
				return ; // abort
			}
			
			if (hitDoc.next == null)
			{
				last = hitDoc.prev;
			}
			else
			{
				hitDoc.next.prev = hitDoc.prev;
			}
			
			if (hitDoc.prev == null)
			{
				first = hitDoc.next;
			}
			else
			{
				hitDoc.prev.next = hitDoc.next;
			}
			
			numDocs--;
		}
예제 #5
0
		private void  AddToFront(HitDoc hitDoc)
		{
			// insert at front of cache
			if (first == null)
			{
				last = hitDoc;
			}
			else
			{
				first.prev = hitDoc;
			}
			
			hitDoc.next = first;
			first = hitDoc;
			hitDoc.prev = null;
			
			numDocs++;
		}
예제 #6
0
        /// <summary>Returns the requested fields of the n<sup>th</sup> document in this set.
        /// <p>Documents are not cached since they could be fetched using different set of fields.
        /// </summary>
        public Document Doc(int n, string[] fields)
        {
            HitDoc hitDoc = HitDoc(n);

            return(searcher.Doc(hitDoc.id, fields));
        }