Search in sources :

Example 1 with Columns

use of org.apache.cassandra.db.Columns in project cassandra by apache.

the class BTreeRow method filter.

public Row filter(ColumnFilter filter, DeletionTime activeDeletion, boolean setActiveDeletionToRow, TableMetadata metadata) {
    Map<ByteBuffer, DroppedColumn> droppedColumns = metadata.droppedColumns;
    boolean mayFilterColumns = !filter.fetchesAllColumns(isStatic()) || !filter.allFetchedColumnsAreQueried();
    // When merging sstable data in Row.Merger#merge(), rowDeletion is removed if it doesn't supersede activeDeletion.
    boolean mayHaveShadowed = !activeDeletion.isLive() && !deletion.time().supersedes(activeDeletion);
    if (!mayFilterColumns && !mayHaveShadowed && droppedColumns.isEmpty())
        return this;
    LivenessInfo newInfo = primaryKeyLivenessInfo;
    Deletion newDeletion = deletion;
    if (mayHaveShadowed) {
        if (activeDeletion.deletes(newInfo.timestamp()))
            newInfo = LivenessInfo.EMPTY;
        // note that mayHaveShadowed means the activeDeletion shadows the row deletion. So if don't have setActiveDeletionToRow,
        // the row deletion is shadowed and we shouldn't return it.
        newDeletion = setActiveDeletionToRow ? Deletion.regular(activeDeletion) : Deletion.LIVE;
    }
    Columns columns = filter.fetchedColumns().columns(isStatic());
    Predicate<ColumnMetadata> inclusionTester = columns.inOrderInclusionTester();
    Predicate<ColumnMetadata> queriedByUserTester = filter.queriedColumns().columns(isStatic()).inOrderInclusionTester();
    final LivenessInfo rowLiveness = newInfo;
    return transformAndFilter(newInfo, newDeletion, (cd) -> {
        ColumnMetadata column = cd.column();
        if (!inclusionTester.test(column))
            return null;
        DroppedColumn dropped = droppedColumns.get(column.name.bytes);
        if (column.isComplex())
            return ((ComplexColumnData) cd).filter(filter, mayHaveShadowed ? activeDeletion : DeletionTime.LIVE, dropped, rowLiveness);
        Cell<?> cell = (Cell<?>) cd;
        // We include the cell unless it is 1) shadowed, 2) for a dropped column or 3) skippable.
        // And a cell is skippable if it is for a column that is not queried by the user and its timestamp
        // is lower than the row timestamp (see #10657 or SerializationHelper.includes() for details).
        boolean isForDropped = dropped != null && cell.timestamp() <= dropped.droppedTime;
        boolean isShadowed = mayHaveShadowed && activeDeletion.deletes(cell);
        boolean isSkippable = !queriedByUserTester.test(column);
        if (isForDropped || isShadowed || (isSkippable && cell.timestamp() < rowLiveness.timestamp()))
            return null;
        // between sstables and memtables data, i.e resulting in a digest mismatch.
        return isSkippable ? cell.withSkippedValue() : cell;
    });
}
Also used : ColumnMetadata(org.apache.cassandra.schema.ColumnMetadata) DroppedColumn(org.apache.cassandra.schema.DroppedColumn) Columns(org.apache.cassandra.db.Columns) ByteBuffer(java.nio.ByteBuffer) LivenessInfo(org.apache.cassandra.db.LivenessInfo)

Example 2 with Columns

use of org.apache.cassandra.db.Columns in project cassandra by apache.

the class ReplicaFilteringProtection method columns.

private static RegularAndStaticColumns columns(List<UnfilteredRowIterator> versions) {
    Columns statics = Columns.NONE;
    Columns regulars = Columns.NONE;
    for (UnfilteredRowIterator iter : versions) {
        if (iter == null)
            continue;
        RegularAndStaticColumns cols = iter.columns();
        statics = statics.mergeTo(cols.statics);
        regulars = regulars.mergeTo(cols.regulars);
    }
    return new RegularAndStaticColumns(statics, regulars);
}
Also used : UnfilteredRowIterator(org.apache.cassandra.db.rows.UnfilteredRowIterator) RegularAndStaticColumns(org.apache.cassandra.db.RegularAndStaticColumns) Columns(org.apache.cassandra.db.Columns) RegularAndStaticColumns(org.apache.cassandra.db.RegularAndStaticColumns)

Example 3 with Columns

use of org.apache.cassandra.db.Columns in project cassandra by apache.

the class PartitionIteratorMergeListener method columns.

protected RegularAndStaticColumns columns(List<UnfilteredRowIterator> versions) {
    Columns statics = Columns.NONE;
    Columns regulars = Columns.NONE;
    for (UnfilteredRowIterator iter : versions) {
        if (iter == null)
            continue;
        RegularAndStaticColumns cols = iter.columns();
        statics = statics.mergeTo(cols.statics);
        regulars = regulars.mergeTo(cols.regulars);
    }
    return new RegularAndStaticColumns(statics, regulars);
}
Also used : UnfilteredRowIterator(org.apache.cassandra.db.rows.UnfilteredRowIterator) Columns(org.apache.cassandra.db.Columns) RegularAndStaticColumns(org.apache.cassandra.db.RegularAndStaticColumns) RegularAndStaticColumns(org.apache.cassandra.db.RegularAndStaticColumns)

Aggregations

Columns (org.apache.cassandra.db.Columns)3 RegularAndStaticColumns (org.apache.cassandra.db.RegularAndStaticColumns)2 UnfilteredRowIterator (org.apache.cassandra.db.rows.UnfilteredRowIterator)2 ByteBuffer (java.nio.ByteBuffer)1 LivenessInfo (org.apache.cassandra.db.LivenessInfo)1 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)1 DroppedColumn (org.apache.cassandra.schema.DroppedColumn)1