public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException { state.hasColumnFamilyAccess(keyspace(), columnFamily(), Permission.SELECT); }
public ResultSet.Metadata getResultMetadata() { return parameters.isCount ? ResultSet.makeCountMetadata(keyspace(), columnFamily(), parameters.countAlias) : selection.getResultMetadata(); }
private Query createQuery(final long startTime, final long execTime, final String queryString, final SelectStatement statement, final QueryState queryState, final QueryOptions options) { return Query.create(startTime, execTime, queryState.getClientState().getRemoteAddress().toString(), Query.StatementType.SELECT, statement.keyspace(), statement.columnFamily(), queryString, extractConsistencyLevel(options)); }
private Query createQuery(final long startTime, final long execTime, final String queryString, final SelectStatement statement, final QueryState queryState, final QueryOptions options) { return Query.create(startTime, execTime, queryState.getClientState().getRemoteAddress().toString(), Query.StatementType.SELECT, statement.keyspace(), statement.columnFamily(), queryString, extractConsistencyLevel(options)); }
private Query createQuery(final long startTime, final long execTime, final String queryString, final SelectStatement statement, final QueryState queryState, final QueryOptions options) { return Query.create(startTime, execTime, queryState.getClientState().getRemoteAddress().toString(), Query.StatementType.SELECT, statement.keyspace(), statement.columnFamily(), queryString, extractConsistencyLevel(options)); }
/** * May be used by custom QueryHandler implementations */ public RowFilter getRowFilter(QueryOptions options) throws InvalidRequestException { ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(columnFamily()); SecondaryIndexManager secondaryIndexManager = cfs.indexManager; RowFilter filter = restrictions.getRowFilter(secondaryIndexManager, options); return filter; }
private Query createQuery(final long startTime, final long execTime, final String queryString, final SelectStatement statement, final QueryState queryState, final QueryOptions options) { return Query.create(startTime, execTime, queryState.getClientState().getRemoteAddress().toString(), Query.StatementType.SELECT, statement.keyspace(), statement.columnFamily(), queryString, extractConsistencyLevel(options)); }
/** * May be used by custom QueryHandler implementations */ public RowFilter getRowFilter(QueryOptions options) throws InvalidRequestException { ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(columnFamily()); SecondaryIndexManager secondaryIndexManager = cfs.indexManager; RowFilter filter = restrictions.getRowFilter(secondaryIndexManager, options); return filter; }
private ResultMessage.Rows pageCountQuery(QueryPager pager, QueryOptions options, int pageSize, long now, int limit) throws RequestValidationException, RequestExecutionException { int count = 0; while (!pager.isExhausted()) { int maxLimit = pager.maxRemaining(); logger.debug("New maxLimit for paged count query is {}", maxLimit); ResultSet rset = process(pager.fetchPage(pageSize), options, maxLimit, now); count += rset.rows.size(); } // We sometimes query one more result than the user limit asks to handle exclusive bounds with compact tables (see updateLimitForQuery). // So do make sure the count is not greater than what the user asked for. ResultSet result = ResultSet.makeCountResult(keyspace(), columnFamily(), Math.min(count, limit), parameters.countAlias); return new ResultMessage.Rows(result); }
/** * May be used by custom QueryHandler implementations */ public RowFilter getRowFilter(QueryOptions options) throws InvalidRequestException { ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(columnFamily()); SecondaryIndexManager secondaryIndexManager = cfs.indexManager; RowFilter filter = restrictions.getRowFilter(secondaryIndexManager, options); return filter; }
private List<ReadCommand> getSliceCommands(QueryOptions options, int limit, long now) throws RequestValidationException { Collection<ByteBuffer> keys = getKeys(options); if (keys.isEmpty()) // in case of IN () for (the last column of) the partition key. return null; List<ReadCommand> commands = new ArrayList<>(keys.size()); IDiskAtomFilter filter = makeFilter(options, limit); if (filter == null) return null; // Note that we use the total limit for every key, which is potentially inefficient. // However, IN + LIMIT is not a very sensible choice. for (ByteBuffer key : keys) { QueryProcessor.validateKey(key); // We should not share the slice filter amongst the commands (hence the cloneShallow), due to // SliceQueryFilter not being immutable due to its columnCounter used by the lastCounted() method // (this is fairly ugly and we should change that but that's probably not a tiny refactor to do that cleanly) commands.add(ReadCommand.create(keyspace(), ByteBufferUtil.clone(key), columnFamily(), now, filter.cloneShallow())); } return commands; }
statementKsName = selectStatement.keyspace(); statementCfName = selectStatement.columnFamily();
statementKsName = selectStatement.keyspace(); statementCfName = selectStatement.columnFamily();
private RangeSliceCommand getRangeCommand(QueryOptions options, int limit, long now) throws RequestValidationException { IDiskAtomFilter filter = makeFilter(options, limit); if (filter == null) return null; List<IndexExpression> expressions = getValidatedIndexExpressions(options); // The LIMIT provided by the user is the number of CQL row he wants returned. // We want to have getRangeSlice to count the number of columns, not the number of keys. AbstractBounds<RowPosition> keyBounds = getKeyBounds(options); return keyBounds == null ? null : new RangeSliceCommand(keyspace(), columnFamily(), now, filter, keyBounds, expressions, limit, !parameters.isDistinct, false); }
public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException { if (cfm.isView()) { CFMetaData baseTable = View.findBaseTable(keyspace(), columnFamily()); if (baseTable != null) state.hasColumnFamilyAccess(baseTable, Permission.SELECT); } else { state.hasColumnFamilyAccess(cfm, Permission.SELECT); } for (Function function : getFunctions()) state.ensureHasPermission(Permission.EXECUTE, function); }
public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException { if (cfm.isView()) { CFMetaData baseTable = View.findBaseTable(keyspace(), columnFamily()); if (baseTable != null) state.hasColumnFamilyAccess(baseTable, Permission.SELECT); } else { state.hasColumnFamilyAccess(cfm, Permission.SELECT); } for (Function function : getFunctions()) state.ensureHasPermission(Permission.EXECUTE, function); }
public void checkAccess(ClientState state) throws InvalidRequestException, UnauthorizedException { if (cfm.isView()) { CFMetaData baseTable = View.findBaseTable(keyspace(), columnFamily()); if (baseTable != null) state.hasColumnFamilyAccess(baseTable, Permission.SELECT); } else { state.hasColumnFamilyAccess(cfm, Permission.SELECT); } for (Function function : getFunctions()) state.ensureHasPermission(Permission.EXECUTE, function); }
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.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.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); }