[
https://issues.apache.org/jira/browse/CASSANDRA-6870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13941391#comment-13941391
]
Edward Capriolo commented on CASSANDRA-6870:
--------------------------------------------
I have made a few more commits on my branch.
Transform now supports two operations can apply two different approaches.
1) The original operator performed an operation on the entire ColumnFamily
2) We can now specify 0 or more column transforms these look like this
{code}
ColumnTransform incrementColumnA = new ColumnTransform();
incrementColumnA.setFunction_name("increment");
incrementColumnA.setInput_columns(Arrays.asList(ByteBufferUtil.bytes("a")));
incrementColumnA.setOutput_column(ByteBufferUtil.bytes("a"));
{code}
This class also supports
{code}
concatAandB.setPersist(false);
{code}
Which is used to chain the results of transforms together without saying them
to the final result set.
UDF for increment and udf for conat is provided inside this patch.
If you check out the FuncTest you can see us implementing something similar to
{code}
update standard1 set a = increment(increment(a)) , set yy =
concat(concat(a,b),a) where rowkey = "row5"
{code}
This can be done because the ColumnTranforms are executed in order and can use
the results from other transforms.
{code}
TransformRequest request = new TransformRequest();
request.setColumn_family("Standard1");
request.setKey(ByteBufferUtil.bytes(rowkey));
request.setPredicate(new SlicePredicate());
request.getPredicate().setColumn_names(Arrays.asList(ByteBufferUtil.bytes("a"),ByteBufferUtil.bytes("b")));
ColumnTransform incrementColumnA = new ColumnTransform();
incrementColumnA.setFunction_name("increment");
incrementColumnA.setInput_columns(Arrays.asList(ByteBufferUtil.bytes("a")));
incrementColumnA.setOutput_column(ByteBufferUtil.bytes("a"));
...
request.setColumn_transform(Arrays.asList(incrementColumnA,
incrementColumnA, concatAandB, concatZZandA));
{code}
> Transform operation
> -------------------
>
> Key: CASSANDRA-6870
> URL: https://issues.apache.org/jira/browse/CASSANDRA-6870
> Project: Cassandra
> Issue Type: New Feature
> Reporter: Edward Capriolo
> Assignee: Edward Capriolo
> Priority: Minor
>
> Compare and swap uses paxos to only update a value only if some criteria is
> met. If I understand correctly we should be able to use this feature to
> provide a wider variety of server side operations.
> For example inside a paxos transaction performing a slice and then using a
> function to manipulate the slice. You could accomplish features like append
> and increment this way without user needing to know the current value.
> I took a stab at doing this. I **think** I did it correctly. Comments welcome.
--
This message was sent by Atlassian JIRA
(v6.2#6252)