@Override public Collection<ChildScorer> getChildren() throws IOException { return scorer.getChildren(); }
ProfileScorer(ProfileWeight w, Scorer scorer, QueryProfileBreakdown profile) throws IOException { super(w); this.scorer = scorer; this.profileWeight = w; scoreTimer = profile.getTimer(QueryTimingType.SCORE); nextDocTimer = profile.getTimer(QueryTimingType.NEXT_DOC); advanceTimer = profile.getTimer(QueryTimingType.ADVANCE); matchTimer = profile.getTimer(QueryTimingType.MATCH); ProfileScorer profileScorer = null; if (w.getQuery() instanceof ConstantScoreQuery && scorer instanceof ProfileScorer) { //Case when we have a totalHits query and it is not cached profileScorer = (ProfileScorer) scorer; } else if (w.getQuery() instanceof ConstantScoreQuery && scorer.getChildren().size() == 1) { //Case when we have a top N query. If the scorer has no children, it is because it is cached //and in that case we do not do any special treatment Scorer childScorer = scorer.getChildren().iterator().next().child; if (childScorer instanceof ProfileScorer) { profileScorer = (ProfileScorer) childScorer; } } if (profileScorer != null) { isConstantScoreQuery = true; profile.setTimer(QueryTimingType.NEXT_DOC, profileScorer.nextDocTimer); profile.setTimer(QueryTimingType.ADVANCE, profileScorer.advanceTimer); profile.setTimer(QueryTimingType.MATCH, profileScorer.matchTimer); } else { isConstantScoreQuery = false; } }
@Override public Collection<ChildScorer> getChildren() { return scorer.getChildren(); }
@Override public Collection<ChildScorer> getChildren() { return scorer.getChildren(); }
@Override public Collection<ChildScorer> getChildren() { return parentScorer.getChildren(); }
@Override public Collection<ChildScorer> getChildren() throws IOException { return parentScorer.getChildren(); }
@Override public Collection<ChildScorer> getChildren() throws IOException { return scorer.getChildren(); }
@Override public Collection<ChildScorer> getChildren() throws IOException { return scorer.getChildren(); }
/** * Get a list of all Spans made available from the passed-in Scorer * @param scorer the scorer to extract spans from * @param errorOnNoSpans if true, throw an error if no Spans can be extracted * from the Scorer or any of its children * @return a List of Spans */ public static List<Spans> getSpans(Scorer scorer, boolean errorOnNoSpans) throws IOException { List<Spans> spans = new ArrayList<>(); if (scorer instanceof SpanScorer) { spans.add(((SpanScorer) scorer).getSpans()); return spans; } Collection<Scorer.ChildScorer> children = scorer.getChildren(); if (errorOnNoSpans && children.isEmpty()) throw new RuntimeException("Couldn't extract SpanScorer from " + scorer.getClass().getCanonicalName()); for (Scorer.ChildScorer child : children) { spans.addAll(getSpans(child.child, errorOnNoSpans)); } return spans; }
@Override public void setScorer(Scorer scorer) throws IOException { //System.out.println("C.setScorer scorer=" + scorer); // Since we invoke .score(), and the comparators likely // do as well, cache it so it's only "really" computed // once: if (scorer instanceof ScoreCachingWrappingScorer == false) { scorer = new ScoreCachingWrappingScorer(scorer); } this.scorer = scorer; for (LeafFieldComparator comparator : comparators) { comparator.setScorer(scorer); } Arrays.fill(joinScorers, null); Queue<Scorer> queue = new LinkedList<>(); //System.out.println("\nqueue: add top scorer=" + scorer); queue.add(scorer); while ((scorer = queue.poll()) != null) { //System.out.println(" poll: " + scorer + "; " + scorer.getWeight().getQuery()); if (scorer instanceof ToParentBlockJoinQuery.BlockJoinScorer) { enroll((ToParentBlockJoinQuery) scorer.getWeight().getQuery(), (ToParentBlockJoinQuery.BlockJoinScorer) scorer); } for (ChildScorer sub : scorer.getChildren()) { //System.out.println(" add sub: " + sub.child + "; " + sub.child.getWeight().getQuery()); queue.add(sub.child); } } }
ProfileScorer(ProfileWeight w, Scorer scorer, QueryProfileBreakdown profile) throws IOException { super(w); this.scorer = scorer; this.profileWeight = w; scoreTimer = profile.getTimer(QueryTimingType.SCORE); nextDocTimer = profile.getTimer(QueryTimingType.NEXT_DOC); advanceTimer = profile.getTimer(QueryTimingType.ADVANCE); matchTimer = profile.getTimer(QueryTimingType.MATCH); ProfileScorer profileScorer = null; if (w.getQuery() instanceof ConstantScoreQuery && scorer instanceof ProfileScorer) { //Case when we have a totalHits query and it is not cached profileScorer = (ProfileScorer) scorer; } else if (w.getQuery() instanceof ConstantScoreQuery && scorer.getChildren().size() == 1) { //Case when we have a top N query. If the scorer has no children, it is because it is cached //and in that case we do not do any special treatment Scorer childScorer = scorer.getChildren().iterator().next().child; if (childScorer instanceof ProfileScorer) { profileScorer = (ProfileScorer) childScorer; } } if (profileScorer != null) { isConstantScoreQuery = true; profile.setTimer(QueryTimingType.NEXT_DOC, profileScorer.nextDocTimer); profile.setTimer(QueryTimingType.ADVANCE, profileScorer.advanceTimer); profile.setTimer(QueryTimingType.MATCH, profileScorer.matchTimer); } else { isConstantScoreQuery = false; } }