public static CqlPreparedResult prepare(String queryString, ThriftClientState clientState) throws RequestValidationException { logger.trace("CQL QUERY: {}", queryString); CQLStatement statement = getStatement(queryString); int statementId = makeStatementId(queryString); logger.trace("Discovered "+ statement.boundTerms + " bound variables."); clientState.getPrepared().put(statementId, statement); logger.trace(String.format("Stored prepared statement #%d with %d bind markers", statementId, statement.boundTerms)); if (!postPreparationHooks.isEmpty()) { PreparationContext context = new PreparationContext(clientState, queryString, statement); for (PostPreparationHook hook : postPreparationHooks) hook.processStatement(statement, context); } return new CqlPreparedResult(statementId, statement.boundTerms); }
public static CqlPreparedResult prepare(String queryString, ThriftClientState clientState) throws SyntaxException { logger.trace("CQL QUERY: {}", queryString); CQLStatement statement = getStatement(queryString); int statementId = makeStatementId(queryString); logger.trace("Discovered "+ statement.boundTerms + " bound variables."); clientState.getPrepared().put(statementId, statement); logger.trace(String.format("Stored prepared statement #%d with %d bind markers", statementId, statement.boundTerms)); return new CqlPreparedResult(statementId, statement.boundTerms); }
public static CqlPreparedResult prepare(String queryString, ThriftClientState clientState) throws InvalidRequestException, SyntaxException { logger.trace("CQL QUERY: {}", queryString); CQLStatement statement = getStatement(queryString); int statementId = makeStatementId(queryString); logger.trace("Discovered "+ statement.boundTerms + " bound variables."); clientState.getPrepared().put(statementId, statement); logger.trace(String.format("Stored prepared statement #%d with %d bind markers", statementId, statement.boundTerms)); return new CqlPreparedResult(statementId, statement.boundTerms); }
public CqlPreparedResult toThriftPreparedResult() { List<String> namesString = new ArrayList<String>(metadata.names.size()); List<String> typesString = new ArrayList<String>(metadata.names.size()); for (ColumnSpecification name : metadata.names) { namesString.add(name.toString()); typesString.add(name.type.toString()); } return new CqlPreparedResult(thriftStatementId, metadata.names.size()).setVariable_types(typesString).setVariable_names(namesString); }
protected Integer getPreparedStatement(CassandraClient client, String cqlQuery) throws Exception { Integer statementId = client.preparedStatements.get(cqlQuery.hashCode()); if (statementId == null) { CqlPreparedResult response = session.cqlVersion.startsWith("3") ? client.prepare_cql3_query(ByteBufferUtil.bytes(cqlQuery), Compression.NONE) : client.prepare_cql_query(ByteBufferUtil.bytes(cqlQuery), Compression.NONE); statementId = response.itemId; client.preparedStatements.put(cqlQuery.hashCode(), statementId); } return statementId; }