I don't understand that. If you need an empty iterator, call:

 

DocIdSet.EMPTY_DOCIDSET.iterator()

 

- bingo. This is always empty.

 

Uwe

 

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
 <http://www.thetaphi.de> http://www.thetaphi.de
eMail: u...@thetaphi.de

  _____  

From: Shai Erera [mailto:ser...@gmail.com] 
Sent: Monday, July 27, 2009 12:29 PM
To: java-dev@lucene.apache.org
Subject: Re: svn commit: r798091 -
/lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.j
ava

 

I don't see this class in DISI. I created it for classes that get a null
iterator, but need to have some iterator to work w/, so now they can use
EmptyDISI.

It not like DocIdSet.EMPTY_DOCIDSET. While the latter allows an impl to
return EMPTY as its DocIdSet, the EmptyDISI is for instantiation by code
which received a null iterator. Sometimes the iterator will be null, and the
DocIdSet itself won't "know" that until its iterator() is called. Also,
instead of fixing all Filter impls to check if the DIS's iterator will be
null then return DIS.EMPTY, I think this is a useful class in and on itself.

Shai

On Mon, Jul 27, 2009 at 1:18 PM, Uwe Schindler <u...@thetaphi.de> wrote:

Why do we need this class? There is already a static final empty iterator
available in DocIdSetIterator.EMPTY_DOCIDSET_ITERATOR (or something like
that name)?

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de

> From: mikemcc...@apache.org [mailto:mikemcc...@apache.org]
> Sent: Monday, July 27, 2009 12:03 PM
> To: java-comm...@lucene.apache.org
> Subject: svn commit: r798091 -
> /lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator
> .java
>
> Author: mikemccand
> Date: Mon Jul 27 10:02:34 2009
> New Revision: 798091
>
> URL: http://svn.apache.org/viewvc?rev=798091
<http://svn.apache.org/viewvc?rev=798091&view=rev> &view=rev
> Log:
> LUCENE-1754: add EmptyDocIdSetIterator
>
> Added:
>
> lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.
> java   (with props)
>
> Added:
> lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.
> java
> URL:
> http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/
> search/EmptyDocIdSetIterator.java?rev=798091&view=auto
> ==========================================================================
> ====
> ---
> lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.
> java (added)
> +++
> lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.
> java Mon Jul 27 10:02:34 2009
> @@ -0,0 +1,42 @@
> +package org.apache.lucene.search;
> +
> +/**
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +import java.io.IOException;
> +
> +/**
> + * An empty implementation for {...@link DocIdSetIterator}. This can be used
> by
> + * classes which receive a null {...@link DocIdSet} from
> + * {...@link Filter#getDocIdSet(org.apache.lucene.index.IndexReader)}.
> + */
> +public final class EmptyDocIdSetIterator extends DocIdSetIterator {
> +
> +  private static final DocIdSetIterator instance = new
> EmptyDocIdSetIterator();
> +
> +  public static DocIdSetIterator getInstance() { return instance; }
> +
> +  // to prevent instantiation
> +  private EmptyDocIdSetIterator() { }
> +
> +  public int advance(int target) throws IOException { return
> NO_MORE_DOCS; }
> +
> +  public int docID() { return NO_MORE_DOCS; }
> +
> +  public int nextDoc() throws IOException { return NO_MORE_DOCS; }
> +
> +}
>
> Propchange:
> lucene/java/trunk/src/java/org/apache/lucene/search/EmptyDocIdSetIterator.
> java
> --------------------------------------------------------------------------
> ----
>     svn:eol-style = native
>



---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

 

Reply via email to