@Override public String toString() { return "EXECUTE " + statementId + " with " + options.getValues().size() + " values at consistency " + options.getConsistency(); } }
private EnumSet<Flag> gatherFlags(QueryOptions options) { EnumSet<Flag> flags = EnumSet.noneOf(Flag.class); if (options.getValues().size() > 0) flags.add(Flag.VALUES); if (options.skipMetadata()) flags.add(Flag.SKIP_METADATA); if (options.getPageSize() >= 0) flags.add(Flag.PAGE_SIZE); if (options.getPagingState() != null) flags.add(Flag.PAGING_STATE); if (options.getSerialConsistency() != ConsistencyLevel.SERIAL) flags.add(Flag.SERIAL_CONSISTENCY); if (options.getSpecificOptions().timestamp != Long.MIN_VALUE) flags.add(Flag.TIMESTAMP); return flags; } }
public Terminal bind(QueryOptions options) throws InvalidRequestException { ByteBuffer value = options.getValues().get(bindIndex); if (value == null) return null; if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) return UNSET_VALUE; return Value.fromSerialized(value, (MapType)receiver.type, options.getProtocolVersion()); } }
public int encodedSize(QueryOptions options, int version) { int size = 0; size += CBUtil.sizeOfConsistencyLevel(options.getConsistency()); EnumSet<Flag> flags = gatherFlags(options); size += 1; if (flags.contains(Flag.VALUES)) size += CBUtil.sizeOfValueList(options.getValues()); if (flags.contains(Flag.PAGE_SIZE)) size += 4; if (flags.contains(Flag.PAGING_STATE)) size += CBUtil.sizeOfValue(options.getPagingState().serialize()); if (flags.contains(Flag.SERIAL_CONSISTENCY)) size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency()); if (flags.contains(Flag.TIMESTAMP)) size += 8; return size; }
if (options.getPageSize() == 0) throw new ProtocolException("The page size cannot be 0"); if (options.getPageSize() > 0) builder.put("page_size", Integer.toString(options.getPageSize())); if(options.getConsistency() != null) builder.put("consistency_level", options.getConsistency().name()); if(options.getSerialConsistency() != null) builder.put("serial_consistency_level", options.getSerialConsistency().name()); if (options.skipMetadata() && response instanceof ResultMessage.Rows) ((ResultMessage.Rows)response).result.metadata.setSkipMetadata();
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options) throws RequestExecutionException, RequestValidationException { CQL3CasRequest request = makeCasRequest(queryState, options); ColumnFamily result = StorageProxy.cas(keyspace(), columnFamily(), request.key, request, options.getSerialConsistency(), options.getConsistency(), queryState.getClientState()); return new ResultMessage.Rows(buildCasResultSet(request.key, result, options)); }
private ResultMessage.Rows execute(ReadQuery query, QueryOptions options, QueryState state, int nowInSec, int userLimit, long queryStartNanoTime) throws RequestValidationException, RequestExecutionException { try (PartitionIterator data = query.execute(options.getConsistency(), state.getClientState(), queryStartNanoTime)) { return processResults(data, options, nowInSec, userLimit); } }
public ResultMessage.Rows execute(QueryState state, QueryOptions options, long queryStartNanoTime) throws RequestExecutionException, RequestValidationException { ConsistencyLevel cl = options.getConsistency(); checkNotNull(cl, "Invalid empty consistency level"); cl.validateForRead(keyspace()); int nowInSec = FBUtilities.nowInSeconds(); int userLimit = getLimit(options); int userPerPartitionLimit = getPerPartitionLimit(options); int pageSize = options.getPageSize(); ReadQuery query = getQuery(options, nowInSec, userLimit, userPerPartitionLimit, pageSize); if (aggregationSpec == null && (pageSize <= 0 || (query.limits().count() <= pageSize))) return execute(query, options, state, nowInSec, userLimit, queryStartNanoTime); QueryPager pager = getPager(query, options); return execute(Pager.forDistributedQuery(pager, cl, state.getClientState()), options, pageSize, nowInSec, userLimit, queryStartNanoTime); }
public ResultMessage process(String queryString, QueryState queryState, QueryOptions options, long queryStartNanoTime) throws RequestExecutionException, RequestValidationException { ParsedStatement.Prepared p = getStatement(queryString, queryState.getClientState()); options.prepare(p.boundNames); CQLStatement prepared = p.statement; if (prepared.getBoundTerms() != options.getValues().size()) throw new InvalidRequestException("Invalid amount of bind variables"); if (!queryState.getClientState().isInternal) metrics.regularStatementsExecuted.inc(); return processStatement(prepared, queryState, options, queryStartNanoTime); }
/** * The {@code RowFilter} for this SELECT, assuming an internal call (no bound values in particular). */ public RowFilter rowFilterForInternalCalls() { return getRowFilter(QueryOptions.forInternalCalls(Collections.emptyList())); }
/** Serial consistency for conditional updates. */ public ConsistencyLevel getSerialConsistency() { return getSpecificOptions().serialConsistency; }
private QueryPager getPager(ReadQuery query, QueryOptions options) { QueryPager pager = query.getPager(options.getPagingState(), options.getProtocolVersion()); if (aggregationSpec == null || query == ReadQuery.EMPTY) return pager; return new AggregationQueryPager(pager, query.limits()); }
@Override public QueryOptions prepare(List<ColumnSpecification> specs) { wrapped.prepare(specs); return this; } }
@Override public String toString() { return "QUERY " + query + "[pageSize = " + options.getPageSize() + "]"; } }
private UDTBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException { super(condition.column, condition.operator); assert column.type.isUDT() && condition.field == null; assert condition.operator != Operator.IN; protocolVersion = options.getProtocolVersion(); value = condition.value.bindAndGet(options); }
public boolean skipMetadata() { return wrapped.skipMetadata(); }
public ConsistencyLevel getSerialConsistency() { return wrapped.getSerialConsistency(); }
public Terminal bind(QueryOptions options) throws InvalidRequestException { ByteBuffer value = options.getValues().get(bindIndex); if (value == null) return null; if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) return UNSET_VALUE; return Value.fromSerialized(value, (UserType) receiver.type); } }
public int encodedSize(QueryOptions options, ProtocolVersion version) { int size = 0; size += CBUtil.sizeOfConsistencyLevel(options.getConsistency()); EnumSet<Flag> flags = gatherFlags(options); size += (version.isGreaterOrEqualTo(ProtocolVersion.V5) ? 4 : 1); if (flags.contains(Flag.VALUES)) size += CBUtil.sizeOfValueList(options.getValues()); if (flags.contains(Flag.PAGE_SIZE)) size += 4; if (flags.contains(Flag.PAGING_STATE)) size += CBUtil.sizeOfValue(options.getPagingState().serializedSize(version)); if (flags.contains(Flag.SERIAL_CONSISTENCY)) size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency()); if (flags.contains(Flag.TIMESTAMP)) size += 8; return size; }
if (options.getPageSize() == 0) throw new ProtocolException("The page size cannot be 0"); if (options.getPageSize() > 0) builder.put("page_size", Integer.toString(options.getPageSize())); if(options.getConsistency() != null) builder.put("consistency_level", options.getConsistency().name()); if(options.getSerialConsistency() != null) builder.put("serial_consistency_level", options.getSerialConsistency().name()); if (options.skipMetadata() && response instanceof ResultMessage.Rows) ((ResultMessage.Rows)response).result.metadata.setSkipMetadata();