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


Java ParsedStatement.Prepared方法代码示例

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


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

示例1: testParsingCQLOnCompoundedTable

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
@Test
public void testParsingCQLOnCompoundedTable() {
   String cql = "CREATE TABLE keyspace1.compressed_bills (" +
           "     user text," +
           "     email text," +
           "     account_id text static," +
           "     balance int static," +
           "     expense_id int," +
           "     item_id int," +
           "     amount int," +
           "     name text," +
           "     PRIMARY KEY ((user, email), expense_id, item_id))";


    ParsedStatement stmt = QueryProcessor.parseStatement(cql);
    stmt.properties.properties.addProperty(CFProperties.KEYSPACE_NAME, "keyspace1");
    stmt.properties.properties.addProperty(CFProperties.PARTITIONER_CLASS,
                                           "org.apache.cassandra.dht.Murmur3Partitioner");

    ParsedStatement.Prepared preparedStmt = stmt.prepare();

    CFMetaData cfMetaData = ((CreateTableStatement) preparedStmt.statement).getCFMetaData();
    Assert.assertEquals(cfMetaData.ksName, "keyspace1");
    Assert.assertEquals(cfMetaData.partitioner, Murmur3Partitioner.instance);

}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:27,代码来源:TestReadingSSTable21.java

示例2: parseSchema

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
/**
 * Get the meta data (column definitions) for the target table.
 * 
 * @param query The CREATE TABLE statement for the table the Json data should be put into.
 * @return The table's meta data
 */
private static CFMetaData parseSchema(String query) {
    try {
        ClientState state = ClientState.forInternalCalls();
        ParsedStatement.Prepared prepared = QueryProcessor.getStatement(query, state);
        CQLStatement stmt = prepared.statement;
        stmt.validate(state);

        if (!stmt.getClass().equals(CreateTableStatement.class)) {
            throw new IllegalArgumentException("Invalid query, must be a CREATE TABLE statement");
        }

        return CreateTableStatement.class.cast(stmt).getCFMetaData();
    } catch (RequestValidationException | IllegalArgumentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:PubGrade,项目名称:Json2SSTable,代码行数:23,代码来源:Json2SSTable.java

示例3: getStatement

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
private static <T extends CQLStatement> Pair<T, List<ColumnSpecification>> getStatement(String query, Class<T> klass, String type)
{
    try
    {
        ClientState state = ClientState.forInternalCalls();
        ParsedStatement.Prepared prepared = QueryProcessor.getStatement(query, state);
        CQLStatement stmt = prepared.statement;
        stmt.validate(state);

        if (!stmt.getClass().equals(klass))
            throw new IllegalArgumentException("Invalid query, must be a " + type + " statement");

        return Pair.create(klass.cast(stmt), prepared.boundNames);
    }
    catch (RequestValidationException e)
    {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:CQLSSTableWriter.java

示例4: schemaChange

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
protected static void schemaChange(String query)
{
    try
    {
        ClientState state = ClientState.forInternalCalls();
        state.setKeyspace(SystemKeyspace.NAME);
        QueryState queryState = new QueryState(state);

        ParsedStatement.Prepared prepared = QueryProcessor.parseStatement(query, queryState);
        prepared.statement.validate(state);

        QueryOptions options = QueryOptions.forInternalCalls(Collections.<ByteBuffer>emptyList());

        lastSchemaChangeResult = prepared.statement.executeInternal(queryState, options);
    }
    catch (Exception e)
    {
        logger.info("Error performing schema change", e);
        throw new RuntimeException("Error setting schema for test (query was: " + query + ")", e);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:CQLTester.java

示例5: execute

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        QueryHandler handler = state.getClientState().getCQLQueryHandler();
        ParsedStatement.Prepared prepared = handler.getPrepared(statementId);
        if (prepared == null)
            throw new PreparedQueryNotFoundException(statementId);

        options.prepare(prepared.boundNames);
        CQLStatement statement = prepared.statement;

        if (options.getPageSize() == 0)
            throw new ProtocolException("The page size cannot be 0");

        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();

            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            if (options.getPageSize() > 0)
                builder.put("page_size", Integer.toString(options.getPageSize()));

            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute CQL3 prepared query", builder.build());
        }

        Message.Response response = handler.processPrepared(statement, state, options);
        if (options.skipMetadata() && response instanceof ResultMessage.Rows)
            ((ResultMessage.Rows)response).result.metadata.setSkipMetadata();

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

        return response;
    }
    catch (Exception e)
    {
        JVMStabilityInspector.inspectThrowable(e);
        return ErrorMessage.fromException(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:54,代码来源:ExecuteMessage.java

示例6: Prepared

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public Prepared(MD5Digest statementId, ParsedStatement.Prepared prepared)
{
    this(statementId, -1, new ResultSet.Metadata(prepared.boundNames), extractResultMetadata(prepared.statement));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:ResultMessage.java

示例7: getPrepared

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPrepared(MD5Digest id)
{
    return queryProcessor.getPrepared(id);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:CustomPayloadMirroringQueryHandler.java

示例8: getPreparedForThrift

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPreparedForThrift(Integer id)
{
    return queryProcessor.getPreparedForThrift(id);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:CustomPayloadMirroringQueryHandler.java

示例9: execute

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        QueryHandler handler = ClientState.getCQLQueryHandler();
        ParsedStatement.Prepared prepared = handler.getPrepared(statementId);
        if (prepared == null)
            throw new PreparedQueryNotFoundException(statementId);

        options.prepare(prepared.boundNames);
        CQLStatement statement = prepared.statement;

        if (options.getPageSize() == 0)
            throw new ProtocolException("The page size cannot be 0");

        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();

            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            if (options.getPageSize() > 0)
                builder.put("page_size", Integer.toString(options.getPageSize()));
            if(options.getConsistency() != null)
                builder.put("consistency_level", options.getConsistency().name());
            if(options.getSerialConsistency() != null)
                builder.put("serial_consistency_level", options.getSerialConsistency().name());

            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute CQL3 prepared query", state.getClientAddress(), builder.build());
        }

        // Some custom QueryHandlers are interested by the bound names. We provide them this information
        // by wrapping the QueryOptions.
        QueryOptions queryOptions = QueryOptions.addColumnSpecifications(options, prepared.boundNames);
        Message.Response response = handler.processPrepared(statement, state, queryOptions, getCustomPayload());
        if (options.skipMetadata() && response instanceof ResultMessage.Rows)
            ((ResultMessage.Rows)response).result.metadata.setSkipMetadata();

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

        return response;
    }
    catch (Exception e)
    {
        JVMStabilityInspector.inspectThrowable(e);
        return ErrorMessage.fromException(e);
    }
    finally
    {
        Tracing.instance.stopSession();
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:61,代码来源:ExecuteMessage.java

示例10: Prepared

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public Prepared(MD5Digest statementId, ParsedStatement.Prepared prepared)
{
    this(statementId, -1, new ResultSet.PreparedMetadata(prepared.boundNames, prepared.partitionKeyBindIndexes), extractResultMetadata(prepared.statement));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:ResultMessage.java

示例11: getPrepared

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPrepared(MD5Digest id)
{
    return QueryProcessor.instance.getPrepared(id);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:MessagePayloadTest.java

示例12: getPreparedForThrift

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPreparedForThrift(Integer id)
{
    return QueryProcessor.instance.getPreparedForThrift(id);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:5,代码来源:MessagePayloadTest.java

示例13: execute

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    try
    {
        QueryHandler handler = state.getClientState().getCQLQueryHandler();
        ParsedStatement.Prepared prepared = handler.getPrepared(statementId);
        if (prepared == null)
            throw new PreparedQueryNotFoundException(statementId);

        options.prepare(prepared.boundNames);
        CQLStatement statement = prepared.statement;

        if (options.getPageSize() == 0)
            throw new ProtocolException("The page size cannot be 0");

        UUID tracingId = null;
        if (isTracingRequested())
        {
            tracingId = UUIDGen.getTimeUUID();
            state.prepareTracingSession(tracingId);
        }

        if (state.traceNextQuery())
        {
            state.createTracingSession();

            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            if (options.getPageSize() > 0)
                builder.put("page_size", Integer.toString(options.getPageSize()));

            // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560 is open to add support.
            Tracing.instance.begin("Execute CQL3 prepared query", builder.build());
        }

        Message.Response response = handler.processPrepared(statement, state, options);
        if (options.skipMetadata() && response instanceof ResultMessage.Rows)
            ((ResultMessage.Rows)response).result.metadata.setSkipMetadata();

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

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

示例14: getPrepared

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPrepared(MD5Digest id); 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:2,代码来源:QueryHandler.java

示例15: getPreparedForThrift

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入方法依赖的package包/类
public ParsedStatement.Prepared getPreparedForThrift(Integer id); 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:2,代码来源:QueryHandler.java


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