lucene-core-2.9.4-dev

eption
    {
      List required = new ArrayList();
      List prohibited = new ArrayList();
      List optional = new ArrayList();
      Iterator wIter = weights.iterator();
      for (Iterator cIter = clauses.iterator(); wIter.hasNext();)
      {
        Weight w = (Weight)wIter.next();
        BooleanClause c = (BooleanClause)cIter.next();
        Scorer subScorer = w.scorer(reader, true, false);
        if (subScorer == null)
        {
          if (c.isRequired()) {
            return null;
          }
        }
        else if (c.isRequired()) {
          required.add(subScorer);
        } else if (c.isProhibited()) {
          prohibited.add(subScorer);
        } else {
          optional.add(subScorer);
        }
      }
      scoreDocsInOrder |= !BooleanQuery.allowDocsOutOfOrder;
      if ((!scoreDocsInOrder) && (topScorer) && (required.size() == 0) && (prohibited.size() < 32)) {
        return new BooleanScorer(similarity, minNrShouldMatch, optional, prohibited);
      }
      if ((required.size() == 0) && (optional.size() == 0)) {
        return null;
      }
      if (optional.size() < minNrShouldMatch) {
        return null;
      }
      return new BooleanScorer2(similarity, minNrShouldMatch, required, prohibited, optional);
    }
    
    public boolean scoresDocsOutOfOrder()
    {
      int numProhibited = 0;
      for (Iterator cIter = clauses.iterator(); cIter.hasNext();)
      {
        BooleanClause c = (BooleanClause)cIter.next();
        if (c.isRequired()) {
          return false;
        }
        if (c.isProhibited()) {
          numProhibited++;
        }
      }
      if (numProhibited > 32) {
        return false;
      }
      return true;
    }
  }
  
  /**
   * @deprecated
   */
  private static boolean allowDocsOutOfOrder = true;
  
  /**
   * @deprecated
   */
  public static void setAllowDocsOutOfOrder(boolean allow)
  {
    allowDocsOutOfOrder = allow;
  }
  
  /**
   * @deprecated
   */
  public static boolean getAllowDocsOutOfOrder()
  {
    return allowDocsOutOfOrder;
  }
  
  /**
   * @deprecated
   */
  public static void setUseScorer14(boolean use14)
  {
    setAllowDocsOutOfOrder(use14);
  }
  
  /**
   * @deprecated
   */
  public static boolean getUseScorer14()
  {
    return getAllowDocsOutOfOrder();
  }
  
  public Weight createWeight(Searcher searcher)
    throws IOException
  {
    return new BooleanWeight(searcher);
  }
  
  public Query rewrite(IndexReader reader)
    throws IOException
  {
    if ((minNrShouldMatch == 0) && (clauses.size() == 1))
    {
      BooleanClause c = (BooleanClause)clauses.get(0);
      if (!c.isProhibited())
      {
        Query query = c.getQuery().rewrite(reader);
        if (getBoost() != 1.0F)
        {
          if (query == c.getQuery()) {
            query = (Query)query.clone();
          }
          query.setBoost(getBoost() * query.getBoost());
        }
        return query;
      }
    }
    BooleanQuery clone = null;
    for (int i = 0; i < clauses.size(); i++)
    {
      BooleanClause c = (BooleanClause)clauses.get(i);
      Query query = c.getQuery().rewrite(reader);
      if (query != c.getQuery())
      {
        if (clone == null) {
          clone = (BooleanQuery)clone();
        }
        clauses.set(i, new BooleanClause(query, c.getOccur()));
      }
    }
    if (clone != null) {
      return clone;
    }
    return this;
  }
  
  public void extractTerms(Set terms)
  {
    for (Iterator i = clauses.iterator(); i.hasNext();)
    {
      BooleanClause clause = (BooleanClause)i.next();
      clause.getQuery().extractTerms(terms);
    }
  }
  
  public Object clone()
  {
    BooleanQuery clone = (BooleanQuery)super.clone();
    clauses = ((ArrayList)clauses.clone());
    return clone;
  }
  
  public String toString(String field)
  {
    StringBuffer buffer = new StringBuffer();
    boolean needParens = (getBoost() != 1.0D) || (getMinimumNumberShouldMatch() > 0);
    if (needParens) {
      buffer.append("(");
    }
    for (int i = 0; i < clauses.size(); i++)
    {
      BooleanClause c = (BooleanClause)clauses.get(i);
      if (c.isProhibited()) {
        buffer.append("-");
      } else if (c.isRequired()) {
        buffer.append("+");
      }
      Query subQuery = c.getQuery();
      if (subQuery != null)
      {
        if ((subQuery instanceof BooleanQuery))
        {
          buffer.append("(");
          buffer.append(subQuery.toString(field));
          buffer.append(")");
        }
        else
        {
          buffer.append(subQuery.toString(field));
        }
      }
      else {
        buffer.append("null");
      }
      if (i != clauses.size() - 1) {
        buffer.append(" ");
      }
    }
    if (needParens) {
      buffer.append(")");
    }
    if (getMinimumNumberShouldMatch() > 0)
    {
      buffer.append('~');
      buffer.append(getMinimumNumberShouldMatch());
    }
    if (getBoost() != 1.0F) {
      buffer.append(ToStringUtils.boost(getBoost()));
    }
    return buffer.toString();
  }
  
  public boolean equals(Object o)
  {
    if (!(o instanceof BooleanQuery)) {
      return false;
    }
    BooleanQuery other = (BooleanQuery)o;
    return (getBoost() == other.getBoost()) && (clauses.equals(clauses)) && (getMinimumNumberShouldMatch() == other.getMinimumNumberShouldMatch()) && (disableCoord == disableCoord);
  }
  
  public int hashCode()
  {
    return Float.floatToIntBits(getBoost()) ^ clauses.hashCode() + getMinimumNumberShouldMatch() + (disableCoord ? 17 : 0);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanQuery
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import org.apache.lucene.index.IndexReader;

final class BooleanScorer$BooleanScorerCollector
  extends Collector
{
  private BooleanScorer.BucketTable bucketTable;
  private int mask;
  private Scorer scorer;
  
  public BooleanScorer$BooleanScorerCollector(int mask, BooleanScorer.BucketTable bucketTable)
  {
    this.mask = mask;
    this.bucketTable = bucketTable;
  }
  
  public final void collect(int doc)
    throws IOException
  {
    BooleanScorer.BucketTable table = bucketTable;
    int i = doc & 0x7FF;
    BooleanScorer.Bucket bucket = buckets[i];
    if (bucket == null) {
      buckets[i] = (bucket = new BooleanScorer.Bucket());
    }
    if (doc != doc)
    {
      doc = doc;
      score = scorer.score();
      bits = mask;
      coord = 1;
      
      next = first;
      first = bucket;
    }
    else
    {
      score += scorer.score();
      bits |= mask;
      coord += 1;
    }
  }
  
  public void setNextReader(IndexReader reader, int docBase) {}
  
  public void setScorer(Scorer scorer)
    throws IOException
  {
    this.scorer = scorer;
  }
  
  public boolean acceptsDocsOutOfOrder()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer.BooleanScorerCollector
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

final class BooleanScorer$Bucket
{
  int doc = -1;
  float score;
  int bits;
  int coord;
  Bucket next;
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer.Bucket
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;

final class BooleanScorer$BucketScorer
  extends Scorer
{
  float score;
  int doc = Integer.MAX_VALUE;
  
  public BooleanScorer$BucketScorer()
  {
    super(null);
  }
  
  public int advance(int target)
    throws IOException
  {
    return Integer.MAX_VALUE;
  }
  
  /**
   * @deprecated
   */
  public int doc()
  {
    return doc;
  }
  
  public int docID()
  {
    return doc;
  }
  
  public Explanation explain(int doc)
    throws IOException
  {
    return null;
  }
  
  /**
   * @deprecated
   */
  public boolean next()
    throws IOException
  {
    return false;
  }
  
  public int nextDoc()
    throws IOException
  {
    return Integer.MAX_VALUE;
  }
  
  public float score()
    throws IOException
  {
    return score;
  }
  
  /**
   * @deprecated
   */
  public boolean skipTo(int target)
    throws IOException
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer.BucketScorer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

final class BooleanScorer$BucketTable
{
  public static final int SIZE = 2048;
  public static final int MASK = 2047;
  final BooleanScorer.Bucket[] buckets = new BooleanScorer.Bucket['?'];
  BooleanScorer.Bucket first = null;
  
  public Collector newCollector(int mask)
  {
    return new BooleanScorer.BooleanScorerCollector(mask, this);
  }
  
  public final int size()
  {
    return 2048;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer.BucketTable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;

final class BooleanScorer$SubScorer
{
  public Scorer scorer;
  public boolean required = false;
  public boolean prohibited = false;
  public Collector collector;
  public SubScorer next;
  
  public BooleanScorer$SubScorer(Scorer scorer, boolean required, boolean prohibited, Collector collector, SubScorer next)
    throws IOException
  {
    this.scorer = scorer;
    this.required = required;
    this.prohibited = prohibited;
    this.collector = collector;
    this.next = next;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer.SubScorer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.apache.lucene.index.IndexReader;

final class BooleanScorer
  extends Scorer
{
  private static final class BooleanScorerCollector
    extends Collector
  {
    private BooleanScorer.BucketTable bucketTable;
    private int mask;
    private Scorer scorer;
    
    public BooleanScorerCollector(int mask, BooleanScorer.BucketTable bucketTable)
    {
      this.mask = mask;
      this.bucketTable = bucketTable;
    }
    
    public final void collect(int doc)
      throws IOException
    {
      BooleanScorer.BucketTable table = bucketTable;
      int i = doc & 0x7FF;
      BooleanScorer.Bucket bucket = buckets[i];
      if (bucket == null) {
        buckets[i] = (bucket = new BooleanScorer.Bucket());
      }
      if (doc != doc)
      {
        doc = doc;
        score = scorer.score();
        bits = mask;
        coord = 1;
        
        next = first;
        first = bucket;
      }
      else
      {
        score += scorer.score();
        bits |= mask;
        coord += 1;
      }
    }
    
    public void setNextReader(IndexReader reader, int docBase) {}
    
    public void setScorer(Scorer scorer)
      throws IOException
    {
      this.scorer = scorer;
    }
    
    public boolean acceptsDocsOutOfOrder()
    {
      return true;
    }
  }
  
  private static final class BucketScorer
    extends Scorer
  {
    float score;
    int doc = Integer.MAX_VALUE;
    
    public BucketScorer()
    {
      super();
    }
    
    public int advance(int target)
      throws IOException
    {
      return Integer.MAX_VALUE;
    }
    
    /**
     * @deprecated
     */
    public int doc()
    {
      return doc;
    }
    
    public int docID()
    {
      return doc;
    }
    
    public Explanation explain(int doc)
      throws IOException
    {
      return null;
    }
    
    /**
     * @deprecated
     */
    public boolean next()
      throws IOException
    {
      return false;
    }
    
    public int nextDoc()
      throws IOException
    {
      return Integer.MAX_VALUE;
    }
    
    public float score()
      throws IOException
    {
      return score;
    }
    
    /**
     * @deprecated
     */
    public boolean skipTo(int target)
      throws IOException
    {
      return false;
    }
  }
  
  static final class Bucket
  {
    int doc = -1;
    float score;
    int bits;
    int coord;
    Bucket next;
  }
  
  static final class BucketTable
  {
    public static final int SIZE = 2048;
    public static final int MASK = 2047;
    final BooleanScorer.Bucket[] buckets = new BooleanScorer.Bucket['?'];
    BooleanScorer.Bucket first = null;
    
    public Collector newCollector(int mask)
    {
      return new BooleanScorer.BooleanScorerCollector(mask, this);
    }
    
    public final int size()
    {
      return 2048;
    }
  }
  
  static final class SubScorer
  {
    public Scorer scorer;
    public boolean required = false;
    public boolean prohibited = false;
    public Collector collector;
    public SubScorer next;
    
    public SubScorer(Scorer scorer, boolean required, boolean prohibited, Collector collector, SubScorer next)
      throws IOException
    {
      this.scorer = scorer;
      this.required = required;
      this.prohibited = prohibited;
      this.collector = collector;
      this.next = next;
    }
  }
  
  private SubScorer scorers = null;
  private BucketTable bucketTable = new BucketTable();
  private int maxCoord = 1;
  private final float[] coordFactors;
  private int requiredMask = 0;
  private int prohibitedMask = 0;
  private int nextMask = 1;
  private final int minNrShouldMatch;
  private int end;
  private Bucket current;
  private int doc = -1;
  
  BooleanScorer(Similarity similarity, int minNrShouldMatch, List optionalScorers, List prohibitedScorers)
    throws IOException
  {
    super(similarity);
    this.minNrShouldMatch = minNrShouldMatch;
    Iterator si;
    if ((optionalScorers != null) && (optionalScorers.size() > 0)) {
      for (si = optionalScorers.iterator(); si.hasNext();)
      {
        Scorer scorer = (Scorer)si.next();
        maxCoord += 1;
        if (scorer.nextDoc() != Integer.MAX_VALUE) {
          scorers = new SubScorer(scorer, false, false, bucketTable.newCollector(0), scorers);
        }
      }
    }
    Iterator si;
    if ((prohibitedScorers != null) && (prohibitedScorers.size() > 0)) {
      for (si = prohibitedScorers.iterator(); si.hasNext();)
      {
        Scorer scorer = (Scorer)si.next();
        int mask = nextMask;
        nextMask <<= 1;
        prohibitedMask |= mask;
        if (scorer.nextDoc() != Integer.MAX_VALUE) {
          scorers = new SubScorer(scorer, false, true, bucketTable.newCollector(mask), scorers);
        }
      }
    }
    coordFactors = new float[maxCoord];
    Similarity sim = getSimilarity();
    for (int i = 0; i < maxCoord; i++) {
      coordFactors[i] = sim.coord(i, maxCoord - 1);
    }
  }
  
  protected boolean score(Collector collector, int max, int firstDocID)
    throws IOException
  {
    BucketScorer bs = new BucketScorer();
    
    collector.setScorer(bs);
    boolean more;
    do
    {
      bucketTable.first = null;
      while (current != null)
      {
        if (((current.bits & prohibitedMask) == 0) && ((current.bits & requiredMask) == requiredMask))
        {
          if (current.doc >= max)
          {
            Bucket tmp = current;
            current = current.next;
            next = bucketTable.first;
            bucketTable.first = tmp;
            continue;
          }
          if (current.coord >= minNrShouldMatch)
          {
            score = (current.score * coordFactors[current.coord]);
            doc = current.doc;
            collector.collect(current.doc);
          }
        }
        current = current.next;
      }
      if (bucketTable.first != null)
      {
        current = bucketTable.first;
        bucketTable.first = current.next;
        return true;
      }
      more = false;
      end += 2048;
      for (SubScorer sub = scorers; sub != null; sub = next)
      {
        int subScorerDocID = scorer.docID();
        if (subScorerDocID != Integer.MAX_VALUE) {
          more |= scorer.score(collector, end, subScorerDocID);
        }
      }
      current = bucketTable.first;
    } while ((current != null) || (more));
    return false;
  }
  
  /**
   * @deprecated
   */
  protected boolean score(HitCollector hc, int max)
    throws IOException
  {
    return score(new HitCollectorWrapper(hc), max, docID());
  }
  
  public int advance(int target)
    throws IOException
  {
    throw new UnsupportedOperationException();
  }
  
  /**
   * @deprecated
   */
  public int doc()
  {
    return current.doc;
  }
  
  public int docID()
  {
    return doc;
  }
  
  public Explanation explain(int doc)
  {
    throw new UnsupportedOperationException();
  }
  
  /**
   * @deprecated
   */
  public boolean next()
    throws IOException
  {
    return nextDoc() != Integer.MAX_VALUE;
  }
  
  public int nextDoc()
    throws IOException
  {
    boolean more;
    do
    {
      while (bucketTable.first != null)
      {
        current = bucketTable.first;
        bucketTable.first = current.next;
        if (((current.bits & prohibitedMask) == 0) && ((current.bits & requiredMask) == requiredMask) && (current.coord >= minNrShouldMatch)) {
          return this.doc = current.doc;
        }
      }
      more = false;
      end += 2048;
      for (SubScorer sub = scorers; sub != null; sub = next)
      {
        Scorer scorer = scorer;
        collector.setScorer(scorer);
        int doc = scorer.docID();
        while (doc < end)
        {
          collector.collect(doc);
          doc = scorer.nextDoc();
        }
        more |= doc != Integer.MAX_VALUE;
      }
    } while ((bucketTable.first != null) || (more));
    return this.doc = Integer.MAX_VALUE;
  }
  
  public float score()
  {
    return current.score * coordFactors[current.coord];
  }
  
  public void score(Collector collector)
    throws IOException
  {
    score(collector, Integer.MAX_VALUE, nextDoc());
  }
  
  /**
   * @deprecated
   */
  public void score(HitCollector hc)
    throws IOException
  {
    score(new HitCollectorWrapper(hc));
  }
  
  /**
   * @deprecated
   */
  public boolean skipTo(int target)
  {
    throw new UnsupportedOperationException();
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("boolean(");
    for (SubScorer sub = scorers; sub != null; sub = next)
    {
      buffer.append(scorer.toString());
      buffer.append(" ");
    }
    buffer.append(")");
    return buffer.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.util.List;

class BooleanScorer2$1
  extends DisjunctionSumScorer
{
  BooleanScorer2$1(BooleanScorer2 paramBooleanScorer2, List x0, int x1)
  {
    super(x0, x1);
  }
  
  private int lastScoredDoc = -1;
  private float lastDocScore = NaN.0F;
  private final BooleanScorer2 this$0;
  
  public float score()
    throws IOException
  {
    int doc = docID();
    if (doc >= lastScoredDoc)
    {
      if (doc > lastScoredDoc)
      {
        lastDocScore = super.score();
        lastScoredDoc = doc;
      }
      access$100this$0).nrMatchers += nrMatchers;
    }
    return lastDocScore;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer2.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.util.Collection;

class BooleanScorer2$2
  extends ConjunctionScorer
{
  BooleanScorer2$2(BooleanScorer2 paramBooleanScorer2, Similarity x0, Collection x1, int paramInt)
  {
    super(x0, x1);
  }
  
  private int lastScoredDoc = -1;
  private float lastDocScore = NaN.0F;
  private final BooleanScorer2 this$0;
  
  public float score()
    throws IOException
  {
    int doc = docID();
    if (doc >= lastScoredDoc)
    {
      if (doc > lastScoredDoc)
      {
        lastDocScore = super.score();
        lastScoredDoc = doc;
      }
      access$100this$0).nrMatchers += val$requiredNrMatchers;
    }
    return lastDocScore;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer2.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

class BooleanScorer2$Coordinator
{
  BooleanScorer2$Coordinator(BooleanScorer2 x0, BooleanScorer2.1 x1)
  {
    this(x0);
  }
  
  float[] coordFactors = null;
  int maxCoord = 0;
  int nrMatchers;
  private final BooleanScorer2 this$0;
  
  void init()
  {
    coordFactors = new float[maxCoord + 1];
    Similarity sim = this$0.getSimilarity();
    for (int i = 0; i <= maxCoord; i++) {
      coordFactors[i] = sim.coord(i, maxCoord);
    }
  }
  
  private BooleanScorer2$Coordinator(BooleanScorer2 paramBooleanScorer2) {}
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer2.Coordinator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;

class BooleanScorer2$SingleMatchScorer
  extends Scorer
{
  private Scorer scorer;
  private int lastScoredDoc = -1;
  private float lastDocScore = NaN.0F;
  private final BooleanScorer2 this$0;
  
  BooleanScorer2$SingleMatchScorer(BooleanScorer2 paramBooleanScorer2, Scorer scorer)
  {
    super(scorer.getSimilarity());
    this.scorer = scorer;
  }
  
  public float score()
    throws IOException
  {
    int doc = docID();
    if (doc >= lastScoredDoc)
    {
      if (doc > lastScoredDoc)
      {
        lastDocScore = scorer.score();
        lastScoredDoc = doc;
      }
      access$100this$0).nrMatchers += 1;
    }
    return lastDocScore;
  }
  
  /**
   * @deprecated
   */
  public int doc()
  {
    return scorer.doc();
  }
  
  public int docID()
  {
    return scorer.docID();
  }
  
  /**
   * @deprecated
   */
  public boolean next()
    throws IOException
  {
    return scorer.nextDoc() != Integer.MAX_VALUE;
  }
  
  public int nextDoc()
    throws IOException
  {
    return scorer.nextDoc();
  }
  
  /**
   * @deprecated
   */
  public boolean skipTo(int docNr)
    throws IOException
  {
    return scorer.advance(docNr) != Integer.MAX_VALUE;
  }
  
  public int advance(int target)
    throws IOException
  {
    return scorer.advance(target);
  }
  
  public Explanation explain(int docNr)
    throws IOException
  {
    return scorer.explain(docNr);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer2.SingleMatchScorer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

class BooleanScorer2
  extends Scorer
{
  private final List requiredScorers;
  private final List optionalScorers;
  private final List prohibitedScorers;
  private final Coordinator coordinator;
  private final Scorer countingSumScorer;
  private final int minNrShouldMatch;
  
  private class Coordinator
  {
    Coordinator(BooleanScorer2.1 x1)
    {
      this();
    }
    
    float[] coordFactors = null;
    int maxCoord = 0;
    int nrMatchers;
    
    void init()
    {
      coordFactors = new float[maxCoord + 1];
      Similarity sim = getSimilarity();
      for (int i = 0; i <= maxCoord; i++) {
        coordFactors[i] = sim.coord(i, maxCoord);
      }
    }
    
    private Coordinator() {}
  }
  
  private int doc = -1;
  
  public BooleanScorer2(Similarity similarity, int minNrShouldMatch, List required, List prohibited, List optional)
    throws IOException
  {
    super(similarity);
    if (minNrShouldMatch < 0) {
      throw new IllegalArgumentException("Minimum number of optional scorers should not be negative");
    }
    coordinator = new Coordinator(null);
    this.minNrShouldMatch = minNrShouldMatch;
    
    optionalScorers = optional;
    coordinator.maxCoord += optional.size();
    
    requiredScorers = required;
    coordinator.maxCoord += required.size();
    
    prohibitedScorers = prohibited;
    
    coordinator.init();
    countingSumScorer = makeCountingSumScorer();
  }
  
  private class SingleMatchScorer
    extends Scorer
  {
    private Scorer scorer;
    private int lastScoredDoc = -1;
    private float lastDocScore = NaN.0F;
    
    SingleMatchScorer(Scorer scorer)
    {
      super();
      this.scorer = scorer;
    }
    
    public float score()
      throws IOException
    {
      int doc = docID();
      if (doc >= lastScoredDoc)
      {
        if (doc > lastScoredDoc)
        {
          lastDocScore = scorer.score();
          lastScoredDoc = doc;
        }
        coordinator.nrMatchers += 1;
      }
      return lastDocScore;
    }
    
    /**
     * @deprecated
     */
    public int doc()
    {
      return scorer.doc();
    }
    
    public int docID()
    {
      return scorer.docID();
    }
    
    /**
     * @deprecated
     */
    public boolean next()
      throws IOException
    {
      return scorer.nextDoc() != Integer.MAX_VALUE;
    }
    
    public int nextDoc()
      throws IOException
    {
      return scorer.nextDoc();
    }
    
    /**
     * @deprecated
     */
    public boolean skipTo(int docNr)
      throws IOException
    {
      return scorer.advance(docNr) != Integer.MAX_VALUE;
    }
    
    public int advance(int target)
      throws IOException
    {
      return scorer.advance(target);
    }
    
    public Explanation explain(int docNr)
      throws IOException
    {
      return scorer.explain(docNr);
    }
  }
  
  private Scorer countingDisjunctionSumScorer(List scorers, int minNrShouldMatch)
    throws IOException
  {
    new DisjunctionSumScorer(scorers, minNrShouldMatch)
    {
      private int lastScoredDoc = -1;
      private float lastDocScore = NaN.0F;
      
      public float score()
        throws IOException
      {
        int doc = docID();
        if (doc >= lastScoredDoc)
        {
          if (doc > lastScoredDoc)
          {
            lastDocScore = super.score();
            lastScoredDoc = doc;
          }
          coordinator.nrMatchers += nrMatchers;
        }
        return lastDocScore;
      }
    };
  }
  
  private static final Similarity defaultSimilarity = ;
  
  private Scorer countingConjunctionSumScorer(List requiredScorers)
    throws IOException
  {
    final int requiredNrMatchers = requiredScorers.size();
    new ConjunctionScorer(defaultSimilarity, requiredScorers)
    {
      private int lastScoredDoc = -1;
      private float lastDocScore = NaN.0F;
      
      public float score()
        throws IOException
      {
        int doc = docID();
        if (doc >= lastScoredDoc)
        {
          if (doc > lastScoredDoc)
          {
            lastDocScore = super.score();
            lastScoredDoc = doc;
          }
          coordinator.nrMatchers += requiredNrMatchers;
        }
        return lastDocScore;
      }
    };
  }
  
  private Scorer dualConjunctionSumScorer(Scorer req1, Scorer req2)
    throws IOException
  {
    return new ConjunctionScorer(defaultSimilarity, new Scorer[] { req1, req2 });
  }
  
  private Scorer makeCountingSumScorer()
    throws IOException
  {
    return requiredScorers.size() == 0 ? makeCountingSumScorerNoReq() : makeCountingSumScorerSomeReq();
  }
  
  private Scorer makeCountingSumScorerNoReq()
    throws IOException
  {
    int nrOptRequired = minNrShouldMatch < 1 ? 1 : minNrShouldMatch;
    Scorer requiredCountingSumScorer;
    Scorer requiredCountingSumScorer;
    if (optionalScorers.size() > nrOptRequired)
    {
      requiredCountingSumScorer = countingDisjunctionSumScorer(optionalScorers, nrOptRequired);
    }
    else
    {
      Scorer requiredCountingSumScorer;
      if (optionalScorers.size() == 1) {
        requiredCountingSumScorer = new SingleMatchScorer((Scorer)optionalScorers.get(0));
      } else {
        requiredCountingSumScorer = countingConjunctionSumScorer(optionalScorers);
      }
    }
    return addProhibitedScorers(requiredCountingSumScorer);
  }
  
  private Scorer makeCountingSumScorerSomeReq()
    throws IOException
  {
    if (optionalScorers.size() == minNrShouldMatch)
    {
      ArrayList allReq = new ArrayList(requiredScorers);
      allReq.addAll(optionalScorers);
      return addProhibitedScorers(countingConjunctionSumScorer(allReq));
    }
    Scorer requiredCountingSumScorer = requiredScorers.size() == 1 ? new SingleMatchScorer((Scorer)requiredScorers.get(0)) : countingConjunctionSumScorer(requiredScorers);
    if (minNrShouldMatch > 0) {
      return addProhibitedScorers(dualConjunctionSumScorer(requiredCountingSumScorer, countingDisjunctionSumScorer(optionalScorers, minNrShouldMatch)));
    }
    return new ReqOptSumScorer(addProhibitedScorers(requiredCountingSumScorer), optionalScorers.size() == 1 ? new SingleMatchScorer((Scorer)optionalScorers.get(0)) : countingDisjunctionSumScorer(optionalScorers, 1));
  }
  
  private Scorer addProhibitedScorers(Scorer requiredCountingSumScorer)
    throws IOException
  {
    return prohibitedScorers.size() == 0 ? requiredCountingSumScorer : new ReqExclScorer(requiredCountingSumScorer, prohibitedScorers.size() == 1 ? (Scorer)prohibitedScorers.get(0) : new DisjunctionSumScorer(prohibitedScorers));
  }
  
  /**
   * @deprecated
   */
  public void score(HitCollector hc)
    throws IOException
  {
    score(new HitCollectorWrapper(hc));
  }
  
  public void score(Collector collector)
    throws IOException
  {
    collector.setScorer(this);
    while ((doc = countingSumScorer.nextDoc()) != Integer.MAX_VALUE) {
      collector.collect(doc);
    }
  }
  
  /**
   * @deprecated
   */
  protected boolean score(HitCollector hc, int max)
    throws IOException
  {
    return score(new HitCollectorWrapper(hc), max, docID());
  }
  
  protected boolean score(Collector collector, int max, int firstDocID)
    throws IOException
  {
    doc = firstDocID;
    collector.setScorer(this);
    while (doc < max)
    {
      collector.collect(doc);
      doc = countingSumScorer.nextDoc();
    }
    return doc != Integer.MAX_VALUE;
  }
  
  /**
   * @deprecated
   */
  public int doc()
  {
    return countingSumScorer.doc();
  }
  
  public int docID()
  {
    return doc;
  }
  
  /**
   * @deprecated
   */
  public boolean next()
    throws IOException
  {
    return nextDoc() != Integer.MAX_VALUE;
  }
  
  public int nextDoc()
    throws IOException
  {
    return doc = countingSumScorer.nextDoc();
  }
  
  public float score()
    throws IOException
  {
    coordinator.nrMatchers = 0;
    float sum = countingSumScorer.score();
    return sum * coordinator.coordFactors[coordinator.nrMatchers];
  }
  
  /**
   * @deprecated
   */
  public boolean skipTo(int target)
    throws IOException
  {
    return advance(target) != Integer.MAX_VALUE;
  }
  
  public int advance(int target)
    throws IOException
  {
    return doc = countingSumScorer.advance(target);
  }
  
  public Explanation explain(int doc)
  {
    throw new UnsupportedOperationException();
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.BooleanScorer2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import org.apache.lucene.index.IndexReader;

class CachingSpanFilter$1
  extends CachingWrapperFilter.FilterCache
{
  private final CachingSpanFilter this$0;
  
  CachingSpanFilter$1(CachingSpanFilter paramCachingSpanFilter, CachingWrapperFilter.DeletesMode x0)
  {
    super(x0);
  }
  
  protected Object mergeDeletes(IndexReader r, Object value)
  {
    throw new IllegalStateException("DeletesMode.DYNAMIC is not supported");
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingSpanFilter.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.util.BitSet;
import org.apache.lucene.index.IndexReader;

public class CachingSpanFilter
  extends SpanFilter
{
  protected SpanFilter filter;
  private final CachingWrapperFilter.FilterCache cache;
  int hitCount;
  int missCount;
  
  public CachingSpanFilter(SpanFilter filter)
  {
    this(filter, CachingWrapperFilter.DeletesMode.RECACHE);
  }
  
  public CachingSpanFilter(SpanFilter filter, CachingWrapperFilter.DeletesMode deletesMode)
  {
    this.filter = filter;
    if (deletesMode == CachingWrapperFilter.DeletesMode.DYNAMIC) {
      throw new IllegalArgumentException("DeletesMode.DYNAMIC is not supported");
    }
    cache = new CachingWrapperFilter.FilterCache(deletesMode)
    {
      protected Object mergeDeletes(IndexReader r, Object value)
      {
        throw new IllegalStateException("DeletesMode.DYNAMIC is not supported");
      }
    };
  }
  
  /**
   * @deprecated
   */
  public BitSet bits(IndexReader reader)
    throws IOException
  {
    SpanFilterResult result = getCachedResult(reader);
    return result != null ? result.getBits() : null;
  }
  
  public DocIdSet getDocIdSet(IndexReader reader)
    throws IOException
  {
    SpanFilterResult result = getCachedResult(reader);
    return result != null ? result.getDocIdSet() : null;
  }
  
  private SpanFilterResult getCachedResult(IndexReader reader)
    throws IOException
  {
    Object coreKey = reader.getFieldCacheKey();
    Object delCoreKey = reader.hasDeletions() ? reader.getDeletesCacheKey() : coreKey;
    
    SpanFilterResult result = (SpanFilterResult)cache.get(reader, coreKey, delCoreKey);
    if (result != null)
    {
      hitCount += 1;
      return result;
    }
    missCount += 1;
    result = filter.bitSpans(reader);
    
    cache.put(coreKey, delCoreKey, result);
    return result;
  }
  
  public SpanFilterResult bitSpans(IndexReader reader)
    throws IOException
  {
    return getCachedResult(reader);
  }
  
  public String toString()
  {
    return "CachingSpanFilter(" + filter + ")";
  }
  
  public boolean equals(Object o)
  {
    if (!(o instanceof CachingSpanFilter)) {
      return false;
    }
    return filter.equals(filter);
  }
  
  public int hashCode()
  {
    return filter.hashCode() ^ 0x1117BF25;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingSpanFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import org.apache.lucene.index.IndexReader;

class CachingWrapperFilter$1$1
  extends FilteredDocIdSet
{
  private final CachingWrapperFilter.1 this$1;
  
  CachingWrapperFilter$1$1(CachingWrapperFilter.1 param1, DocIdSet x0, IndexReader paramIndexReader)
  {
    super(x0);
  }
  
  protected boolean match(int docID)
  {
    return !val$r.isDeleted(docID);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingWrapperFilter.1.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import org.apache.lucene.index.IndexReader;

class CachingWrapperFilter$1
  extends CachingWrapperFilter.FilterCache
{
  private final CachingWrapperFilter this$0;
  
  CachingWrapperFilter$1(CachingWrapperFilter paramCachingWrapperFilter, CachingWrapperFilter.DeletesMode x0)
  {
    super(x0);
  }
  
  public Object mergeDeletes(final IndexReader r, Object docIdSet)
  {
    new FilteredDocIdSet((DocIdSet)docIdSet)
    {
      protected boolean match(int docID)
      {
        return !r.isDeleted(docID);
      }
    };
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingWrapperFilter.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.Serializable;
import org.apache.lucene.util.Parameter;

public final class CachingWrapperFilter$DeletesMode
  extends Parameter
  implements Serializable
{
  private CachingWrapperFilter$DeletesMode(String name)
  {
    super(name);
  }
  
  public static DeletesMode IGNORE = new DeletesMode("IGNORE");
  public static DeletesMode RECACHE = new DeletesMode("RECACHE");
  public static DeletesMode DYNAMIC = new DeletesMode("DYNAMIC");
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingWrapperFilter.DeletesMode
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.io.Serializable;
import java.util.Map;
import java.util.WeakHashMap;
import org.apache.lucene.index.IndexReader;

abstract class CachingWrapperFilter$FilterCache
  implements Serializable
{
  transient Map cache;
  private final CachingWrapperFilter.DeletesMode deletesMode;
  
  public CachingWrapperFilter$FilterCache(CachingWrapperFilter.DeletesMode deletesMode)
  {
    this.deletesMode = deletesMode;
  }
  
  public synchronized Object get(IndexReader reader, Object coreKey, Object delCoreKey)
    throws IOException
  {
    if (cache == null) {
      cache = new WeakHashMap();
    }
    Object value;
    Object value;
    if (deletesMode == CachingWrapperFilter.DeletesMode.IGNORE)
    {
      value = cache.get(coreKey);
    }
    else
    {
      Object value;
      if (deletesMode == CachingWrapperFilter.DeletesMode.RECACHE)
      {
        value = cache.get(delCoreKey);
      }
      else
      {
        assert (deletesMode == CachingWrapperFilter.DeletesMode.DYNAMIC);
        
        value = cache.get(delCoreKey);
        if (value == null)
        {
          value = cache.get(coreKey);
          if ((value != null) && (reader.hasDeletions())) {
            value = mergeDeletes(reader, value);
          }
        }
      }
    }
    return value;
  }
  
  protected abstract Object mergeDeletes(IndexReader paramIndexReader, Object paramObject);
  
  public synchronized void put(Object coreKey, Object delCoreKey, Object value)
  {
    if (deletesMode == CachingWrapperFilter.DeletesMode.IGNORE)
    {
      cache.put(coreKey, value);
    }
    else if (deletesMode == CachingWrapperFilter.DeletesMode.RECACHE)
    {
      cache.put(delCoreKey, value);
    }
    else
    {
      cache.put(coreKey, value);
      cache.put(delCoreKey, value);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.search.CachingWrapperFilter.FilterCache
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.search;

import java.io.IOException;
import java.io.Serializable;
import java.util.BitSet;
import java.util.Map;
import java.util.WeakHashMap;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.util.DocIdBitSet;
import org.apache.lucene.util.OpenBitSetDISI;
import org.apache.lucene.util.Parameter;

public class CachingWrapperFilter
  extends Filter
{
  protected Filter filter;
  protected final FilterCache cache;
  int hitCount;
  int missCount;
  
  public static final class DeletesMode
    extends Parameter
    implements Serializable
  {
    private DeletesMode(String name)
    {
      super();
    }
    
    public static DeletesMode IGNORE = new DeletesMode("IGNORE");
    public static DeletesMode RECACHE = new DeletesMode("RECACHE");
    public static DeletesMode DYNAMIC = new DeletesMode("DYNAMIC");
  }
  
  static abstract class FilterCache
    implements Serializable
  {
    transient Map cache;
    private final CachingWrapperFilter.DeletesMode deletesMode;
    
    public FilterCache(CachingWrapperFilter.DeletesMode deletesMode)
    {
      this.deletesMode = deletesMode;
    }
    
    public synchronized Object get(IndexReader reader, Object coreKey, Object delCoreKey)
      throws IOException
    {
      if (cache == null) {
        cache = new WeakHashMap();
      }
      Object value;
      Object value;
      if (deletesMode == CachingWrapperFilter.DeletesMode.IGNORE)
      {
        value = cache.get(coreKey);
      }
      else
      {
        Object value;
        if (deletesMode == CachingWrapperFilter.DeletesMode.RECACHE)
        {
          value = cache.get(delCoreKey);
        }
        else
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd