• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ModificationStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: customExpressionsDisallowedInModifications

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
@Test
public void customExpressionsDisallowedInModifications() throws Throwable
{
    createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b))");
    String indexName = currentTable() + "_custom_index";
    createIndex(String.format("CREATE CUSTOM INDEX %s ON %%s(c) USING '%s'",
                              indexName, StubIndex.class.getName()));

    assertInvalidThrowMessage(Server.CURRENT_VERSION,
                              ModificationStatement.CUSTOM_EXPRESSIONS_NOT_ALLOWED,
                              QueryValidationException.class,
                              String.format("DELETE FROM %%s WHERE expr(%s, 'foo bar baz ')", indexName));
    assertInvalidThrowMessage(Server.CURRENT_VERSION,
                              ModificationStatement.CUSTOM_EXPRESSIONS_NOT_ALLOWED,
                              QueryValidationException.class,
                              String.format("UPDATE %%s SET d=0 WHERE expr(%s, 'foo bar baz ')", indexName));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:CustomIndexTest.java


示例2: executeLoggedBatch

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
private void executeLoggedBatch(List<CQLStatement> statements)
throws RequestExecutionException, RequestValidationException
{
    BatchStatement batch = new BatchStatement(0,
                                              BatchStatement.Type.LOGGED,
                                              Lists.newArrayList(Iterables.filter(statements, ModificationStatement.class)),
                                              Attributes.none());
    QueryProcessor.instance.processBatch(batch,
                                         QueryState.forInternalCalls(),
                                         BatchQueryOptions.withoutPerStatementVariables(QueryOptions.DEFAULT));

}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:CassandraAuthorizer.java


示例3: testBatchStatement

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
@Test
public void testBatchStatement() throws Throwable
{
    String iFunc2 = createEchoFunction("int");
    List<ModificationStatement> statements = new ArrayList<>();
    statements.add(modificationStatement(cql("INSERT INTO %s (key, i_cc, t_cc) VALUES (%s, 0, 'foo')",
                                             functionCall(iFunc, "0"))));
    statements.add(modificationStatement(cql("INSERT INTO %s (key, i_cc, t_cc) VALUES (1, %s, 'foo')",
                                             functionCall(iFunc2, "1"))));
    statements.add(modificationStatement(cql("INSERT INTO %s (key, i_cc, t_cc) VALUES (2, 2, %s)",
                                             functionCall(tFunc, "'foo'"))));

    BatchStatement batch = new BatchStatement(-1, BatchStatement.Type.LOGGED, statements, Attributes.none());
    assertFunctions(batch, iFunc, iFunc2, tFunc);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:UFIdentificationTest.java


示例4: testBatchStatementWithConditions

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
@Test
public void testBatchStatementWithConditions() throws Throwable
{
    List<ModificationStatement> statements = new ArrayList<>();
    statements.add(modificationStatement(cql("UPDATE %s SET i_val = %s WHERE key=0 AND i_cc=0 and t_cc='foo' IF l_val = %s",
                                             functionCall(iFunc, "0"), functionCall(lFunc, "[1]"))));
    statements.add(modificationStatement(cql("UPDATE %s SET i_val = %s WHERE key=0 AND i_cc=1 and t_cc='foo' IF s_val = %s",
                                             functionCall(iFunc, "0"), functionCall(sFunc, "{1}"))));

    BatchStatement batch = new BatchStatement(-1, BatchStatement.Type.LOGGED, statements, Attributes.none());
    assertFunctions(batch, iFunc, lFunc, sFunc);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:UFIdentificationTest.java


示例5: testBatchStatement

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
@Test
public void testBatchStatement() throws Throwable
{
    List<ModificationStatement> statements = new ArrayList<>();
    List<String> functions = new ArrayList<>();
    for (int i = 0; i < 3; i++)
    {
        String functionName = createSimpleFunction();
        ModificationStatement stmt =
        (ModificationStatement) getStatement(String.format("INSERT INTO %s (k, v1, v2) " +
                                                           "VALUES (%s, %s, %s)",
                                                           KEYSPACE + "." + currentTable(),
                                                           i, i, functionCall(functionName)));
        functions.add(functionName);
        statements.add(stmt);
    }
    BatchStatement batch = new BatchStatement(-1, BatchStatement.Type.LOGGED, statements, Attributes.none());
    assertUnauthorized(batch, functions);

    grantExecuteOnFunction(functions.get(0));
    assertUnauthorized(batch, functions.subList(1, functions.size()));

    grantExecuteOnFunction(functions.get(1));
    assertUnauthorized(batch, functions.subList(2, functions.size()));

    grantExecuteOnFunction(functions.get(2));
    batch.checkAccess(clientState);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:UFAuthTest.java


示例6: 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


示例7: modificationStatement

import org.apache.cassandra.cql3.statements.ModificationStatement; //导入依赖的package包/类
private ModificationStatement modificationStatement(String cql)
{
    return (ModificationStatement) QueryProcessor.getStatement(cql, ClientState.forInternalCalls()).statement;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:UFIdentificationTest.java


示例8: 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


示例9: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AndroidClock类代码示例发布时间:2022-05-22
下一篇:
Java S3APacketTabComplete类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap