Skip to content

Commit add004b

Browse files
committed
Lazy Virtual Tables
Also Improve: - Searchable system_accord_debug.txn patch by Benedict; reviewed by Aleksey Yeschenko for CASSANDRA-20899
1 parent 09b5266 commit add004b

21 files changed

+1100
-322
lines changed

src/java/org/apache/cassandra/cql3/restrictions/StatementRestrictions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ public static StatementRestrictions empty(StatementType type, TableMetadata tabl
156156
return new StatementRestrictions(type, table, IndexHints.NONE, false);
157157
}
158158

159-
private StatementRestrictions(StatementType type, TableMetadata table, IndexHints indexHints, boolean allowFiltering)
159+
private StatementRestrictions(StatementType type, TableMetadata table, IndexHints indexHints, boolean allowFilteringOfPrimaryKeys)
160160
{
161161
this.type = type;
162162
this.table = table;
163163
this.indexHints = indexHints;
164164
this.partitionKeyRestrictions = new PartitionKeyRestrictions(table.partitionKeyAsClusteringComparator());
165-
this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(table, allowFiltering);
165+
this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(table, allowFilteringOfPrimaryKeys);
166166
this.nonPrimaryKeyRestrictions = RestrictionSet.empty();
167167
this.notNullColumns = new HashSet<>();
168168
}
@@ -370,7 +370,7 @@ else if (operator.requiresIndexing())
370370
}
371371
else
372372
{
373-
if (!allowFiltering && requiresAllowFilteringIfNotSpecified(table))
373+
if (!allowFiltering && requiresAllowFilteringIfNotSpecified(table, false))
374374
throw invalidRequest(allowFilteringMessage(state));
375375
}
376376

@@ -381,14 +381,14 @@ else if (operator.requiresIndexing())
381381
validateSecondaryIndexSelections();
382382
}
383383

384-
public static boolean requiresAllowFilteringIfNotSpecified(TableMetadata metadata)
384+
public static boolean requiresAllowFilteringIfNotSpecified(TableMetadata metadata, boolean isPrimaryKey)
385385
{
386386
if (!metadata.isVirtual())
387387
return true;
388388

389389
VirtualTable tableNullable = VirtualKeyspaceRegistry.instance.getTableNullable(metadata.id);
390390
assert tableNullable != null;
391-
return !tableNullable.allowFilteringImplicitly();
391+
return isPrimaryKey ? !tableNullable.allowFilteringPrimaryKeysImplicitly() : !tableNullable.allowFilteringImplicitly();
392392
}
393393

394394
private void addRestriction(Restriction restriction, IndexRegistry indexRegistry, IndexHints indexHints)
@@ -593,7 +593,7 @@ private void processPartitionKeyRestrictions(ClientState state, boolean hasQueri
593593
// components must have a EQ. Only the last partition key component can be in IN relation.
594594
if (partitionKeyRestrictions.needFiltering())
595595
{
596-
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified(table))
596+
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified(table, true))
597597
throw new InvalidRequestException(allowFilteringMessage(state));
598598

599599
isKeyRange = true;

src/java/org/apache/cassandra/cql3/statements/SelectStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ private StatementRestrictions prepareRestrictions(ClientState state,
14741474
boundNames,
14751475
orderings,
14761476
selectsOnlyStaticColumns,
1477-
parameters.allowFiltering || !requiresAllowFilteringIfNotSpecified(metadata),
1477+
parameters.allowFiltering || !requiresAllowFilteringIfNotSpecified(metadata, true),
14781478
forView);
14791479
}
14801480

@@ -1700,7 +1700,7 @@ private void checkNeedsFiltering(TableMetadata table, StatementRestrictions rest
17001700
{
17011701
// We will potentially filter data if the row filter is not the identity and there isn't any index group
17021702
// supporting all the expressions in the filter.
1703-
if (requiresAllowFilteringIfNotSpecified(table))
1703+
if (requiresAllowFilteringIfNotSpecified(table, true))
17041704
checkFalse(restrictions.needFiltering(table), StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE);
17051705
}
17061706
}

src/java/org/apache/cassandra/db/PartitionRangeReadCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
647647
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
648648
{
649649
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
650-
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter(), rowFilter());
650+
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter(), rowFilter(), limits());
651651
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
652652
}
653653

src/java/org/apache/cassandra/db/SinglePartitionReadCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
15161516
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
15171517
{
15181518
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
1519-
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter(), rowFilter());
1519+
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter(), rowFilter(), limits());
15201520
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
15211521
}
15221522

0 commit comments

Comments
 (0)