private Coverage(long docs, long active, int nodes, int resultSets, FullCoverageDefinition fullReason) { this.docs = docs; this.nodes = nodes; this.nodesTried = nodes; this.active = active; this.soonActive = active; this.degradedReason = 0; this.resultSets = resultSets; this.fullReason = fullReason; this.fullResultSets = getFull() ? resultSets : 0; }
/** * An int between 0 (inclusive) and 100 (inclusive) representing how many * percent coverage the result sets this Coverage instance contains information * about had. */ public int getResultPercentage() { if (getResultSets() == 0) { return 0; } if (docs < active) { return (int) Math.round(docs * 100.0d / active); } return getFullResultSets() * 100 / getResultSets(); }
public boolean isDegradedByNonIdealState() { return (degradedReason == 0) && (getResultPercentage() != 100);}
public void merge(Coverage other) { if (other == null) { return; } docs += other.getDocs(); nodes += other.getNodes(); nodesTried += other.nodesTried; active += other.getActive(); soonActive += other.getSoonActive(); degradedReason |= other.degradedReason; resultSets += other.getResultSets(); fullResultSets += other.getFullResultSets(); // explicitly incomplete beats doc count beats explicitly full switch (other.fullReason) { case EXPLICITLY_FULL: // do nothing break; case EXPLICITLY_INCOMPLETE: fullReason = FullCoverageDefinition.EXPLICITLY_INCOMPLETE; break; case DOCUMENT_COUNT: if (fullReason == FullCoverageDefinition.EXPLICITLY_FULL) { fullReason = FullCoverageDefinition.DOCUMENT_COUNT; } break; } }
public boolean isDegraded() { return (degradedReason != 0) || isDegradedByNonIdealState(); } public boolean isDegradedByMatchPhase() { return (degradedReason & DEGRADED_BY_MATCH_PHASE) != 0; }
public Coverage setNodesTried(int nodesTried) { super.setNodesTried(nodesTried); return this; } }