I think what I need is already captured in getIndexedValue... ignore
earlier email. I'll just need to try it out and if it works I'll provide
some information for others in the form of documentation. Thank you, -H

/**
 * Extract the value to be inserted into the index from the components
of the base data
 * @param partitionKey from the primary data
 * @param clustering from the primary data
 * @param path from the primary data
 * @param cellValue from the primary data
 * @return a ByteBuffer containing the value to be inserted in the
index. This will be used to make the partition
 * key in the index table
 */
protected abstract ByteBuffer getIndexedValue(ByteBuffer partitionKey,
                                              Clustering clustering,
                                              CellPath path,
                                              ByteBuffer cellValue);




On Mon, Mar 7, 2016 at 10:06 AM Henry Manasseh <henrymanm...@gmail.com>
wrote:

> From my review so far (I am new to the casssandra code base) it seems
> users could extend RegularColumnIndex, CollectionValueIndex, etc... but
> this will likely require being able to override the CassandraIndex.insert
> method which is currently private. My approach would be to de-serialize the
> cell, pick the fields I want to index and create a new Cell containing
> those fields only. I would them use the expr('custom_index', 'query_value')
> in my CQL for the query.
>
> An alternative would be to override the CassandraIndex.indexerFor and
> create a new Indexer but it seems like a lot of code to copy/paste unless
> there could also be a refactoring to extract the Indexer class into a class
> which could be extended so that the Indexer.insertRow could be overridden
> to perform the similar transformation on the Cell before adding the entry
> to the index.
>
> If the approach works, then user's could extend one of the index classes
> (RegularColumnIndex, CollectionValueIndex, etc...) and just override one
> method for transforming and inserting the entry to the index.
>
> Does, my approach seem like it would work? If yes, would it be worth it to
> make those two refactorings (make the CassandraIndex.insert method public
> or extract the in-lined indexer class in CassandraIndex.indexerFor so it
> can be extended (extension would be the Indexer.insertRow).
>
> Thank you,
> Henry
>
> These are the two CassandraIndex methods which would be refactored.
>
> /**
>  * Called when adding a new entry to the index
>  */
> private void insert(ByteBuffer rowKey,
>                     Clustering clustering,
>                     Cell cell,
>                     LivenessInfo info,
>                     OpOrder.Group opGroup)
>
>
> public Indexer indexerFor(final DecoratedKey key,
>                           final PartitionColumns columns,
>                           final int nowInSec,
>                           final OpOrder.Group opGroup,
>                           final IndexTransaction.Type transactionType)
>
>
>
>
>
>
> On Sun, Mar 6, 2016 at 8:58 PM Jack Krupansky <jack.krupan...@gmail.com>
> wrote:
>
>> Is RegularColumnIndex representative of what a typical custom index
>> needs... or not?
>>
>>
>> https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/index/internal/composites/RegularColumnIndex.java
>>
>> Ditto for CassandraIndex (abstract class) - should all (or at least most)
>> custom indexes extend it?
>>
>>
>> https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/index/internal/CassandraIndex.java
>>
>>
>> -- Jack Krupansky
>>
>> On Sun, Mar 6, 2016 at 11:03 PM, Henry Manasseh <henrymanm...@gmail.com>
>> wrote:
>>
>> > Thank you. This is a perfect class for to start experimenting with.
>> >
>> >
>> > On Sun, Mar 6, 2016 at 2:38 PM Sam Tunnicliffe <s...@beobal.com> wrote:
>> >
>> > > You might find o.a.c.i.StubIndex in the test source tree useful.
>> > > On 6 Mar 2016 19:24, "Henry Manasseh" <henrymanm...@gmail.com> wrote:
>> > >
>> > > > Hello,
>> > > > I was wondering if anyone is aware of a minimal reference
>> > implementation
>> > > > for a java class implementing a secondary index or some
>> documentation
>> > of
>> > > > the interface(s) I would need to implement (I looked at the SASI 2i
>> > code
>> > > > but I am trying to find the bare bones test or sample class for a
>> > newbie
>> > > if
>> > > > it exists).
>> > > >
>> > > > e.g. I am referring to the class you would use for
>> > > > 'path.to.the.IndexClass'.
>> > > >
>> > > > CREATE CUSTOM INDEX ON users (email) USING 'path.to.the.IndexClass';
>> > > > >
>> > > >
>> > > >
>> > > > I am trying to understand if it is possible to index a UDT
>> collection
>> > > based
>> > > > on only one field of the UDT and still use the cassandra index file
>> > > > management (I don't want to provide my own file storage). In other
>> > > words, I
>> > > > am looking to see if the custom index class can serve as a
>> > transformation
>> > > > function to only index my subfield. This probably will need a tweak
>> to
>> > > the
>> > > > CQL to prevent a syntax error but not concerned about that at the
>> > moment.
>> > > >
>> > > > Thank you for any helps and tips,
>> > > > Henry
>> > > >
>> > >
>> >
>>
>

Reply via email to