@Override public ReadCommand maybeGenerateRetryCommand(RowDataResolver resolver, Row row) { int maxLiveColumns = resolver.getMaxLiveCount(); int count = filter.count; // We generate a retry if at least one node reply with count live columns but after merge we have less // than the total number of column we are interested in (which may be < count on a retry). // So in particular, if no host returned count live columns, we know it's not a short read. if (maxLiveColumns < count) return null; int liveCountInRow = row == null || row.cf == null ? 0 : filter.getLiveCount(row.cf, timestamp); if (liveCountInRow < getOriginalRequestedCount()) { // We asked t (= count) live columns and got l (=liveCountInRow) ones. // From that, we can estimate that on this row, for x requested // columns, only l/t end up live after reconciliation. So for next // round we want to ask x column so that x * (l/t) == t, i.e. x = t^2/l. int retryCount = liveCountInRow == 0 ? count + 1 : ((count * count) / liveCountInRow) + 1; SliceQueryFilter newFilter = filter.withUpdatedCount(retryCount); return new RetriedSliceFromReadCommand(ksName, key, cfName, timestamp, newFilter, getOriginalRequestedCount()); } return null; }
public boolean isFullyCoveredBy(ColumnFamily cf, long now) { // cf is the beginning of a partition. It covers this filter if: // 1) either this filter requests the head of the partition and request less // than what cf has to offer (note: we do need to use getLiveCount() for that // as it knows if the filter count cells or CQL3 rows). // 2) the start and finish bound of this filter are included in cf. if (isHeadFilter() && count <= getLiveCount(cf, now)) return true; if (start().isEmpty() || finish().isEmpty() || !cf.hasColumns()) return false; Composite low = isReversed() ? finish() : start(); Composite high = isReversed() ? start() : finish(); CellName first = cf.iterator(ColumnSlice.ALL_COLUMNS_ARRAY).next().name(); CellName last = cf.reverseIterator(ColumnSlice.ALL_COLUMNS_ARRAY).next().name(); return cf.getComparator().compare(first, low) <= 0 && cf.getComparator().compare(high, last) <= 0; }