⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hits.java

📁 nutch搜索的改进型工具和优化爬虫的相关工具
💻 JAVA
字号:
/* Copyright (c) 2003 The Nutch Organization.  All rights reserved.   */
/* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */

package net.nutch.searcher;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import net.nutch.io.Writable;

import java.util.logging.Logger;
import net.nutch.util.LogFormatter;

/** A set of hits matching a query. */
public final class Hits implements Writable {
  private static final Logger LOG =
    LogFormatter.getLogger("net.nutch.searcher.Hits");
  
  private long total;
  private long totalGrpHits;
  private int[] grpHits;
  private boolean totalIsExact = true;
  private Hit[] top;

  public Hits() {}

  public Hits(long total, int[] grpHits, Hit[] top) {
    this.total = total;
    this.grpHits = grpHits;
    this.totalGrpHits = grpHits.length;
    this.top = top;
  }
  
  public Hits(long total, long totalGrpHits, Hit[] top) {
  	this.total = total;
  	this.totalGrpHits = totalGrpHits;
  	this.top = top;
  }
  
  public Hits(long total, Hit[] top) {
  	this.total = total;
  	this.top = top;
  }

  /** Returns the total number of hits for this query.  This may be an estimate
   * when (@link totalIsExact()} is false. */
  public long getTotal() { return total; }
  
  public long getTotalGrp() { return totalGrpHits; };
  
  public int[] getGrpHits() { return grpHits; };

  /** True if {@link getTotal()} gives the exact number of hits, or false if
   * it is only an estimate of the total number of hits. */
  public boolean totalIsExact() { return totalIsExact; }

  /** Set {@link totalIsExact()}. */
  public void setTotalIsExact(boolean isExact) { totalIsExact = isExact; }

  /** Returns the number of hits included in this current listing. */
  public int getLength() { return top.length; }

  /** Returns the <code>i</code><sup>th</sup> hit in this list. */
  public Hit getHit(int i) { return top[i]; }

  /** Return all hit objects.
  /*  add by xie shuqiang. 2006.7.21
   *  @return
   */
  public Hit[] getHits() {
	  return top;
  }
  
  
  /** Returns a subset of the hit objects. */
  public Hit[] getHits(int start, int length) {
    Hit[] results = new Hit[length];
    for (int i = 0; i < length; i++) {
      results[i] = top[start+i];
    }
    return results;
  }


  public void write(DataOutput out) throws IOException {
    out.writeLong(total);
    out.writeInt(top.length);
    for (int i = 0; i < top.length; i++) {
      top[i].write(out);
    }
  }

  public void readFields(DataInput in) throws IOException {
    total = in.readLong();
    top = new Hit[in.readInt()];
    for (int i = 0; i < top.length; i++) {
      top[i] = new Hit();
      top[i].readFields(in);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -