Skip to content
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

Support for priming based on variables in Batch queries #164

Open
razvanth opened this issue Jun 17, 2016 · 0 comments
Open

Support for priming based on variables in Batch queries #164

razvanth opened this issue Jun 17, 2016 · 0 comments

Comments

@razvanth
Copy link

We are currently facing an issue trying to prime a batch query using Scassandra based on specific variables. This is similar to the MultiPrime API that was added recently but this currently does not support batch queries.

We've come up with a proposed api for priming batch queries based on variables (you can find it below).

It's worth noting that at the moment in order to prime a batch which uses prepared statements, you need to prime the prepared statement and the batch separately (see http://scassandra-docs.readthedocs.io/en/latest/java/batches/http://scassandra-docs.readthedocs.io/en/latest/java/batches/ ).

The proposed API would only require priming once, although we're not sure whether this adds additional complexity.

Happy to take feedback based on this and/or if you have any ideas on how else to deliver this functionality.

String query = "INSERT INTO table_name(column_1, column_2,column_3) VALUES (?,?,?);";

        MultiPrimeBatchRequest prime = MultiPrimeBatchRequest.request()
                .withWhen(when().withQuery(query))
                .withThen(
                        MultiPrimeBatchRequest.then()
                                .withVariableTypes(VARCHAR, VARCHAR, VARCHAR)
                                .withOutcomes(
                                    outcome(
                                        match().withVariableMatchers(exactMatch("StringToMatch"), anyMatch(), anyMatch()),
                                        action().withResult(Result.success)
                                    ),
                                    outcome(
                                        match().withVariableMatchers(exactMatch("DifferentStringToMatch"), anyMatch(), anyMatch()),
                                        action().withResult(Result.config_error)
                                    )
                                )
                ).build();

        scassandra.primingClient().multiPrimeBatch(prime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant