cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sam Tunnicliffe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CASSANDRA-11458) Complete support for CustomExpression
Date Wed, 30 Mar 2016 08:38:25 GMT

    [ https://issues.apache.org/jira/browse/CASSANDRA-11458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15217662#comment-15217662
] 

Sam Tunnicliffe commented on CASSANDRA-11458:
---------------------------------------------

Custom expressions as implemented by CASSANDRA-10217 are intended for use by custom indexes.
Only a single custom expression is permitted per query and we validate that the index referred
to is a valid one, so when the query is executed on each replica we know that an index lookup
will be performed rather than a simple read from the base table. So you would implement your
custom lookup code (in your case, the "type of "IN" query filter") in the {{Searcher}} provided
by your custom index implementation. What kind of lookup does your custom index implementation
perform and is it not possible to incorporate that "IN" filtering into that?

As you've seen, {{isSatisfiedBy}} is used for performing additional filtering of the results
of a query (at that point, whether the results came from an index lookup or from a direct
read of the base table is immaterial). The fact that the {{CustomExpression::isSatisfiedBy}}
is even relevant is somewhat incorrect as I'd expect the expression to be removed from the
row filter by your index's implementation of {{getPostIndexQueryFilter}}. It seems that maybe
what you really want is to be able to add a custom filter without necessitating the use of
a custom index. CASSANDRA-11295 provides a first version of that, though in that first version
the filters can only be added programmatically and not via CQL, so this might not be enough
for your use case. Perhaps you could comment there if you have some thoughts on a suitable
syntax for that.

As a general point, the best way to get feedback on your approach would be to attach a patch
for your prototype.


> Complete support for CustomExpression
> -------------------------------------
>
>                 Key: CASSANDRA-11458
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11458
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Henry Manasseh
>            Priority: Minor
>         Attachments: Custom-expression-Change.png, addCustomIndexExpression change.png
>
>
> This is a proposal to complete the CustomExpression support first introduced as part
of https://issues.apache.org/jira/browse/CASSANDRA-10217.
> The current support for custom expressions is partial. There is no clean way to implement
queries making use of the "exp('index', 'value)" syntax due to the fact CustomExpression is
declared as final and there is no way to for developers to cleanly plug-in their own expressions.
> https://github.com/apache/cassandra/blob/6e69c75900f3640195130085ad69daa1659184eb/src/java/org/apache/cassandra/db/filter/RowFilter.java#L869
> The proposal is to make CustomExpression not final so that developers can extend and
create their own subclass and provide their own isSatisfiedBy operation (which currently always
returns true).
> Introducing a new custom expression would be done as follows:
> 1. Developer would create a subclass of CustomExpression and override isSatisfiedBy method
with their logic (public boolean isSatisfiedBy(CFMetaData metadata, DecoratedKey partitionKey,
Row row))
> 2. This class would be packaged in a jar and copied to the cassandra lib directory along
with a secondary index class which overrides Index.customExpressionValueType
> 2. Create the custom index with an option which identifies the CustomExpression subclass
(custom_expression_class).
> CREATE CUSTOM INDEX ON keyspace.my_table(my_indexed_column) USING 'org.custom.MyCustomIndex'
> WITH OPTIONS = { 'custom_expression_class': 'org.custom.MyCustomExpression' };
> I have prototyped the change and works as designed. In my case I do a type of "IN" query
filter which will simplify my client logic significantly.
> The default behavior of using the CustomExpression class would be maintained if the developer
does not provide a custom class in the create index options.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message