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


Java ModificationStatement.isCounter方法代码示例

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


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

示例1: execute

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();
            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute batch of CQL3 queries", Collections.<String, String>emptyMap());
        }

        List<ModificationStatement> statements = new ArrayList<ModificationStatement>(queryOrIdList.size());
        for (int i = 0; i < queryOrIdList.size(); i++)
        {
            Object query = queryOrIdList.get(i);
            CQLStatement statement;
            if (query instanceof String)
            {
                statement = QueryProcessor.parseStatement((String)query, state);
            }
            else
            {
                statement = QueryProcessor.getPrepared((MD5Digest)query);
                if (statement == null)
                    throw new PreparedQueryNotFoundException((MD5Digest)query);
            }

            List<ByteBuffer> queryValues = values.get(i);
            if (queryValues.size() != statement.getBoundsTerms())
                throw new InvalidRequestException(String.format("There were %d markers(?) in CQL but %d bound variables",
                                                                statement.getBoundsTerms(),
                                                                queryValues.size()));
            if (!(statement instanceof ModificationStatement))
                throw new InvalidRequestException("Invalid statement in batch: only UPDATE, INSERT and DELETE statements are allowed.");

            ModificationStatement mst = (ModificationStatement)statement;
            if (mst.isCounter())
            {
                if (type != BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include counter statement in a non-counter batch");
            }
            else
            {
                if (type == BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include non-counter statement in a counter batch");
            }
            statements.add(mst);
        }

        // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
        // (and no value would be really correct, so we prefer passing a clearly wrong one).
        BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
        Message.Response response = QueryProcessor.processBatch(batch, consistency, state, values);

        if (tracingId != null)
            response.setTracingId(tracingId);

        return response;
    }
    catch (Exception e)
    {
        return ErrorMessage.fromException(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:76,代码来源:BatchMessage.java

示例2: execute

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();
            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute batch of CQL3 queries", Collections.<String, String>emptyMap());
        }

        List<ModificationStatement> statements = new ArrayList<ModificationStatement>(queryOrIdList.size());
        for (int i = 0; i < queryOrIdList.size(); i++)
        {
            Object query = queryOrIdList.get(i);
            CQLStatement statement;
            if (query instanceof String)
            {
                statement = QueryProcessor.parseStatement((String)query, state);
            }
            else
            {
                statement = QueryProcessor.getPrepared((MD5Digest)query);
                if (statement == null)
                    throw new PreparedQueryNotFoundException((MD5Digest)query);
            }

            List<ByteBuffer> queryValues = values.get(i);
            if (queryValues.size() != statement.getBoundTerms())
                throw new InvalidRequestException(String.format("There were %d markers(?) in CQL but %d bound variables",
                                                                statement.getBoundTerms(),
                                                                queryValues.size()));
            if (!(statement instanceof ModificationStatement))
                throw new InvalidRequestException("Invalid statement in batch: only UPDATE, INSERT and DELETE statements are allowed.");

            ModificationStatement mst = (ModificationStatement)statement;
            if (mst.isCounter())
            {
                if (type != BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include counter statement in a non-counter batch");
            }
            else
            {
                if (type == BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include non-counter statement in a counter batch");
            }
            statements.add(mst);
        }

        // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
        // (and no value would be really correct, so we prefer passing a clearly wrong one).
        BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
        Message.Response response = QueryProcessor.processBatch(batch, consistency, state, values, queryOrIdList);

        if (tracingId != null)
            response.setTracingId(tracingId);

        return response;
    }
    catch (Exception e)
    {
        return ErrorMessage.fromException(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:76,代码来源:BatchMessage.java

示例3: execute

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();
            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute batch of CQL3 queries", Collections.<String, String>emptyMap());
        }

        QueryHandler handler = state.getClientState().getCQLQueryHandler();
        List<ModificationStatement> statements = new ArrayList<ModificationStatement>(queryOrIdList.size());
        for (int i = 0; i < queryOrIdList.size(); i++)
        {
            Object query = queryOrIdList.get(i);
            CQLStatement statement;
            if (query instanceof String)
            {
                statement = QueryProcessor.parseStatement((String)query, state);
            }
            else
            {
                statement = handler.getPrepared((MD5Digest)query);
                if (statement == null)
                    throw new PreparedQueryNotFoundException((MD5Digest)query);
            }

            List<ByteBuffer> queryValues = values.get(i);
            if (queryValues.size() != statement.getBoundTerms())
                throw new InvalidRequestException(String.format("There were %d markers(?) in CQL but %d bound variables",
                                                                statement.getBoundTerms(),
                                                                queryValues.size()));
            if (!(statement instanceof ModificationStatement))
                throw new InvalidRequestException("Invalid statement in batch: only UPDATE, INSERT and DELETE statements are allowed.");

            ModificationStatement mst = (ModificationStatement)statement;
            if (mst.isCounter())
            {
                if (type != BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include counter statement in a non-counter batch");
            }
            else
            {
                if (type == BatchStatement.Type.COUNTER)
                    throw new InvalidRequestException("Cannot include non-counter statement in a counter batch");
            }
            statements.add(mst);
        }

        // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
        // (and no value would be really correct, so we prefer passing a clearly wrong one).
        BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
        Message.Response response = handler.processBatch(batch, state, new BatchQueryOptions(consistency, values, queryOrIdList));

        if (tracingId != null)
            response.setTracingId(tracingId);

        return response;
    }
    catch (Exception e)
    {
        return ErrorMessage.fromException(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:77,代码来源:BatchMessage.java


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