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


Java ResultMessage.Prepared方法代码示例

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


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

示例1: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public static ResultMessage.Prepared prepare(String queryString, ClientState clientState, boolean forThrift)
throws RequestValidationException
{
    ResultMessage.Prepared existing = getStoredPreparedStatement(queryString, clientState.getRawKeyspace(), forThrift);
    if (existing != null)
        return existing;

    ParsedStatement.Prepared prepared = getStatement(queryString, clientState);
    int boundTerms = prepared.statement.getBoundTerms();
    if (boundTerms > FBUtilities.MAX_UNSIGNED_SHORT)
        throw new InvalidRequestException(String.format("Too many markers(?). %d markers exceed the allowed maximum of %d", boundTerms, FBUtilities.MAX_UNSIGNED_SHORT));
    assert boundTerms == prepared.boundNames.size();

    return storePreparedStatement(queryString, clientState.getRawKeyspace(), prepared, forThrift);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:QueryProcessor.java

示例2: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public static ResultMessage.Prepared prepare(String queryString, ClientState clientState, boolean forThrift)
throws RequestValidationException
{
    ParsedStatement.Prepared prepared = getStatement(queryString, clientState);
    ResultMessage.Prepared msg = storePreparedStatement(queryString, clientState.getRawKeyspace(), prepared, forThrift);

    assert prepared.statement.getBoundsTerms() == prepared.boundNames.size();
    return msg;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:10,代码来源:QueryProcessor.java

示例3: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public static ResultMessage.Prepared prepare(String queryString, ClientState clientState, boolean forThrift)
{
    ResultMessage.Prepared existing = getStoredPreparedStatement(queryString, clientState.getRawKeyspace(), forThrift);
    if (existing != null)
        return existing;

    ParsedStatement.Prepared prepared = getStatement(queryString, clientState);
    int boundTerms = prepared.statement.getBoundTerms();
    if (boundTerms > FBUtilities.MAX_UNSIGNED_SHORT)
        throw new InvalidRequestException(String.format("Too many markers(?). %d markers exceed the allowed maximum of %d", boundTerms, FBUtilities.MAX_UNSIGNED_SHORT));
    assert boundTerms == prepared.boundNames.size();

    return storePreparedStatement(queryString, clientState.getRawKeyspace(), prepared, forThrift);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:QueryProcessor.java

示例4: prepareStatementWithDelayedValue

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage.Prepared prepareStatementWithDelayedValue(CollectionType.Kind kind, String function)
{
    String collectionType;
    String literalArgs;
    switch (kind)
    {
        case LIST:
            collectionType = "list<double>";
            literalArgs = String.format("[%s(0.0)]", function);
            break;
        case SET:
            collectionType = "set<double>";
            literalArgs = String.format("{%s(0.0)}", function);
            break;
        case MAP:
            collectionType = "map<double, double>";
            literalArgs = String.format("{%s(0.0):0.0}", function);
            break;
        default:
            Assert.fail("Unsupported collection type " + kind);
            collectionType = null;
            literalArgs = null;
    }

    createTable("CREATE TABLE %s (" +
                " key int PRIMARY KEY," +
                " val " + collectionType + ')');

    ResultMessage.Prepared prepared = QueryProcessor.prepare(
                                                            String.format("INSERT INTO %s.%s (key, val) VALUES (?, %s)",
                                                                         KEYSPACE,
                                                                         currentTable(),
                                                                         literalArgs),
                                                            ClientState.forInternalCalls(), false);
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(prepared.statementId));
    return prepared;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:38,代码来源:UFTest.java

示例5: prepareStatementWithDelayedValueTuple

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage.Prepared prepareStatementWithDelayedValueTuple(String function)
{
    createTable("CREATE TABLE %s (" +
                " key int PRIMARY KEY," +
                " val tuple<double> )");

    ResultMessage.Prepared prepared = QueryProcessor.prepare(
                                                            String.format("INSERT INTO %s.%s (key, val) VALUES (?, (%s(0.0)))",
                                                                         KEYSPACE,
                                                                         currentTable(),
                                                                         function),
                                                            ClientState.forInternalCalls(), false);
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(prepared.statementId));
    return prepared;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:UFTest.java

示例6: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Prepared prepare(String query,
                                      QueryState state,
                                      Map<String, ByteBuffer> customPayload)
                                              throws RequestValidationException
{
    if (customPayload != null)
        requestPayload = customPayload;
    ResultMessage.Prepared result = QueryProcessor.instance.prepare(query, state, customPayload);
    if (customPayload != null)
    {
        result.setCustomPayload(responsePayload);
        responsePayload = null;
    }
    return result;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:MessagePayloadTest.java

示例7: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Prepared prepare(String query)
{
    Message.Response msg = execute(new PrepareMessage(query));
    assert msg instanceof ResultMessage.Prepared;
    return (ResultMessage.Prepared)msg;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:7,代码来源:SimpleClient.java

示例8: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
ResultMessage.Prepared prepare(String query,
QueryState state,
Map<String, ByteBuffer> customPayload) throws RequestValidationException;
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:4,代码来源:QueryHandler.java

示例9: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Prepared prepare(String query, QueryState state, Map<String, ByteBuffer> customPayload)
{
    ResultMessage.Prepared prepared = queryProcessor.prepare(query, state, customPayload);
    prepared.setCustomPayload(customPayload);
    return prepared;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:7,代码来源:CustomPayloadMirroringQueryHandler.java

示例10: testFunctionDropPreparedStatement

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
@Test
public void testFunctionDropPreparedStatement() throws Throwable
{
    String otherKS = "cqltest_foo";

    execute("CREATE KEYSPACE IF NOT EXISTS " + otherKS + " WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3};");
    try
    {
        execute("CREATE TABLE " + otherKS + ".jsdp (a int primary key, b int)");

        String fState = createFunction(otherKS,
                                       "int, int",
                                       "CREATE FUNCTION %s(a int, b int) " +
                                       "CALLED ON NULL INPUT " +
                                       "RETURNS int " +
                                       "LANGUAGE javascript " +
                                       "AS 'a + b;'");

        String a = createAggregate(otherKS,
                                   "int",
                                   "CREATE AGGREGATE %s(int) " +
                                   "SFUNC " + shortFunctionName(fState) + " " +
                                   "STYPE int");

        ResultMessage.Prepared prepared = QueryProcessor.prepare("SELECT " + a + "(b) FROM " + otherKS + ".jsdp", ClientState.forInternalCalls(), false);
        assertNotNull(QueryProcessor.instance.getPrepared(prepared.statementId));

        execute("DROP AGGREGATE " + a + "(int)");
        assertNull(QueryProcessor.instance.getPrepared(prepared.statementId));

        //

        execute("CREATE AGGREGATE " + a + "(int) " +
                "SFUNC " + shortFunctionName(fState) + " " +
                "STYPE int");

        prepared = QueryProcessor.prepare("SELECT " + a + "(b) FROM " + otherKS + ".jsdp", ClientState.forInternalCalls(), false);
        assertNotNull(QueryProcessor.instance.getPrepared(prepared.statementId));

        execute("DROP KEYSPACE " + otherKS + ";");

        assertNull(QueryProcessor.instance.getPrepared(prepared.statementId));
    }
    finally
    {
        execute("DROP KEYSPACE IF EXISTS " + otherKS + ";");
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:49,代码来源:AggregationTest.java

示例11: prepareStatement

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage.Prepared prepareStatement(String cql, boolean forThrift)
{
    return QueryProcessor.prepare(String.format(cql, KEYSPACE, currentTable()),
                                  ClientState.forInternalCalls(),
                                  forThrift);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:7,代码来源:SecondaryIndexTest.java

示例12: testFunctionDropPreparedStatement

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
@Test
public void testFunctionDropPreparedStatement() throws Throwable
{
    createTable("CREATE TABLE %s (key int PRIMARY KEY, d double)");

    String fSin = createFunction(KEYSPACE_PER_TEST, "double",
                                 "CREATE FUNCTION %s ( input double ) " +
                                 "CALLED ON NULL INPUT " +
                                 "RETURNS double " +
                                 "LANGUAGE java " +
                                 "AS 'return Double.valueOf(Math.sin(input.doubleValue()));'");

    FunctionName fSinName = parseFunctionName(fSin);

    Assert.assertEquals(1, Schema.instance.getFunctions(parseFunctionName(fSin)).size());

    // create a pairs of Select and Inserts. One statement in each pair uses the function so when we
    // drop it those statements should be removed from the cache in QueryProcessor. The other statements
    // should be unaffected.

    ResultMessage.Prepared preparedSelect1 = QueryProcessor.prepare(
                                                                   String.format("SELECT key, %s(d) FROM %s.%s", fSin, KEYSPACE, currentTable()),
                                                                   ClientState.forInternalCalls(), false);
    ResultMessage.Prepared preparedSelect2 = QueryProcessor.prepare(
                                                String.format("SELECT key FROM %s.%s", KEYSPACE, currentTable()),
                                                ClientState.forInternalCalls(), false);
    ResultMessage.Prepared preparedInsert1 = QueryProcessor.prepare(
                                                  String.format("INSERT INTO %s.%s (key, d) VALUES (?, %s(?))", KEYSPACE, currentTable(), fSin),
                                                  ClientState.forInternalCalls(), false);
    ResultMessage.Prepared preparedInsert2 = QueryProcessor.prepare(
                                                  String.format("INSERT INTO %s.%s (key, d) VALUES (?, ?)", KEYSPACE, currentTable()),
                                                  ClientState.forInternalCalls(), false);

    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedSelect1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedSelect2.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedInsert1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedInsert2.statementId));

    execute("DROP FUNCTION " + fSin + "(double);");

    // the statements which use the dropped function should be removed from cache, with the others remaining
    Assert.assertNull(QueryProcessor.instance.getPrepared(preparedSelect1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedSelect2.statementId));
    Assert.assertNull(QueryProcessor.instance.getPrepared(preparedInsert1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedInsert2.statementId));

    execute("CREATE FUNCTION " + fSin + " ( input double ) " +
            "RETURNS NULL ON NULL INPUT " +
            "RETURNS double " +
            "LANGUAGE java " +
            "AS 'return Double.valueOf(Math.sin(input));'");

    Assert.assertEquals(1, Schema.instance.getFunctions(fSinName).size());

    preparedSelect1= QueryProcessor.prepare(
                                     String.format("SELECT key, %s(d) FROM %s.%s", fSin, KEYSPACE, currentTable()),
                                     ClientState.forInternalCalls(), false);
    preparedInsert1 = QueryProcessor.prepare(
                                     String.format("INSERT INTO %s.%s (key, d) VALUES (?, %s(?))", KEYSPACE, currentTable(), fSin),
                                     ClientState.forInternalCalls(), false);
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedSelect1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedInsert1.statementId));

    dropPerTestKeyspace();

    // again, only the 2 statements referencing the function should be removed from cache
    // this time because the statements select from tables in KEYSPACE, only the function
    // is scoped to KEYSPACE_PER_TEST
    Assert.assertNull(QueryProcessor.instance.getPrepared(preparedSelect1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedSelect2.statementId));
    Assert.assertNull(QueryProcessor.instance.getPrepared(preparedInsert1.statementId));
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(preparedInsert2.statementId));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:74,代码来源:UFTest.java

示例13: checkDelayedValuesCorrectlyIdentifyFunctionsInUse

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public void checkDelayedValuesCorrectlyIdentifyFunctionsInUse(boolean dropKeyspace) throws Throwable
{
    // prepare a statement which doesn't use any function for a control
    createTable("CREATE TABLE %s (" +
                " key int PRIMARY KEY," +
                " val double)");
    ResultMessage.Prepared control = QueryProcessor.prepare(
                                                           String.format("INSERT INTO %s.%s (key, val) VALUES (?, ?)",
                                                                        KEYSPACE,
                                                                        currentTable()),
                                                           ClientState.forInternalCalls(), false);
    Assert.assertNotNull(QueryProcessor.instance.getPrepared(control.statementId));

    // a function that we'll drop and verify that statements which use it to
    // provide a DelayedValue are removed from the cache in QueryProcessor
    String function = createFunction(KEYSPACE_PER_TEST, "double",
                                    "CREATE FUNCTION %s ( input double ) " +
                                    "CALLED ON NULL INPUT " +
                                    "RETURNS double " +
                                    "LANGUAGE javascript " +
                                    "AS 'input'");
    Assert.assertEquals(1, Schema.instance.getFunctions(parseFunctionName(function)).size());

    List<ResultMessage.Prepared> prepared = new ArrayList<>();
    // prepare statements which use the function to provide a DelayedValue
    prepared.add(prepareStatementWithDelayedValue(CollectionType.Kind.LIST, function));
    prepared.add(prepareStatementWithDelayedValue(CollectionType.Kind.SET, function));
    prepared.add(prepareStatementWithDelayedValue(CollectionType.Kind.MAP, function));
    prepared.add(prepareStatementWithDelayedValueTuple(function));

    // what to drop - the function is scoped to the per-test keyspace, but the prepared statements
    // select from the per-fixture keyspace. So if we drop the per-test keyspace, the function
    // should be removed along with the statements that reference it. The control statement should
    // remain present in the cache. Likewise, if we actually drop the function itself the control
    // statement should not be removed, but the others should be
    if (dropKeyspace)
        dropPerTestKeyspace();
    else
        execute("DROP FUNCTION " + function);

    Assert.assertNotNull(QueryProcessor.instance.getPrepared(control.statementId));
    for (ResultMessage.Prepared removed : prepared)
        Assert.assertNull(QueryProcessor.instance.getPrepared(removed.statementId));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:45,代码来源:UFTest.java

示例14: testMessagePayload

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
@Test
public void testMessagePayload() throws Throwable
{
    QueryHandler queryHandler = (QueryHandler) cqlQueryHandlerField.get(null);
    cqlQueryHandlerField.set(null, new TestQueryHandler());
    try
    {
        requireNetwork();

        Assert.assertSame(TestQueryHandler.class, ClientState.getCQLQueryHandler().getClass());

        SimpleClient client = new SimpleClient(nativeAddr.getHostAddress(), nativePort);
        try
        {
            client.connect(false);

            Map<String, ByteBuffer> reqMap;
            Map<String, ByteBuffer> respMap;

            QueryMessage queryMessage = new QueryMessage(
                                                        "CREATE TABLE " + KEYSPACE + ".atable (pk int PRIMARY KEY, v text)",
                                                        QueryOptions.DEFAULT
            );
            PrepareMessage prepareMessage = new PrepareMessage("SELECT * FROM " + KEYSPACE + ".atable");

            reqMap = Collections.singletonMap("foo", bytes(42));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(42));
            queryMessage.setCustomPayload(reqMap);
            Message.Response queryResponse = client.execute(queryMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, queryResponse.getCustomPayload());

            reqMap = Collections.singletonMap("foo", bytes(43));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(43));
            prepareMessage.setCustomPayload(reqMap);
            ResultMessage.Prepared prepareResponse = (ResultMessage.Prepared) client.execute(prepareMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, prepareResponse.getCustomPayload());

            ExecuteMessage executeMessage = new ExecuteMessage(prepareResponse.statementId, QueryOptions.DEFAULT);
            reqMap = Collections.singletonMap("foo", bytes(44));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(44));
            executeMessage.setCustomPayload(reqMap);
            Message.Response executeResponse = client.execute(executeMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, executeResponse.getCustomPayload());

            BatchMessage batchMessage = new BatchMessage(BatchStatement.Type.UNLOGGED,
                                                         Collections.<Object>singletonList("INSERT INTO " + KEYSPACE + ".atable (pk,v) VALUES (1, 'foo')"),
                                                         Collections.singletonList(Collections.<ByteBuffer>emptyList()),
                                                         QueryOptions.DEFAULT);
            reqMap = Collections.singletonMap("foo", bytes(45));
            responsePayload = respMap = Collections.singletonMap("bar", bytes(45));
            batchMessage.setCustomPayload(reqMap);
            Message.Response batchResponse = client.execute(batchMessage);
            payloadEquals(reqMap, requestPayload);
            payloadEquals(respMap, batchResponse.getCustomPayload());
        }
        finally
        {
            client.close();
        }
    }
    finally
    {
        cqlQueryHandlerField.set(null, queryHandler);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:69,代码来源:MessagePayloadTest.java

示例15: prepare

import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Prepared prepare(String query, QueryState state) throws RequestValidationException; 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:2,代码来源:QueryHandler.java


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