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


Java ConsistencyLevel.validateForRead方法代码示例

本文整理汇总了Java中org.apache.cassandra.db.ConsistencyLevel.validateForRead方法的典型用法代码示例。如果您正苦于以下问题:Java ConsistencyLevel.validateForRead方法的具体用法?Java ConsistencyLevel.validateForRead怎么用?Java ConsistencyLevel.validateForRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.db.ConsistencyLevel的用法示例。


在下文中一共展示了ConsistencyLevel.validateForRead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.cassandra.db.ConsistencyLevel; //导入方法依赖的package包/类
public ResultMessage.Rows execute(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException
{
    ConsistencyLevel cl = options.getConsistency();
    if (cl == null)
        throw new InvalidRequestException("Invalid empty consistency level");

    cl.validateForRead(keyspace());

    int limit = getLimit(options);
    long now = System.currentTimeMillis();
    Pageable command = getPageableCommand(options, limit, now);

    int pageSize = options.getPageSize();
    // A count query will never be paged for the user, but we always page it internally to avoid OOM.
    // If we user provided a pageSize we'll use that to page internally (because why not), otherwise we use our default
    // Note that if there are some nodes in the cluster with a version less than 2.0, we can't use paging (CASSANDRA-6707).
    if (parameters.isCount && pageSize <= 0)
        pageSize = DEFAULT_COUNT_PAGE_SIZE;

    if (pageSize <= 0 || command == null || !QueryPagers.mayNeedPaging(command, pageSize))
    {
        return execute(command, options, limit, now, state);
    }
    else
    {
        QueryPager pager = QueryPagers.pager(command, cl, state.getClientState(), options.getPagingState());
        if (parameters.isCount)
            return pageCountQuery(pager, options, pageSize, now, limit);

        // We can't properly do post-query ordering if we page (see #6722)
        if (needsPostQueryOrdering())
            throw new InvalidRequestException("Cannot page queries with both ORDER BY and a IN restriction on the partition key; you must either remove the "
                                            + "ORDER BY or the IN and sort client side, or disable paging for this query");

        List<Row> page = pager.fetchPage(pageSize);
        ResultMessage.Rows msg = processResults(page, options, limit, now);

        if (!pager.isExhausted())
            msg.result.metadata.setHasMorePages(pager.state());

        return msg;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:44,代码来源:SelectStatement.java

示例2: execute

import org.apache.cassandra.db.ConsistencyLevel; //导入方法依赖的package包/类
public ResultMessage.Rows execute(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException
{
    ConsistencyLevel cl = options.getConsistency();
    List<ByteBuffer> variables = options.getValues();
    if (cl == null)
        throw new InvalidRequestException("Invalid empty consistency level");

    cl.validateForRead(keyspace());

    int limit = getLimit(variables);
    long now = System.currentTimeMillis();
    Pageable command;
    if (isKeyRange || usesSecondaryIndexing)
    {
        command = getRangeCommand(variables, limit, now);
    }
    else
    {
        List<ReadCommand> commands = getSliceCommands(variables, limit, now);
        command = commands == null ? null : new Pageable.ReadCommands(commands);
    }

    int pageSize = options.getPageSize();
    // A count query will never be paged for the user, but we always page it internally to avoid OOM.
    // If we user provided a pageSize we'll use that to page internally (because why not), otherwise we use our default
    if (parameters.isCount && pageSize <= 0)
        pageSize = DEFAULT_COUNT_PAGE_SIZE;

    if (pageSize <= 0 || command == null || !QueryPagers.mayNeedPaging(command, pageSize))
    {
        return execute(command, cl, variables, limit, now);
    }
    else
    {
        QueryPager pager = QueryPagers.pager(command, cl, options.getPagingState());
        if (parameters.isCount)
            return pageCountQuery(pager, variables, pageSize, now);

        List<Row> page = pager.fetchPage(pageSize);
        ResultMessage.Rows msg = processResults(page, variables, limit, now);
        if (!pager.isExhausted())
            msg.result.metadata.setHasMorePages(pager.state());
        return msg;
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:46,代码来源:SelectStatement.java


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