public int lastLive() { return columnCounter == null ? 0 : columnCounter.live(); }
public int lastCounted() { // If we have a slice limit set, columnCounter.live() can overcount by one because we have to call // columnCounter.count() before we can tell if we've exceeded the slice limit (and accordingly, should not // add the cells to returned container). To deal with this overcounting, we take the min of the slice // limit and the counter's count. return columnCounter == null ? 0 : Math.min(columnCounter.live(), count); }
private int getPageLiveCount(List<Row> page) { int count = 0; for (Row row : page) count += columnCounter().countAll(row.cf).live(); return count; }
public List<Row> fetchPage(int pageSize) throws RequestValidationException, RequestExecutionException { List<Row> result = new ArrayList<Row>(); int remainingThisQuery = Math.min(remaining, pageSize); while (remainingThisQuery > 0 && !isExhausted()) { // isExhausted has set us on the first non-exhausted pager List<Row> page = pagers[current].fetchPage(remainingThisQuery); if (page.isEmpty()) continue; Row row = page.get(0); int fetched = pagers[current].columnCounter().countAll(row.cf).live(); remaining -= fetched; remainingThisQuery -= fetched; result.add(row); } return result; }
private int discardTail(ColumnFamily cf, int toDiscard, ColumnFamily copy, Iterator<Cell> iter, DeletionInfo.InOrderTester tester) { // Redoing the counting like that is not extremely efficient. // This is called only for reversed slices or in the case of a race between // paging and a deletion (pretty unlikely), so this is probably acceptable. int liveCount = columnCounter().countAll(cf).live(); if (liveCount == toDiscard) return toDiscard; ColumnCounter counter = columnCounter(); // Discard the last 'toDiscard' live (so stop adding as sound as we're past 'liveCount - toDiscard') while (iter.hasNext()) { Cell c = iter.next(); counter.count(c, tester); if (counter.live() > liveCount - toDiscard) break; copy.addColumn(c); } return Math.min(liveCount, toDiscard); }
public int getLiveCount(ColumnFamily cf, long now) { return columnCounter(cf.getComparator(), now).countAll(cf).live(); }
public int liveCQL3RowCount(long now) { ColumnCounter counter = getComparator().isDense() ? new ColumnCounter(now) : new ColumnCounter.GroupByPrefix(now, getComparator(), metadata.clusteringColumns().size()); return counter.countAll(this).live(); }
/** * Convenience method that count (live) cells/rows for a given slice of a row, but page underneath. */ public static int countPaged(String keyspace, String columnFamily, ByteBuffer key, SliceQueryFilter filter, ConsistencyLevel consistencyLevel, ClientState cState, final int pageSize, long now) throws RequestValidationException, RequestExecutionException { SliceFromReadCommand command = new SliceFromReadCommand(keyspace, key, columnFamily, now, filter); final SliceQueryPager pager = new SliceQueryPager(command, consistencyLevel, cState, false); ColumnCounter counter = filter.columnCounter(Schema.instance.getCFMetaData(keyspace, columnFamily).comparator, now); while (!pager.isExhausted()) { List<Row> next = pager.fetchPage(pageSize); if (!next.isEmpty()) counter.countAll(next.get(0).cf); } return counter.live(); } }
logger.trace("collecting {} of {}: {}", columnCounter.live(), count, cell.getString(container.getComparator())); if (columnCounter.live() > count) break; Tracing.trace("Read {} live and {} tombstone cells", columnCounter.live(), columnCounter.tombstones()); if (logger.isWarnEnabled() && respectTombstoneThresholds() && columnCounter.tombstones() > DatabaseDescriptor.getTombstoneWarnThreshold()) columnCounter.live(), columnCounter.tombstones(), container.metadata().ksName,
public ColumnFamily trim(ColumnFamily cf, int trimTo, long now) { // each cell can increment the count by at most one, so if we have fewer cells than trimTo, we can skip trimming if (cf.getColumnCount() < trimTo) return cf; ColumnCounter counter = columnCounter(cf.getComparator(), now); ColumnFamily trimmedCf = cf.getFactory().create(cf.metadata(), reversed, trimTo); trimmedCf.delete(cf); Collection<Cell> cells = reversed ? cf.getReverseSortedColumns() : cf.getSortedColumns(); DeletionInfo.InOrderTester tester = cf.deletionInfo().inOrderTester(reversed); for (Iterator<Cell> iter = cells.iterator(); iter.hasNext(); ) { Cell cell = iter.next(); counter.count(cell, tester); if (counter.live() > trimTo) { break; } else { trimmedCf.addColumn(cell); } } return trimmedCf; }