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;
});
}
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);
}
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);
}
Aggregations