-
Notifications
You must be signed in to change notification settings - Fork 22
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
CNDB-12425: A few reproduction tests and a preliminary patch, WIP #1529
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,9 @@ | |
*/ | ||
public class ANNOptions | ||
{ | ||
public static final String REQUIRES_HIGHER_MESSAGING_VERSION = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
"ANN options are not supported in clusters below DS 11."; | ||
|
||
public static final String RERANK_K_OPTION_NAME = "rerank_k"; | ||
|
||
public static final ANNOptions NONE = new ANNOptions(null); | ||
|
@@ -79,7 +82,7 @@ public static ANNOptions fromMap(Map<String, String> map) | |
if (MessagingService.current_version < MessagingService.VERSION_DS_11) | ||
badNodes.add(FBUtilities.getBroadcastAddressAndPort()); | ||
if (!badNodes.isEmpty()) | ||
throw new InvalidRequestException("ANN options are not supported in clusters below DS 11."); | ||
throw new InvalidRequestException(REQUIRES_HIGHER_MESSAGING_VERSION); | ||
|
||
Integer rerankK = null; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,13 +79,16 @@ public class RowFilter | |
private static final Logger logger = LoggerFactory.getLogger(RowFilter.class); | ||
|
||
public static final Serializer serializer = new Serializer(); | ||
public static final RowFilter NONE = new RowFilter(FilterElement.NONE); | ||
public static final RowFilter NONE = new RowFilter(FilterElement.NONE, false); | ||
|
||
private final FilterElement root; | ||
|
||
protected RowFilter(FilterElement root) | ||
public final boolean allowFiltering; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a mixed use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
protected RowFilter(FilterElement root, boolean allowFitlering) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: s/allowFitlering/allowFiltering |
||
{ | ||
this.root = root; | ||
this.allowFiltering = allowFitlering; | ||
} | ||
|
||
public FilterElement root() | ||
|
@@ -294,7 +297,7 @@ public RowFilter without(Expression expression) | |
if (root.size() == 1) | ||
return RowFilter.NONE; | ||
|
||
return new RowFilter(root.filter(e -> !e.equals(expression))); | ||
return new RowFilter(root.filter(e -> !e.equals(expression)), allowFiltering); | ||
} | ||
|
||
public RowFilter withoutExpressions() | ||
|
@@ -307,12 +310,12 @@ public RowFilter withoutExpressions() | |
*/ | ||
public RowFilter withoutDisjunctions() | ||
{ | ||
return new RowFilter(root.withoutDisjunctions()); | ||
return new RowFilter(root.withoutDisjunctions(), allowFiltering); | ||
} | ||
|
||
public RowFilter restrict(Predicate<Expression> filter) | ||
{ | ||
return new RowFilter(root.filter(filter)); | ||
return new RowFilter(root.filter(filter), allowFiltering); | ||
} | ||
|
||
public boolean isEmpty() | ||
|
@@ -328,28 +331,30 @@ public String toString() | |
|
||
public static Builder builder() | ||
{ | ||
return new Builder(null); | ||
return new Builder(null, false); | ||
} | ||
|
||
public static Builder builder(IndexRegistry indexRegistry) | ||
public static Builder builder(IndexRegistry indexRegistry, boolean allowFitlering) | ||
{ | ||
return new Builder(indexRegistry); | ||
return new Builder(indexRegistry, allowFitlering); | ||
} | ||
|
||
public static class Builder | ||
{ | ||
private FilterElement.Builder current = new FilterElement.Builder(false); | ||
|
||
private final IndexRegistry indexRegistry; | ||
private final Boolean allowFiltering; | ||
|
||
public Builder(IndexRegistry indexRegistry) | ||
public Builder(IndexRegistry indexRegistry, boolean allowFiltering) | ||
{ | ||
this.indexRegistry = indexRegistry; | ||
this.allowFiltering = allowFiltering; | ||
} | ||
|
||
public RowFilter build() | ||
{ | ||
return new RowFilter(current.build()); | ||
return new RowFilter(current.build(), allowFiltering); | ||
} | ||
|
||
public RowFilter buildFromRestrictions(StatementRestrictions restrictions, | ||
|
@@ -363,7 +368,7 @@ public RowFilter buildFromRestrictions(StatementRestrictions restrictions, | |
if (Guardrails.queryFilters.enabled(queryState)) | ||
Guardrails.queryFilters.guard(root.numFilteredValues(), "Select query", false, queryState); | ||
|
||
return new RowFilter(root); | ||
return new RowFilter(root, allowFiltering); | ||
} | ||
|
||
private FilterElement doBuild(StatementRestrictions restrictions, | ||
|
@@ -420,7 +425,7 @@ public void addAllAsConjunction(Consumer<Builder> addToRowFilterDelegate) | |
{ | ||
// If we're in disjunction mode, we must not pass the current builder to addToRowFilter. | ||
// We create a new conjunction sub-builder instead and add all expressions there. | ||
var builder = new Builder(indexRegistry); | ||
var builder = new Builder(indexRegistry, allowFiltering); | ||
addToRowFilterDelegate.accept(builder); | ||
|
||
if (builder.current.expressions.size() == 1 && builder.current.children.isEmpty()) | ||
|
@@ -1836,19 +1841,22 @@ public void serialize(RowFilter filter, DataOutputPlus out, int version) throws | |
{ | ||
out.writeBoolean(false); // Old "is for thrift" boolean | ||
FilterElement.serializer.serialize(filter.root, out, version); | ||
out.writeBoolean(filter.allowFiltering); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should depend on the messaging version |
||
} | ||
|
||
public RowFilter deserialize(DataInputPlus in, int version, TableMetadata metadata) throws IOException | ||
{ | ||
in.readBoolean(); // Unused | ||
FilterElement operation = FilterElement.serializer.deserialize(in, version, metadata); | ||
return new RowFilter(operation); | ||
boolean allowFiltering = in.readBoolean(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should depend on the messaging version |
||
return new RowFilter(operation, allowFiltering); | ||
} | ||
|
||
public long serializedSize(RowFilter filter, int version) | ||
{ | ||
return 1 // unused boolean | ||
+ FilterElement.serializer.serializedSize(filter.root, version); | ||
+ FilterElement.serializer.serializedSize(filter.root, version) | ||
+ 1; // for allowFiltering | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should depend on the messaging version. Also, it's probably better to use |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -807,6 +807,17 @@ Indexer indexerFor(Predicate<Index> indexSelector, | |
@Nullable | ||
QueryPlan queryPlanFor(RowFilter rowFilter); | ||
|
||
/** | ||
* Returns a new {@link QueryPlan} for the specified {@link RowFilter} and set of {@link Index}, or {@code null} | ||
* if none of the indexes in this group supports the expression in the row filter. | ||
* | ||
* @param rowFilter a row filter | ||
* @param indexes a set of indexes | ||
* @return a new query plan for the specified {@link RowFilter} and {@link Index}, {@code null} otherwise | ||
*/ | ||
@Nullable | ||
QueryPlan queryPlanForIndices(RowFilter rowFilter, Set<Index> indexes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still thinking about how could make this the only method and get rid of |
||
|
||
/** | ||
* Get flush observer to observe partition/cell events generated by flushing SSTable (memtable flush or compaction). | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collapsed the two ifs, no need of nesting here