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

Java ParsedStatement类代码示例

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

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



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

示例1: parseStatement

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
public static ParsedStatement parseStatement(String queryStr) throws SyntaxException
{
    try
    {
        return CQLFragmentParser.parseAnyUnhandled(CqlParser::query, queryStr);
    }
    catch (CassandraException ce)
    {
        throw ce;
    }
    catch (RuntimeException re)
    {
        logger.error(String.format("The statement: [%s] could not be parsed.", queryStr), re);
        throw new SyntaxException(String.format("Failed parsing statement: [%s] reason: %s %s",
                queryStr,
                re.getClass().getSimpleName(),
                re.getMessage()));
    }
    catch (RecognitionException e)
    {
        throw new SyntaxException("Invalid or malformed CQL query string: " + e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:24,代码来源:QueryProcessor.java


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


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


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


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


示例6: cqlStatement

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
public final ParsedStatement cqlStatement() throws RecognitionException {
	ParsedStatement stmt = null;

	CreateTableStatement.RawStatement st9 =null;


	try {
		// Parser.g:209:5: (st1= selectStatement |st2= insertStatement |st3= updateStatement |st4= batchStatement |st5= deleteStatement |st6= useStatement |st7= truncateStatement |st8= createKeyspaceStatement |st9= createTableStatement |st10= createIndexStatement |st11= dropKeyspaceStatement |st12= dropTableStatement |st13= dropIndexStatement |st14= alterTableStatement |st15= alterKeyspaceStatement |st16= grantPermissionsStatement |st17= revokePermissionsStatement |st18= listPermissionsStatement |st19= createUserStatement |st20= alterUserStatement |st21= dropUserStatement |st22= listUsersStatement |st23= createTriggerStatement |st24= dropTriggerStatement |st25= createTypeStatement |st26= alterTypeStatement |st27= dropTypeStatement |st28= createFunctionStatement |st29= dropFunctionStatement |st30= createAggregateStatement |st31= dropAggregateStatement |st32= createRoleStatement |st33= alterRoleStatement |st34= dropRoleStatement |st35= listRolesStatement |st36= grantRoleStatement |st37= revokeRoleStatement |st38= createMaterializedViewStatement |st39= dropMaterializedViewStatement |st40= alterMaterializedViewStatement )
		int alt1=40;
		alt1 = dfa1.predict(input);
		switch (alt1) {

			case 9 :
				// Parser.g:217:7: st9= createTableStatement
			{
				pushFollow(FOLLOW_createTableStatement_in_cqlStatement285);
				st9=createTableStatement();
				state._fsp--;

				stmt = st9;
			}
			break;

		}
	}
	catch (RecognitionException re) {
		reportError(re);
		recover(input,re);
	}
	finally {
		// do for sure before leaving
	}
	return stmt;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:35,代码来源:Cql_Parser.java


示例7: doSchema

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
public void doSchema(String command) throws Exception {
    String path = command.substring(6).trim().replaceAll("\"", "");

    if (path.equalsIgnoreCase("off")) {
        System.out.println(DISABLING_SCHEMA);
        CassandraUtils.cqlOverride = null;
    } else if (Strings.isNullOrEmpty(path)) {
        if (!Strings.isNullOrEmpty(CassandraUtils.cqlOverride)) {
            System.out.printf(USER_DEFINED_SCHEMA, CassandraUtils.cqlOverride);
        } else {
            System.out.println(NO_USER_DEFINED_SCHEMA);
        }
    } else {
        File schemaFile = new File(path);
        if (!schemaFile.exists()) {
            System.err.printf(CANNOT_FIND_FILE, schemaFile.getAbsolutePath());
        } else {
            String cql = new String(Files.readAllBytes(schemaFile.toPath()));
            try {
                ParsedStatement statement = QueryProcessor.parseStatement(cql);
                if (statement instanceof CreateTableStatement.RawStatement) {
                    CassandraUtils.cqlOverride = cql;
                    System.out.printf(IMPORTED_SCHEMA, schemaFile.getAbsolutePath());
                } else {
                    System.err.printf(FAILED_TO_IMPORT_SCHEMA, schemaFile.getAbsoluteFile(), "Wrong type of statement, " + statement.getClass());
                }
            } catch (SyntaxException se) {
                System.err.printf(FAILED_TO_IMPORT_SCHEMA, schemaFile.getAbsoluteFile(), se.getMessage());
            }
        }
    }

}
 
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:34,代码来源:Cqlsh.java


示例8: getExpressions

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
private static IndexExpression[] getExpressions(String cqlQuery) throws Exception
{
    ParsedStatement parsedStatement = QueryProcessor.parseStatement(String.format(cqlQuery, KS_NAME, CF_NAME));
    SelectStatement selectStatement = (SelectStatement) parsedStatement.prepare().statement;

    List<IndexExpression> expressions = selectStatement.getIndexExpressions(Collections.<ByteBuffer>emptyList());
    return expressions.toArray(new IndexExpression[expressions.size()]);
}
 
开发者ID:xedin,项目名称:sasi,代码行数:9,代码来源:SSTableAttachedSecondaryIndexTest.java


示例9: query

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
public final ParsedStatement query() throws RecognitionException {
	ParsedStatement stmnt = null;


	ParsedStatement st =null;

	try {
		// /Users/minhdo/workspace2/BDP/cassandra-3/src/antlr/Cql.g:138:5: (st= cqlStatement ( ';' )* EOF )
		// /Users/minhdo/workspace2/BDP/cassandra-3/src/antlr/Cql.g:138:7: st= cqlStatement ( ';' )* EOF
		{
		pushFollow(FOLLOW_cqlStatement_in_query77);
		st=cqlStatement();
		state._fsp--;

		// /Users/minhdo/workspace2/BDP/cassandra-3/src/antlr/Cql.g:138:23: ( ';' )*
		loop1:
		while (true) {
			int alt1=2;
			int LA1_0 = input.LA(1);
			if ( (LA1_0==192) ) {
				alt1=1;
			}

			switch (alt1) {
			case 1 :
				// /Users/minhdo/workspace2/BDP/cassandra-3/src/antlr/Cql.g:138:24: ';'
				{
				match(input,192,FOLLOW_192_in_query80); 
				}
				break;

			default :
				break loop1;
			}
		}

		match(input,EOF,FOLLOW_EOF_in_query84); 
		 stmnt = st; 
		}

	}
	catch (RecognitionException re) {
		reportError(re);
		recover(input,re);
	}
	finally {
		// do for sure before leaving
	}
	return stmnt;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:51,代码来源:CqlParser.java


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


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


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


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


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


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


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


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


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


示例19: cqlStatement

import org.apache.cassandra.cql3.statements.ParsedStatement; //导入依赖的package包/类
public ParsedStatement cqlStatement() throws RecognitionException { return gParser.cqlStatement(); } 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:2,代码来源:CqlParser.java


示例20: getPrepared

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EnumEditor类代码示例发布时间:2022-05-22
下一篇:
Java OnDiskAtom类代码示例发布时间: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