[
https://issues.apache.org/jira/browse/CASSANDRA-11295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sam Tunnicliffe updated CASSANDRA-11295:
----------------------------------------
Attachment: DummyFilteringRestrictions.java
[~henryman], you can attach a {{UserExpression}} to a query using an
implementation of {{o.a.c.cql3.restrictions.Restrictions}} which adds it to the
row filter when the query is executed. This is obviously a bit clunky and the
interface can surely be improved, but bear in mind that this is a first pass at
a pretty low-level api, so things can (and probably will) change. I've attached
a sample class which to illustrate. The way to use it in your {{QueryHandler}}
would be something like:
{code}
// Register custom expression class
static
{
RowFilter.UserExpression.register(DummyFilteringRestrictions.DummyFilteringExpression.class,
new
DummyFilteringRestrictions.DummyFilteringExpression.Deserializer());
}
public ResultMessage process(String query,
QueryState state,
QueryOptions options,
Map<String, ByteBuffer> customPayload)
throws RequestExecutionException, RequestValidationException
{
ParsedStatement.Prepared parsed = QueryProcessor.getStatement(query,
state.getClientState());
if (parsed.statement instanceof SelectStatement)
{
((SelectStatement) parsed.statement).getRestrictions()
.getIndexRestrictions()
.add(new
DummyFilteringRestrictions());
}
return QueryProcessor.instance.processStatement(parsed.statement,
state, options);
}
{code}
of course you'd also need to handle prepared statements, doing basically the
exact same thing in {{processPrepared}}.
> Make custom filtering more extensible via custom classes
> ---------------------------------------------------------
>
> Key: CASSANDRA-11295
> URL: https://issues.apache.org/jira/browse/CASSANDRA-11295
> Project: Cassandra
> Issue Type: Improvement
> Components: Local Write-Read Paths
> Reporter: Sam Tunnicliffe
> Assignee: Sam Tunnicliffe
> Priority: Minor
> Fix For: 3.6
>
> Attachments: DummyFilteringRestrictions.java
>
>
> At the moment, the implementation of {{RowFilter.CustomExpression}} is
> tightly bound to the syntax designed to support non-CQL search syntax for
> custom 2i implementations. It might be interesting to decouple the two things
> by making the custom expression implementation and serialization a bit more
> pluggable. This would allow users to add their own custom expression
> implementations to experiment with custom filtering strategies without having
> to patch the C* source. As a minimally invasive first step, custom
> expressions could be added programmatically via {{QueryHandler}}. Further
> down the line, if this proves useful and we can figure out some reasonable
> syntax we could think about adding the capability in CQL in a separate
> ticket.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)