Fix Version/s: 2.1.6
Java driver 2.1.6
Currently whenever client calls session.prepare(Statement), the Java driver prepares the statement with cassandra. Cassandra prepares the statement, caches in memory and returns prepareId. The driver caches it in the session and uses it subsequently.
In case, we have another session (as in web application or REST services, there are multiple JVM and so different cluster and session instances), currently we need reprepare the same query for which we need the original query string and other details (like consistency level and so on).
Since cassandra is already caching in memory (also a ticket is there to persist as well in 3.x), we can have an API to load the preparestatement from any session (if not there in the cache already) as below
where the driver can call Cassandra and load the preparedstatement (to get metadata, resultSetMetadata, routingKeyIndexes etc...).
WIth this, the client need to cache only the prepareId and can avoid multiple round trip to prepare the query (same query) again with different hosts.