Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrimaryIdTable as a virtual table for querying SSTable metadata #3756

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public ClusteringColumnRestrictions mergeWith(Restriction restriction, @Nullable

ColumnMetadata lastRestrictionStart = lastRestriction.firstColumn();
ColumnMetadata newRestrictionStart = restriction.firstColumn();

checkFalse(lastRestriction.isSlice() && newRestrictionStart.position() > lastRestrictionStart.position(),
"Clustering column \"%s\" cannot be restricted (preceding column \"%s\" is restricted by a non-EQ relation)",
newRestrictionStart.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ else if (operator.requiresIndexing())
}
else
{
if (!allowFiltering && requiresAllowFilteringIfNotSpecified())
if (!allowFiltering && requiresAllowFilteringIfNotSpecified(table))
throw invalidRequest(allowFilteringMessage(state));
}

Expand All @@ -356,12 +356,12 @@ else if (operator.requiresIndexing())
validateSecondaryIndexSelections();
}

public boolean requiresAllowFilteringIfNotSpecified()
public static boolean requiresAllowFilteringIfNotSpecified(TableMetadata metadata)
{
if (!table.isVirtual())
if (!metadata.isVirtual())
return true;

VirtualTable tableNullable = VirtualKeyspaceRegistry.instance.getTableNullable(table.id);
VirtualTable tableNullable = VirtualKeyspaceRegistry.instance.getTableNullable(metadata.id);
assert tableNullable != null;
return !tableNullable.allowFilteringImplicitly();
}
Expand Down Expand Up @@ -568,7 +568,7 @@ private void processPartitionKeyRestrictions(ClientState state, boolean hasQueri
// components must have a EQ. Only the last partition key component can be in IN relation.
if (partitionKeyRestrictions.needFiltering())
{
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified())
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified(table))
throw new InvalidRequestException(allowFilteringMessage(state));

isKeyRange = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import org.apache.commons.lang3.builder.ToStringStyle;

import static java.lang.String.format;
import static org.apache.cassandra.cql3.restrictions.StatementRestrictions.requiresAllowFilteringIfNotSpecified;
import static org.apache.cassandra.cql3.statements.RequestValidations.checkFalse;
import static org.apache.cassandra.cql3.statements.RequestValidations.checkNotNull;
import static org.apache.cassandra.cql3.statements.RequestValidations.checkNull;
Expand Down Expand Up @@ -1357,7 +1358,7 @@ private StatementRestrictions prepareRestrictions(ClientState state,
boundNames,
orderings,
selectsOnlyStaticColumns,
parameters.allowFiltering,
parameters.allowFiltering || !requiresAllowFilteringIfNotSpecified(metadata),
forView);
}

Expand Down Expand Up @@ -1583,7 +1584,7 @@ private void checkNeedsFiltering(TableMetadata table, StatementRestrictions rest
{
// We will potentially filter data if the row filter is not the identity and there isn't any index group
// supporting all the expressions in the filter.
if (restrictions.requiresAllowFilteringIfNotSpecified())
if (requiresAllowFilteringIfNotSpecified(table))
checkFalse(restrictions.needFiltering(table), StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter());
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter(), rowFilter());
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter());
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter(), rowFilter());
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.cassandra.db.PartitionPosition;
import org.apache.cassandra.db.filter.ClusteringIndexFilter;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.filter.RowFilter;
import org.apache.cassandra.db.partitions.AbstractUnfilteredPartitionIterator;
import org.apache.cassandra.db.partitions.PartitionUpdate;
import org.apache.cassandra.db.partitions.SingletonUnfilteredPartitionIterator;
Expand Down Expand Up @@ -75,7 +76,7 @@ public DataSet data(DecoratedKey partitionKey)
}

@Override
public final UnfilteredPartitionIterator select(DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, ColumnFilter columnFilter)
public final UnfilteredPartitionIterator select(DecoratedKey partitionKey, ClusteringIndexFilter clusteringIndexFilter, ColumnFilter columnFilter, RowFilter rowFilter)
{
Partition partition = data(partitionKey).getPartition(partitionKey);

Expand All @@ -88,7 +89,7 @@ public final UnfilteredPartitionIterator select(DecoratedKey partitionKey, Clust
}

@Override
public final UnfilteredPartitionIterator select(DataRange dataRange, ColumnFilter columnFilter)
public final UnfilteredPartitionIterator select(DataRange dataRange, ColumnFilter columnFilter, RowFilter rowFilter)
{
DataSet data = data();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.apache.cassandra.db.EmptyIterators;
import org.apache.cassandra.db.filter.ClusteringIndexFilter;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.filter.RowFilter;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.BooleanType;
import org.apache.cassandra.db.marshal.ByteType;
Expand Down Expand Up @@ -307,7 +308,8 @@ else if (partitionKeyTypes.size() > 1)
@Override
public UnfilteredPartitionIterator select(DecoratedKey partitionKey,
ClusteringIndexFilter clusteringFilter,
ColumnFilter columnFilter)
ColumnFilter columnFilter,
RowFilter rowFilter)
{
if (!data.iterator().hasNext())
return EmptyIterators.unfilteredPartition(metadata);
Expand Down Expand Up @@ -348,7 +350,7 @@ public UnfilteredPartitionIterator select(DecoratedKey partitionKey,
}

@Override
public UnfilteredPartitionIterator select(DataRange dataRange, ColumnFilter columnFilter)
public UnfilteredPartitionIterator select(DataRange dataRange, ColumnFilter columnFilter, RowFilter rowFilter)
{
return createPartitionIterator(metadata, new AbstractIterator<>()
{
Expand Down
Loading