Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skipTo使用的是terms,这里面用到了大量的clone #114

Closed
muyannian opened this issue Jul 14, 2013 · 1 comment
Closed

skipTo使用的是terms,这里面用到了大量的clone #114

muyannian opened this issue Jul 14, 2013 · 1 comment

Comments

@muyannian
Copy link
Owner

  public boolean skipTo(Term target) throws IOException {
    // already here
    if (t != null && t.equals(target)) return true;

    int startIdx = Arrays.binarySearch(tindex.index,target.text());

    if (startIdx >= 0) {
      // we hit the term exactly... lucky us!
      if (tenum != null) tenum.close();
      tenum = reader.terms(target);
      pos = startIdx << tindex.intervalBits;
      return setTerm();
    }

    // we didn't hit the term exactly
    startIdx=-startIdx-1;

    if (startIdx == 0) {
      // our target occurs *before* the first term
      if (tenum != null) tenum.close();
      tenum = reader.terms(target);
      pos = 0;
      return setTerm();
    } 

/** Returns an enumeration of terms starting at or after the named term. */
public SegmentTermEnum terms(Term term) throws IOException {
BytesRef termBytesRef = new BytesRef(term.text);
get(term, true, termBytesRef);
return (SegmentTermEnum)getThreadResources().termEnum.clone();
}

@muyannian
Copy link
Owner Author

用于从termNum to term的转换 不会造成太大的影响

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant