@Override public int hashCode() { int result = str1.hashCode(); result = 31 * result + str2.hashCode(); result = 31 * result + dist.hashCode(); return result; }
@Override public int hashCode() { int h = a.hashCode(); h ^= (h << 13) | (h >>> 20); h += b.hashCode(); h ^= (h << 23) | (h >>> 10); h += name().hashCode(); return h; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof StringDistanceFunction)) return false; StringDistanceFunction that = (StringDistanceFunction) o; if (!dist.equals(that.dist)) return false; if (!str1.equals(that.str1)) return false; if (!str2.equals(that.str2)) return false; return true; }
@Override public FuncValues getValues(QueryContext context, AtomicReaderContext readerContext) throws IOException { final FuncValues aVals = a.getValues(context, readerContext); final FuncValues bVals = b.getValues(context, readerContext); return new DoubleFuncValues(this) { @Override public double doubleVal(int doc) { return func(doc, aVals, bVals); } @Override public String toString(int doc) { return name() + '(' + aVals.toString(doc) + ',' + bVals.toString(doc) + ')'; } }; }
@Override public int hashCode() { int h = q.hashCode(); h ^= (h << 17) | (h >>> 16); h += boostVal.hashCode(); h ^= (h << 8) | (h >>> 25); h += Float.floatToIntBits(getBoost()); return h; }
@Override public FuncValues getValues(QueryContext context, AtomicReaderContext readerContext) throws IOException { if (context.get(this) == null) { SolrRequestInfo requestInfo = SolrRequestInfo.getRequestInfo(); throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "testfunc: unweighted value source detected. delegate=" + source + " request=" + (requestInfo == null ? "null" : requestInfo.getReq())); } return source.getValues(context, readerContext); }
@Override public DocValues getValues(Map context, IndexReader reader) throws IOException { final DocValues str1DV = str1.getValues(context, reader); final DocValues str2DV = str2.getValues(context, reader); return new DocValues() { public float floatVal(int doc) { return dist.getDistance(str1DV.strVal(doc), str2DV.strVal(doc)); } public int intVal(int doc) { return (int) doubleVal(doc); } public long longVal(int doc) { return (long) doubleVal(doc); } public double doubleVal(int doc) { return (double) floatVal(doc); } @Override public String toString(int doc) { StringBuilder sb = new StringBuilder(); sb.append("strdist").append('('); sb.append(str1DV.toString(doc)) .append(',') .append(str2DV.toString(doc)) .append(", dist=") .append(dist.getClass().getName()); sb.append(')'); return sb.toString(); } }; }
private CustomScorer( Similarity similarity, Searcher searcher, IndexReader reader, BoostedQuery.BoostedWeight w, Scorer scorer, ValueSource vs) throws IOException { super(similarity, w); this.weight = w; this.qWeight = w.getValue(); this.scorer = scorer; this.reader = reader; this.searcher = searcher; // for explain this.vals = vs.getValues(weight.context, reader); }
@Override public BoolFuncValues getValues(QueryContext context, AtomicReaderContext readerContext) throws IOException { final FuncValues vals = source.getValues(context, readerContext); return new BoolFuncValues(this) { @Override public boolean boolVal(int doc) { return func(doc, vals); } @Override public String toString(int doc) { return name() + '(' + vals.toString(doc) + ')'; } }; }
@Override public int hashCode() { return source.hashCode() + TestValueSource.class.hashCode(); }
public String toString(int doc) { return vs.description() + '=' + strVal(doc); }
@Override public boolean equals(Object o) { return o instanceof TestValueSource && source.equals(((TestValueSource) o).source); }
/** Returns a hash code value for this object. */ @Override public int hashCode() { return func.hashCode() * 31 + Float.floatToIntBits(getBoost()); }
/** Prints a user-readable version of this query. */ @Override public String toString(String field) { float boost = getBoost(); return (boost != 1.0 ? "(" : "") + func.toString() + (boost == 1.0 ? "" : ")^" + boost); }
@Override public String description() { return name() + "(" + a.description() + "," + b.description() + ")"; }
@Override public void createWeight(QueryContext context) throws IOException { source.createWeight(context); }
@Override public int hashCode() { return source.hashCode() + name().hashCode(); }
public FunctionWeight(Searcher searcher) throws IOException { this.searcher = searcher; this.context = ValueSource.newContext(); func.createWeight(context, searcher); }
@Override public String description() { return "testfunc(" + source.description() + ')'; }
public void setNextReader(AtomicReaderContext ctx) throws IOException { if (valueSource == null) { valueSource = ft.getValueSource(sf, null); } values = valueSource.getValues(qcontext, ctx); }
@Override public String description() { return name() + '(' + source.description() + ')'; }