当前位置: 首页>>代码示例>>Java>>正文


Java ResultMessage类代码示例

本文整理汇总了Java中org.apache.cassandra.transport.messages.ResultMessage的典型用法代码示例。如果您正苦于以下问题:Java ResultMessage类的具体用法?Java ResultMessage怎么用?Java ResultMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ResultMessage类属于org.apache.cassandra.transport.messages包,在下文中一共展示了ResultMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeWithCondition

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> keys = buildPartitionKeyNames(options);
    // We don't support IN for CAS operation so far
    if (keys.size() > 1)
        throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");

    ByteBuffer key = keys.get(0);
    long now = options.getTimestamp(queryState);
    Composite prefix = createClusteringPrefix(options);

    CQL3CasRequest request = new CQL3CasRequest(cfm, key, false);
    addConditions(prefix, request, options);
    request.addRowUpdate(prefix, this, options, now);

    ColumnFamily result = StorageProxy.cas(keyspace(),
                                           columnFamily(),
                                           key,
                                           request,
                                           options.getSerialConsistency(),
                                           options.getConsistency(),
                                           queryState.getClientState());
    return new ResultMessage.Rows(buildCasResultSet(key, result, options));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:ModificationStatement.java

示例2: execute

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage execute(ClientState state) throws RequestValidationException, RequestExecutionException
{
    List<PermissionDetails> details = new ArrayList<PermissionDetails>();

    if (resource != null && recursive)
    {
        for (IResource r : Resources.chain(resource))
            details.addAll(list(state, r));
    }
    else
    {
        details.addAll(list(state, resource));
    }

    Collections.sort(details);
    return resultMessage(details);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:ListPermissionsStatement.java

示例3: addPermissionsForRole

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
private void addPermissionsForRole(Set<Permission> permissions, IResource resource, RoleResource role)
throws RequestExecutionException, RequestValidationException
{
    QueryOptions options = QueryOptions.forInternalCalls(ConsistencyLevel.LOCAL_ONE,
                                                         Lists.newArrayList(ByteBufferUtil.bytes(role.getRoleName()),
                                                                            ByteBufferUtil.bytes(resource.getName())));

    // If it exists, read from the legacy user permissions table to handle the case where the cluster
    // is being upgraded and so is running with mixed versions of the authz schema
    SelectStatement statement = Schema.instance.getCFMetaData(AuthKeyspace.NAME, USER_PERMISSIONS) == null
                                ? authorizeRoleStatement
                                : legacyAuthorizeRoleStatement;
    ResultMessage.Rows rows = statement.execute(QueryState.forInternalCalls(), options) ;
    UntypedResultSet result = UntypedResultSet.create(rows.result);

    if (!result.isEmpty() && result.one().has(PERMISSIONS))
    {
        for (String perm : result.one().getSet(PERMISSIONS, UTF8Type.instance))
        {
            permissions.add(Permission.valueOf(perm));
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CassandraAuthorizer.java

示例4: execute

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public static UntypedResultSet execute(String query, ConsistencyLevel cl, QueryState state, Object... values)
throws RequestExecutionException
{
    try
    {
        ParsedStatement.Prepared prepared = prepareInternal(query);
        ResultMessage result = prepared.statement.execute(state, makeInternalOptions(prepared, values, cl));
        if (result instanceof ResultMessage.Rows)
            return UntypedResultSet.create(((ResultMessage.Rows)result).result);
        else
            return null;
    }
    catch (RequestValidationException e)
    {
        throw new RuntimeException("Error validating " + query, e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:QueryProcessor.java

示例5: execute

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
private ResultMessage.Rows execute(Pageable command, QueryOptions options, int limit, long now, QueryState state) throws RequestValidationException, RequestExecutionException
{
    List<Row> rows;
    if (command == null)
    {
        rows = Collections.<Row>emptyList();
    }
    else
    {
        rows = command instanceof Pageable.ReadCommands
             ? StorageProxy.read(((Pageable.ReadCommands)command).commands, options.getConsistency(), state.getClientState())
             : StorageProxy.getRangeSlice((RangeSliceCommand)command, options.getConsistency());
    }

    return processResults(rows, options, limit, now);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:SelectStatement.java

示例6: pageCountQuery

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:17,代码来源:SelectStatement.java

示例7: executeWithCondition

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    CQL3CasRequest request = makeCasRequest(queryState, options);

    try (RowIterator result = StorageProxy.cas(keyspace(),
                                               columnFamily(),
                                               request.key,
                                               request,
                                               options.getSerialConsistency(),
                                               options.getConsistency(),
                                               queryState.getClientState()))
    {
        return new ResultMessage.Rows(buildCasResultSet(result, options));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:ModificationStatement.java

示例8: thriftHandler

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
@Override
public Function<ResultMessage, byte[][]> thriftHandler()
{
    return new Function<ResultMessage, byte[][]>()
    {

        @Override
        public byte[][] apply(ResultMessage result)
        {
            if (result instanceof ResultMessage.Rows)
            {
                ResultMessage.Rows rows = ((ResultMessage.Rows) result);
                byte[][] r = new byte[rows.result.size()][];
                for (int i = 0 ; i < r.length ; i++)
                    r[i] = rows.result.rows.get(i).get(0).array();
                return r;
            }
            return null;
        }
    };
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:CqlOperation.java

示例9: executeCQL

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
private Set<String> executeCQL(String rawStatement) throws Exception
{
    SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(rawStatement).prepare().statement;
    ResultMessage.Rows cqlRows = statement.executeInternal(QueryState.forInternalCalls(), new QueryOptions(ConsistencyLevel.LOCAL_ONE, Collections.<ByteBuffer>emptyList()));

    Set<String> results = new TreeSet<>();
    for (CqlRow row : cqlRows.toThriftResult().getRows())
    {
        for (org.apache.cassandra.thrift.Column col : row.columns)
        {
            String columnName = UTF8Type.instance.getString(col.bufferForName());
            if (columnName.equals("key"))
                results.add(AsciiType.instance.getString(col.bufferForValue()));
        }
    }

    return results;
}
 
开发者ID:xedin,项目名称:sasi,代码行数:19,代码来源:SSTableAttachedSecondaryIndexTest.java

示例10: processPrepared

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public static ResultMessage processPrepared(CQLStatement statement, QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> variables = options.getValues();
    // Check to see if there are any bound variables to verify
    if (!(variables.isEmpty() && (statement.getBoundsTerms() == 0)))
    {
        if (variables.size() != statement.getBoundsTerms())
            throw new InvalidRequestException(String.format("there were %d markers(?) in CQL but %d bound variables",
                                                            statement.getBoundsTerms(),
                                                            variables.size()));

        // at this point there is a match in count between markers and variables that is non-zero

        if (logger.isTraceEnabled())
            for (int i = 0; i < variables.size(); i++)
                logger.trace("[{}] '{}'", i+1, variables.get(i));
    }

    return processStatement(statement, queryState, options);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:QueryProcessor.java

示例11: execute

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage execute(ClientState state) throws RequestValidationException, RequestExecutionException
{
    // If the executing user has DESCRIBE permission on the root roles resource, let them list any and all roles
    boolean hasRootLevelSelect = DatabaseDescriptor.getAuthorizer()
                                                   .authorize(state.getUser(), RoleResource.root())
                                                   .contains(Permission.DESCRIBE);
    if (hasRootLevelSelect)
    {
        if (grantee == null)
            return resultMessage(DatabaseDescriptor.getRoleManager().getAllRoles());
        else
            return resultMessage(DatabaseDescriptor.getRoleManager().getRoles(grantee, recursive));
    }
    else
    {
        RoleResource currentUser = RoleResource.role(state.getUser().getName());
        if (grantee == null)
            return resultMessage(DatabaseDescriptor.getRoleManager().getRoles(currentUser, recursive));
        if (DatabaseDescriptor.getRoleManager().getRoles(currentUser, true).contains(grantee))
            return resultMessage(DatabaseDescriptor.getRoleManager().getRoles(grantee, recursive));
        else
            throw new UnauthorizedException(String.format("You are not authorized to view roles granted to %s ", grantee.getRoleName()));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:ListRolesStatement.java

示例12: processPrepared

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage processPrepared(CQLStatement statement, QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
    List<ByteBuffer> variables = options.getValues();
    // Check to see if there are any bound variables to verify
    if (!(variables.isEmpty() && (statement.getBoundTerms() == 0)))
    {
        if (variables.size() != statement.getBoundTerms())
            throw new InvalidRequestException(String.format("there were %d markers(?) in CQL but %d bound variables",
                                                            statement.getBoundTerms(),
                                                            variables.size()));

        // at this point there is a match in count between markers and variables that is non-zero

        if (logger.isTraceEnabled())
            for (int i = 0; i < variables.size(); i++)
                logger.trace("[{}] '{}'", i+1, variables.get(i));
    }

    metrics.preparedStatementsExecuted.inc();
    return processStatement(statement, queryState, options);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:QueryProcessor.java

示例13: execute

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage.Rows execute(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException
{
    ConsistencyLevel cl = options.getConsistency();
    checkNotNull(cl, "Invalid empty consistency level");

    cl.validateForRead(keyspace());

    int nowInSec = FBUtilities.nowInSeconds();
    int userLimit = getLimit(options);
    ReadQuery query = getQuery(options, nowInSec, userLimit);

    int pageSize = getPageSize(options);

    if (pageSize <= 0 || query.limits().count() <= pageSize)
        return execute(query, options, state, nowInSec, userLimit);

    QueryPager pager = query.getPager(options.getPagingState(), options.getProtocolVersion());
    return execute(Pager.forDistributedQuery(pager, cl, state.getClientState()), options, pageSize, nowInSec, userLimit);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:SelectStatement.java

示例14: process

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
public ResultMessage process(String queryString, QueryState queryState, QueryOptions options)
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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:QueryProcessor.java

示例15: executeOnceInternal

import org.apache.cassandra.transport.messages.ResultMessage; //导入依赖的package包/类
/**
 * Same than executeInternal, but to use for queries we know are only executed once so that the
 * created statement object is not cached.
 */
public static UntypedResultSet executeOnceInternal(String query, Object... values)
{
    ParsedStatement.Prepared prepared = parseStatement(query, internalQueryState());
    prepared.statement.validate(internalQueryState().getClientState());
    ResultMessage result = prepared.statement.executeInternal(internalQueryState(), makeInternalOptions(prepared, values));
    if (result instanceof ResultMessage.Rows)
        return UntypedResultSet.create(((ResultMessage.Rows)result).result);
    else
        return null;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:QueryProcessor.java


注:本文中的org.apache.cassandra.transport.messages.ResultMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。