private List<Row> filterEmpty(List<Row> result) { for (Row row : result) { if (row.cf == null || !row.cf.hasColumns()) { List<Row> newResult = new ArrayList<Row>(result.size() - 1); for (Row row2 : result) { if (row2.cf == null || !row2.cf.hasColumns()) continue; newResult.add(row2); } return newResult; } } return result; }
public static boolean invalidSchemaRow(Row row) { return row.cf == null || (row.cf.isMarkedForDelete() && !row.cf.hasColumns()); }
/** * Returns true if this contains no columns or deletion info */ public boolean isEmpty() { return deletionInfo().isLive() && !hasColumns(); }
/** * Purges gc-able top-level and range tombstones, returning `cf` if there are any columns or tombstones left, * null otherwise. * @param gcBefore a timestamp (in seconds); tombstones with a localDeletionTime before this will be purged */ public static ColumnFamily removeDeletedCF(ColumnFamily cf, int gcBefore) { // purge old top-level and range tombstones cf.purgeTombstones(gcBefore); // if there are no columns or tombstones left, return null return !cf.hasColumns() && !cf.isMarkedForDelete() ? null : cf; }
/** * Updates this object in place to match the definition in the system schema tables. * @return true if any columns were added, removed, or altered; otherwise, false is returned */ public boolean reload() { Row cfDefRow = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, ksName, cfName); if (cfDefRow.cf == null || !cfDefRow.cf.hasColumns()) throw new RuntimeException(String.format("%s not found in the schema definitions keyspace.", ksName + ":" + cfName)); try { return apply(fromSchema(cfDefRow)); } catch (ConfigurationException e) { throw new RuntimeException(e); } }
if (entry.getValue().hasColumns()) created.add(new Row(entry.getKey(), entry.getValue())); ColumnFamily post = entry.getValue().rightValue(); if (pre.hasColumns() && post.hasColumns()) altered.add(keyspaceName); else if (pre.hasColumns()) dropped.add(keyspaceName); else if (post.hasColumns()) // a (re)created keyspace created.add(new Row(entry.getKey(), post));
if (entry.getValue().hasColumns()) created.addAll(UTMetaData.fromSchema(new Row(entry.getKey(), entry.getValue())).values()); ColumnFamily post = entry.getValue().rightValue(); if (pre.hasColumns() && post.hasColumns()) else if (pre.hasColumns()) else if (post.hasColumns())
if (entry.getValue().hasColumns()) created.addAll(KSMetaData.deserializeColumnFamilies(new Row(entry.getKey(), entry.getValue())).values()); ColumnFamily post = entry.getValue().rightValue(); if (pre.hasColumns() && post.hasColumns()) else if (pre.hasColumns()) else if (post.hasColumns())
public void addAll(ColumnFamily other) { delete(other.deletionInfo()); if (!other.hasColumns()) return; // In reality, with ABSC being the only remaining container (aside from ABTC), other will aways be ABSC. if (size == 0 && other instanceof ArrayBackedSortedColumns) { fastAddAll((ArrayBackedSortedColumns) other); } else { Iterator<Cell> iterator = reversed ? other.reverseIterator() : other.iterator(); while (iterator.hasNext()) addColumn(iterator.next()); } }
public static RowIndexEntry rawAppend(ColumnFamily cf, long startPosition, DecoratedKey key, DataOutputPlus out) throws IOException { assert cf.hasColumns() || cf.isMarkedForDelete(); ColumnIndex.Builder builder = new ColumnIndex.Builder(cf, key.getKey(), out); ColumnIndex index = builder.build(cf); out.writeShort(END_OF_ROW); return RowIndexEntry.create(startPosition, cf.deletionInfo().getTopLevelDeletion(), index); }
private List<ColumnOrSuperColumn> thriftifyColumnFamily(ColumnFamily cf, boolean subcolumnsOnly, boolean reverseOrder, long now) { if (cf == null || !cf.hasColumns()) return EMPTY_COLUMNS; if (cf.metadata().isSuper()) { boolean isCounterCF = cf.metadata().isCounter(); return thriftifySuperColumns(cf.getSortedColumns(), reverseOrder, now, subcolumnsOnly, isCounterCF); } else { return thriftifyColumns(cf.getSortedColumns(), reverseOrder, now); } }
filter.timestamp); ColumnFamily indexRow = index.getIndexCfs().getColumnFamily(indexFilter); if (indexRow == null || !indexRow.hasColumns()) return makeReturn(currentKey, data);
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; }