/** {@inheritDoc} */ @Override public String getQueryString() { return st.getQueryString(); }
/** * Tunes CQL statement execution options (consistency level, fetch option and etc.). * * @param statement Statement. * @return Modified statement. */ private Statement tuneStatementExecutionOptions(Statement statement) { String qry = ""; if (statement instanceof BoundStatement) qry = ((BoundStatement)statement).preparedStatement().getQueryString().trim().toLowerCase(); else if (statement instanceof PreparedStatement) qry = ((PreparedStatement)statement).getQueryString().trim().toLowerCase(); boolean readStatement = qry.startsWith("select"); boolean writeStatement = statement instanceof Batch || statement instanceof BatchStatement || qry.startsWith("insert") || qry.startsWith("delete") || qry.startsWith("update"); if (readStatement && readConsistency != null) statement.setConsistencyLevel(readConsistency); if (writeStatement && writeConsistency != null) statement.setConsistencyLevel(writeConsistency); if (fetchSize != null) statement.setFetchSize(fetchSize); return statement; }
logger.debug(stmt.getQueryString()); logger.debug("key = {}", key);
logger.debug(stmt.getQueryString()); logger.debug("startKey = {}, recordcount = {}", startkey, recordcount);
logger.debug(stmt.getQueryString()); logger.debug("key = {}", key); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
logger.debug(stmt.getQueryString()); logger.debug("key = {}", key); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
logger.debug(stmt.getQueryString()); logger.debug("key = {}", key);
if (statement instanceof BoundStatement) { BoundStatement bs = ((BoundStatement) statement); md.update(bs.preparedStatement().getQueryString().getBytes()); values = bs.wrapper.values; } else {
public PreparedStatement addPrepared(PreparedStatement stmt) { PreparedStatement previous = preparedQueries.putIfAbsent(stmt.getPreparedId().boundValuesMetadata.id, stmt); if (previous != null) { logger.warn( "Re-preparing already prepared query is generally an anti-pattern and will likely affect performance. " + "Consider preparing the statement only once. Query='{}'", stmt.getQueryString()); // The one object in the cache will get GCed once it's not referenced by the client anymore // since we use a weak reference. // So we need to make sure that the instance we do return to the user is the one that is in // the cache. // However if the result metadata changed since the last PREPARE call, this also needs to be // updated. previous.getPreparedId().resultSetMetadata = stmt.getPreparedId().resultSetMetadata; return previous; } return stmt; }
private ListenableFuture<PreparedStatement> prepare( final PreparedStatement statement, InetSocketAddress toExclude) { final String query = statement.getQueryString(); List<ListenableFuture<Response>> futures = Lists.newArrayListWithExpectedSize(pools.size()); for (final Map.Entry<Host, HostConnectionPool> entry : pools.entrySet()) {
perKeyspace.put(keyspace, ps.getQueryString());
remaining = append( ((BoundStatement) statement).preparedStatement().getQueryString().trim(), buffer, remaining);
toPrepare.getQueryKeyspace(), connection.keyspace(), toPrepare.getQueryString())); "Query {} is not prepared on {}, preparing before retrying executing. " + "Seeing this message a few times is fine, but seeing it a lot may be source of performance problems", toPrepare.getQueryString(), connection.address); write(connection, prepareAndRetry(toPrepare.getQueryString()));
private String debugSelectTraceIdsByDuration(String serviceName, String spanName, long minDuration, long maxDuration, int limit) { return selectTraceIdsBySpanDuration.getQueryString() .replace(":service_name", serviceName) .replace(":span_name", spanName) .replace(":max_duration", String.valueOf(maxDuration)) .replace(":min_duration", String.valueOf(minDuration)) .replace(":limit_", String.valueOf(limit)); }
private String debugSelectTraceIdsBySpanName(String serviceSpanName, long startTs, long endTs, int limit) { return selectTraceIdsByServiceName.getQueryString() .replace(":service_span_name", serviceSpanName) .replace(":start_ts", new Date(startTs / 1000).toString()) .replace(":end_ts", new Date(endTs / 1000).toString()) .replace(":limit_", String.valueOf(limit)); }
private String debugSelectTraceIdsByServiceName(List<String> serviceNames, long startTs, long endTs, int limit) { return selectTraceIdsByServiceName.getQueryString() .replace(":service_name", String.valueOf(serviceNames)) .replace(":start_ts", new Date(startTs / 1000).toString()) .replace(":end_ts", new Date(endTs / 1000).toString()) .replace(":limit_", String.valueOf(limit)); }
private String debugInsertSpan(long traceId, long timestamp, String spanName, ByteBuffer span, int ttl) { return insertSpan.getQueryString() .replace(":trace_id", String.valueOf(traceId)) .replace(":ts", String.valueOf(timestamp)) .replace(":span_name", spanName) .replace(":span", Bytes.toHexString(span)) .replace(":ttl_", String.valueOf(ttl)); }
private String debugInsertTraceIdBySpanDuration(String serviceName, String spanName, long timestamp, long duration, long traceId, int ttl) { return insertTraceIdBySpanDuration.getQueryString() .replace(":service_name", serviceName) .replace(":span_name", spanName) .replace(":bucket", String.valueOf(durationIndexBucket(timestamp))) .replace(":ts", new Date(timestamp / 1000).toString()) .replace(":duration", String.valueOf(duration)) .replace(":trace_id", String.valueOf(traceId)) .replace(":ttl_", String.valueOf(ttl)); }
public PreparedStatement addPrepared(PreparedStatement stmt) { PreparedStatement previous = preparedQueries.putIfAbsent(stmt.getPreparedId().id, stmt); if (previous != null) { logger.warn("Re-preparing already prepared query {}. Please note that preparing the same query more than once is " + "generally an anti-pattern and will likely affect performance. Consider preparing the statement only once.", stmt.getQueryString()); // The one object in the cache will get GCed once it's not referenced by the client anymore since we use a weak reference. // So we need to make sure that the instance we do return to the user is the one that is in the cache. return previous; } return stmt; }
/** * Make sure the CQL is prepared by the correct Cluster. * * @since 0.2.5 */ private static PreparedStatement ensurePrepareStatement(Session session, PreparedStatement pstm) { final String cql = pstm.getQueryString(); return prepareStatement(session, cql); }