@Override protected void merge(Suggestion.Entry<Suggestion.Entry.Option> other) { super.merge(other); // If the cluster contains both pre 0.90.4 and post 0.90.4 nodes then we'll see Suggestion.Entry // objects being merged with PhraseSuggestion.Entry objects. We merge Suggestion.Entry objects // by assuming they had a low cutoff score rather than a high one as that is the more common scenario // and the simplest one for us to implement. if (!(other instanceof PhraseSuggestion.Entry)) { return; } PhraseSuggestion.Entry otherSuggestionEntry = (PhraseSuggestion.Entry) other; this.cutoffScore = Math.max(this.cutoffScore, otherSuggestionEntry.cutoffScore); }
protected <T extends Entry<O>> Entry<O> reduce(List<T> toReduce) { if (toReduce.size() == 1) { return toReduce.get(0); } final Map<O, O> entries = new HashMap<>(); Entry<O> leader = toReduce.get(0); for (Entry<O> entry : toReduce) { if (!leader.text.equals(entry.text)) { throw new IllegalStateException("Can't merge suggest entries, this might be caused by suggest calls " + "across multiple indices with different analysis chains. Suggest entries have different text actual [" + entry.text + "] expected [" + leader.text +"]"); } assert leader.offset == entry.offset; assert leader.length == entry.length; leader.merge(entry); for (O option : entry) { O merger = entries.get(option); if (merger == null) { entries.put(option, option); } else { merger.mergeInto(option); } } } leader.options.clear(); for (O option: entries.keySet()) { leader.addOption(option); } return leader; }
@Override protected void merge(Suggestion.Entry<Suggestion.Entry.Option> other) { super.merge(other); // If the cluster contains both pre 0.90.4 and post 0.90.4 nodes then we'll see Suggestion.Entry // objects being merged with PhraseSuggestion.Entry objects. We merge Suggestion.Entry objects // by assuming they had a low cutoff score rather than a high one as that is the more common scenario // and the simplest one for us to implement. if (!(other instanceof PhraseSuggestion.Entry)) { return; } PhraseSuggestion.Entry otherSuggestionEntry = (PhraseSuggestion.Entry) other; this.cutoffScore = Math.max(this.cutoffScore, otherSuggestionEntry.cutoffScore); }
protected <T extends Entry<O>> Entry<O> reduce(List<T> toReduce) { if (toReduce.size() == 1) { return toReduce.get(0); } final Map<O, O> entries = new HashMap<>(); Entry<O> leader = toReduce.get(0); for (Entry<O> entry : toReduce) { if (!leader.text.equals(entry.text)) { throw new IllegalStateException("Can't merge suggest entries, this might be caused by suggest calls " + "across multiple indices with different analysis chains. Suggest entries have different text actual [" + entry.text + "] expected [" + leader.text +"]"); } assert leader.offset == entry.offset; assert leader.length == entry.length; leader.merge(entry); for (O option : entry) { O merger = entries.get(option); if (merger == null) { entries.put(option, option); } else { merger.mergeInto(option); } } } leader.options.clear(); for (O option: entries.keySet()) { leader.addOption(option); } return leader; }
protected <T extends Entry<O>> Entry<O> reduce(List<T> toReduce) { if (toReduce.size() == 1) { return toReduce.get(0); } final Map<O, O> entries = new HashMap<>(); Entry<O> leader = toReduce.get(0); for (Entry<O> entry : toReduce) { if (!leader.text.equals(entry.text)) { throw new IllegalStateException("Can't merge suggest entries, this might be caused by suggest calls " + "across multiple indices with different analysis chains. Suggest entries have different text actual [" + entry.text + "] expected [" + leader.text +"]"); } assert leader.offset == entry.offset; assert leader.length == entry.length; leader.merge(entry); for (O option : entry) { O merger = entries.get(option); if (merger == null) { entries.put(option, option); } else { merger.mergeInto(option); } } } leader.options.clear(); for (O option: entries.keySet()) { leader.addOption(option); } return leader; }
protected <T extends Entry<O>> Entry<O> reduce(List<T> toReduce) { if (toReduce.size() == 1) { return toReduce.get(0); } final Map<O, O> entries = new HashMap<>(); Entry<O> leader = toReduce.get(0); for (Entry<O> entry : toReduce) { if (!leader.text.equals(entry.text)) { throw new IllegalStateException("Can't merge suggest entries, this might be caused by suggest calls " + "across multiple indices with different analysis chains. Suggest entries have different text actual [" + entry.text + "] expected [" + leader.text +"]"); } assert leader.offset == entry.offset; assert leader.length == entry.length; leader.merge(entry); for (O option : entry) { O merger = entries.get(option); if (merger == null) { entries.put(option, option); } else { merger.mergeInto(option); } } } leader.options.clear(); for (O option: entries.keySet()) { leader.addOption(option); } return leader; }
protected <T extends Entry<O>> Entry<O> reduce(List<T> toReduce) { if (toReduce.size() == 1) { return toReduce.get(0); } final Map<O, O> entries = new HashMap<>(); Entry<O> leader = toReduce.get(0); for (Entry<O> entry : toReduce) { if (!leader.text.equals(entry.text)) { throw new IllegalStateException("Can't merge suggest entries, this might be caused by suggest calls " + "across multiple indices with different analysis chains. Suggest entries have different text actual [" + entry.text + "] expected [" + leader.text +"]"); } assert leader.offset == entry.offset; assert leader.length == entry.length; leader.merge(entry); for (O option : entry) { O merger = entries.get(option); if (merger == null) { entries.put(option, option); } else { merger.mergeInto(option); } } } leader.options.clear(); for (O option: entries.keySet()) { leader.addOption(option); } return leader; }
@Override protected void merge(Suggestion.Entry<Suggestion.Entry.Option> other) { super.merge(other); // If the cluster contains both pre 0.90.4 and post 0.90.4 nodes then we'll see Suggestion.Entry // objects being merged with PhraseSuggestion.Entry objects. We merge Suggestion.Entry objects // by assuming they had a low cutoff score rather than a high one as that is the more common scenario // and the simplest one for us to implement. if (!(other instanceof PhraseSuggestion.Entry)) { return; } PhraseSuggestion.Entry otherSuggestionEntry = (PhraseSuggestion.Entry) other; this.cutoffScore = Math.max(this.cutoffScore, otherSuggestionEntry.cutoffScore); }
@Override protected void merge(Suggestion.Entry<Suggestion.Entry.Option> other) { super.merge(other); // If the cluster contains both pre 0.90.4 and post 0.90.4 nodes then we'll see Suggestion.Entry // objects being merged with PhraseSuggestion.Entry objects. We merge Suggestion.Entry objects // by assuming they had a low cutoff score rather than a high one as that is the more common scenario // and the simplest one for us to implement. if (!(other instanceof PhraseSuggestion.Entry)) { return; } PhraseSuggestion.Entry otherSuggestionEntry = (PhraseSuggestion.Entry) other; this.cutoffScore = Math.max(this.cutoffScore, otherSuggestionEntry.cutoffScore); }
@Override protected void merge(Suggestion.Entry<Suggestion.Entry.Option> other) { super.merge(other); // If the cluster contains both pre 0.90.4 and post 0.90.4 nodes then we'll see Suggestion.Entry // objects being merged with PhraseSuggestion.Entry objects. We merge Suggestion.Entry objects // by assuming they had a low cutoff score rather than a high one as that is the more common scenario // and the simplest one for us to implement. if (!(other instanceof PhraseSuggestion.Entry)) { return; } PhraseSuggestion.Entry otherSuggestionEntry = (PhraseSuggestion.Entry) other; this.cutoffScore = Math.max(this.cutoffScore, otherSuggestionEntry.cutoffScore); }