private int preparedStatement ( Cassandra . Client client ) { Integer itemId = preparedStatements . get ( client ) ; if ( itemId == null ) { CqlPreparedResult result ; try { result = client . prepare_cql3_query ( ByteBufferUtil . bytes ( cql ) , Compression . NONE ) ; } catch ( InvalidRequestException e ) { throw new RuntimeException ( "failed to prepare cql query " + cql , e ) ; } catch ( TException e ) { throw new RuntimeException ( "failed to prepare cql query " + cql , e ) ; } Integer previousId = preparedStatements . putIfAbsent ( client , Integer . valueOf ( result . itemId ) ) ; itemId = previousId == null ? result . itemId : previousId ; } return itemId ; }
get prepared statement id from cache otherwise prepare it from Cassandra server