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

Java CFStatement类代码示例

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

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



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

示例1: compile

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
@VisibleForTesting
public static CFMetaData compile(String cql, String keyspace)
{
    try
    {
        CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql);
        parsed.prepareKeyspace(keyspace);
        CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement;
        CFMetaData cfm = newSystemMetadata(keyspace, statement.columnFamily(), "", statement.comparator);
        statement.applyPropertiesTo(cfm);
        return cfm.rebuild();
    }
    catch (RequestValidationException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:CFMetaData.java


示例2: compile

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
public static CFMetaData compile(String cql, String keyspace, IPartitioner partitioner)
{
    CFStatement parsed = (CFStatement) QueryProcessor.parseStatement(cql);
    parsed.properties.properties.addProperty(CFProperties.KEYSPACE_NAME, keyspace);

    CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement;

    return statement.metadataBuilder()
            .withId(generateLegacyCfId(keyspace, statement.columnFamily()))
            .withPartitioner(partitioner)
            .build()
            .params(statement.params());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:14,代码来源:CFMetaData.java


示例3: tableFromCQL

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
public static CFMetaData tableFromCQL(InputStream source, UUID cfid) throws IOException {
    String schema = CharStreams.toString(new InputStreamReader(source, "UTF-8"));
    logger.trace("Loading Schema" + schema);
    CFStatement statement = (CFStatement) QueryProcessor.parseStatement(schema);
    String keyspace = "";
    try {
        keyspace = statement.keyspace() == null ? "turtles" : statement.keyspace();
    } catch (AssertionError e) { // if -ea added we should provide lots of warnings that things probably wont work
        logger.warn("Remove '-ea' JVM option when using sstable-tools library");
        keyspace = "turtles";
    }
    statement.prepareKeyspace(keyspace);
    if(Schema.instance.getKSMetaData(keyspace) == null) {
        Schema.instance.setKeyspaceMetadata(KeyspaceMetadata.create(keyspace, KeyspaceParams.local(), Tables.none(),
                Views.none(), getTypes(), Functions.none()));
    }
    CFMetaData cfm;
    if(cfid != null) {
        cfm = ((CreateTableStatement) statement.prepare().statement).metadataBuilder().withId(cfid).build();
        KeyspaceMetadata prev = Schema.instance.getKSMetaData(keyspace);
        List<CFMetaData> tables = Lists.newArrayList(prev.tablesAndViews());
        tables.add(cfm);
        Schema.instance.setKeyspaceMetadata(prev.withSwapped(Tables.of(tables)));
        Schema.instance.load(cfm);
    } else {
        cfm = ((CreateTableStatement) statement.prepare().statement).getCFMetaData();
    }
    return cfm;
}
 
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:30,代码来源:CassandraUtils.java


示例4: compile

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
public static CFMetaData compile(String cql, String keyspace)
{
    CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql);
    parsed.prepareKeyspace(keyspace);
    CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed).prepare(Types.none()).statement;

    return statement.metadataBuilder()
                    .withId(generateLegacyCfId(keyspace, statement.columnFamily()))
                    .build()
                    .params(statement.params())
                    .readRepairChance(0.0)
                    .dcLocalReadRepairChance(0.0)
                    .gcGraceSeconds(0)
                    .memtableFlushPeriod((int) TimeUnit.HOURS.toMillis(1));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:16,代码来源:CFMetaData.java


示例5: getTableMetadata

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
private static CFMetaData getTableMetadata(String schema)
{
    CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(schema);
    // tables with UDTs are currently not supported by CQLSSTableWrite, so we just use Types.none(), for now
    // see CASSANDRA-10624 for more details
    CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed).prepare(Types.none()).statement;
    statement.validate(ClientState.forInternalCalls());
    return statement.getCFMetaData();
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:CQLSSTableWriter.java


示例6: getCFMetaData

import org.apache.cassandra.cql3.statements.CFStatement; //导入依赖的package包/类
@SuppressWarnings("serial")
@Override
public CFMetaData getCFMetaData(String keyspace, String cfName) {
    Pair<String, String> key = Pair.create(keyspace, cfName);
    CFMetaData cfm = cfMetaDatas.get(key);
    if (cfm == null) {
        KeyspaceMetadata ks = metadata.getKeyspace(keyspace);
        TableMetadata cf = ks.getTable(cfName);
        CFStatement parsed = (CFStatement) QueryProcessor.parseStatement(cf.asCQLQuery());
        org.apache.cassandra.schema.KeyspaceMetadata ksm = Schema.instance.getKSMetaData(keyspace);
        CreateTableStatement statement = (CreateTableStatement) ((CreateTableStatement.RawStatement) parsed)
                .prepare(ksm != null ? ksm.types : Types.none()).statement;
        statement.validate(ClientState.forInternalCalls());
        cfm = statement.getCFMetaData();

        final Map<ByteBuffer, DroppedColumn> map = new HashMap<>();
        Map<ByteBuffer, DroppedColumn> droppedColumns = map;

        try {
            ResultSet r = session.execute(SELECT_DROPPED_COLUMNS + " WHERE keyspace_name = '" + keyspace
                    + "' AND table_name = '" + cfName + '\'');

            for (Row row : r) {
                String name = row.getString("column_name");
                long droppedTime = row.getTimestamp("dropped_time").getTime();
                AbstractType<?> type = parse(keyspace, row.getString("type"),
                        org.apache.cassandra.schema.Types.none());
                droppedColumns.put(UTF8Type.instance.decompose(name),
                        new CFMetaData.DroppedColumn(name, type, droppedTime * 1000));
            }
        } catch (DriverException e) {
            // ignore. Assume we're asking a v2 schema source.
        }
        if (!ignoreColumns.isEmpty()) {
            droppedColumns = new HashMap<ByteBuffer, DroppedColumn>(droppedColumns) {
                @Override
                public DroppedColumn get(Object key) {
                    DroppedColumn c = super.get(key);
                    if (c == null) {
                        String name = UTF8Type.instance.compose((ByteBuffer) key);
                        if (ignoreColumns.contains(name)) {
                            c = new DroppedColumn(name, BytesType.instance, FBUtilities.timestampMicros());
                            put((ByteBuffer) key, c);
                        }
                    }
                    return c;
                }
            };
        }
        cfm.droppedColumns(droppedColumns);
        cfMetaDatas.put(key, cfm);
    }
    return cfm;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:55,代码来源:BulkLoader.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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