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

Java ThriftConversion类代码示例

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

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



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

示例1: run

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
public void run(final SimpleClient client) throws IOException
{
    run(new CQLQueryExecutor()
    {
        public boolean execute(String cqlQuery, List<String> queryParams) throws Exception
        {
            ResultMessage result = null;
            if (session.usePreparedStatements())
            {
                byte[] stmntId = getPreparedStatement(client, cqlQuery);
                result = client.executePrepared(stmntId, queryParamsAsByteBuffer(queryParams), ThriftConversion.fromThrift(session.getConsistencyLevel()));
            }
            else
            {
                String formattedQuery = formatCqlQuery(cqlQuery, queryParams);
                result = client.execute(formattedQuery, ThriftConversion.fromThrift(session.getConsistencyLevel()));
            }
            return validateNativeResult(result);
        }
    });
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:CQLOperation.java


示例2: getValidate

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
public List<ValidatingSchemaQuery> getValidate(Timer timer, PartitionGenerator generator, SeedManager seedManager, StressSettings settings)
{
    if (validationFactories == null)
    {
        synchronized (this)
        {
            if (validationFactories == null)
            {
                maybeLoadSchemaInfo(settings);
                validationFactories = ValidatingSchemaQuery.create(tableMetaData, settings);
            }
        }
    }

    List<ValidatingSchemaQuery> queries = new ArrayList<>();
    for (ValidatingSchemaQuery.Factory factory : validationFactories)
        queries.add(factory.create(timer, settings, generator, seedManager, ThriftConversion.fromThrift(settings.command.consistencyLevel)));
    return queries;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:StressProfile.java


示例3: testNonTextComparator

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test // test for CASSANDRA-8178
public void testNonTextComparator() throws Throwable
{
    ColumnDef column = new ColumnDef();
    column.setName(bytes(42))
          .setValidation_class(UTF8Type.instance.toString());

    CfDef cf = new CfDef("thriftcompat", "JdbcInteger");
    cf.setColumn_type("Standard")
      .setComparator_type(Int32Type.instance.toString())
      .setDefault_validation_class(UTF8Type.instance.toString())
      .setKey_validation_class(BytesType.instance.toString())
      .setColumn_metadata(Collections.singletonList(column));

    SchemaLoader.createKeyspace("thriftcompat", KeyspaceParams.simple(1), ThriftConversion.fromThrift(cf));

    // the comparator is IntegerType, and there is a column named 42 with a UTF8Type validation type
    execute("INSERT INTO \"thriftcompat\".\"JdbcInteger\" (key, \"42\") VALUES (0x00000001, 'abc')");
    execute("UPDATE \"thriftcompat\".\"JdbcInteger\" SET \"42\" = 'abc' WHERE key = 0x00000001");
    execute("DELETE \"42\" FROM \"thriftcompat\".\"JdbcInteger\" WHERE key = 0x00000000");
    UntypedResultSet results = execute("SELECT key, \"42\" FROM \"thriftcompat\".\"JdbcInteger\"");
    assertEquals(1, results.size());
    UntypedResultSet.Row row = results.iterator().next();
    assertEquals(ByteBufferUtil.bytes(1), row.getBytes("key"));
    assertEquals("abc", row.getString("42"));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:27,代码来源:ThriftCompatibilityTest.java


示例4: execute

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Override
public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
{
    return handler.javaDriverHandler().apply(
            client.executePrepared(
                    (PreparedStatement) preparedStatementId,
                    queryParams,
                    ThriftConversion.fromThrift(settings.command.consistencyLevel)));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:10,代码来源:CqlOperation.java


示例5: run

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
public boolean run() throws Exception
{
    CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(), thriftArgs(), ThriftConversion.toThrift(cl));
    validate(rs);
    rowCount = rs.getRowsSize();
    partitionCount = Math.min(1, rowCount);
    return true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:SchemaQuery.java


示例6: run

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
public boolean run() throws Exception
{
    CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(), thriftArgs(), ThriftConversion.toThrift(cl));
    rowCount = rs.getRowsSize();
    partitionCount = Math.min(1, rowCount);
    return true;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:SchemaQuery.java


示例7: testDropCompactStaticColumn

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test // test for CASSANDRA-9867
public void testDropCompactStaticColumn()
{
    ColumnDef column1 = new ColumnDef();
    column1.setName(bytes(42))
          .setValidation_class(UTF8Type.instance.toString());

    ColumnDef column2 = new ColumnDef();
    column2.setName(bytes(25))
           .setValidation_class(UTF8Type.instance.toString());

    CfDef cf = new CfDef("thriftks", "staticcompact");
    cf.setColumn_type("Standard")
      .setComparator_type(Int32Type.instance.toString())
      .setDefault_validation_class(UTF8Type.instance.toString())
      .setKey_validation_class(BytesType.instance.toString())
      .setColumn_metadata(Arrays.asList(column1, column2));

    SchemaLoader.createKeyspace("thriftks", KeyspaceParams.simple(1), ThriftConversion.fromThrift(cf));
    CFMetaData cfm = Schema.instance.getCFMetaData("thriftks", "staticcompact");

    // assert the both columns are in the metadata
    assertTrue(cfm.getColumnMetadata().containsKey(bytes(42)));
    assertTrue(cfm.getColumnMetadata().containsKey(bytes(25)));

    // remove column2
    cf.setColumn_metadata(Collections.singletonList(column1));
    MigrationManager.announceColumnFamilyUpdate(ThriftConversion.fromThriftForUpdate(cf, cfm), true);

    // assert that it's gone from metadata
    assertTrue(cfm.getColumnMetadata().containsKey(bytes(42)));
    assertFalse(cfm.getColumnMetadata().containsKey(bytes(25)));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:34,代码来源:ThriftCompatibilityTest.java


示例8: testCFMetaDataSerialization

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test
public void testCFMetaDataSerialization() throws ConfigurationException, InvalidRequestException
{
    // test serialization of all defined test CFs.
    for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
    {
        for (CFMetaData cfm : Schema.instance.getTablesAndViews(keyspaceName))
        {
            CFMetaData cfmDupe = ThriftConversion.fromThrift(ThriftConversion.toThrift(cfm));
            assertNotNull(cfmDupe);
            assertEquals(cfm, cfmDupe);
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:DatabaseDescriptorTest.java


示例9: testKSMetaDataSerialization

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test
public void testKSMetaDataSerialization() throws ConfigurationException
{
    for (String ks : Schema.instance.getNonSystemKeyspaces())
    {
        // Not testing round-trip on the KsDef via serDe() because maps
        KeyspaceMetadata ksm = Schema.instance.getKSMetaData(ks);
        KeyspaceMetadata ksmDupe = ThriftConversion.fromThrift(ThriftConversion.toThrift(ksm));
        assertNotNull(ksmDupe);
        assertEquals(ksm, ksmDupe);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:DatabaseDescriptorTest.java


示例10: testThriftConversion

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test
public void testThriftConversion() throws Exception
{
    CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
                             .setComment("Test comment")
                             .setColumn_metadata(columnDefs)
                             .setKeyspace(KEYSPACE1)
                             .setName(CF_STANDARD1);

    // convert Thrift to CFMetaData
    CFMetaData cfMetaData = ThriftConversion.fromThrift(cfDef);

    CfDef thriftCfDef = new CfDef();
    thriftCfDef.keyspace = KEYSPACE1;
    thriftCfDef.name = CF_STANDARD1;
    thriftCfDef.default_validation_class = cfDef.default_validation_class;
    thriftCfDef.comment = cfDef.comment;
    thriftCfDef.column_metadata = new ArrayList<>();
    for (ColumnDef columnDef : columnDefs)
    {
        ColumnDef c = new ColumnDef();
        c.name = ByteBufferUtil.clone(columnDef.name);
        c.validation_class = columnDef.getValidation_class();
        c.index_name = columnDef.getIndex_name();
        c.index_type = columnDef.getIndex_type();
        if (columnDef.isSetIndex_options())
            c.setIndex_options(columnDef.getIndex_options());
        thriftCfDef.column_metadata.add(c);
    }

    CfDef converted = ThriftConversion.toThrift(cfMetaData);

    assertEquals(thriftCfDef.keyspace, converted.keyspace);
    assertEquals(thriftCfDef.name, converted.name);
    assertEquals(thriftCfDef.default_validation_class, converted.default_validation_class);
    assertEquals(thriftCfDef.comment, converted.comment);
    assertEquals(new HashSet<>(thriftCfDef.column_metadata), new HashSet<>(converted.column_metadata));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:39,代码来源:CFMetaDataTest.java


示例11: testSerializeDeserialize

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
protected void testSerializeDeserialize(CFMetaData cfm, ColumnDefinition cd) throws Exception
{
    ColumnDefinition newCd = ThriftConversion.fromThrift(cfm.ksName, cfm.cfName, cfm.comparator.subtype(0), null, ThriftConversion.toThrift(cfm, cd));
    Assert.assertNotSame(cd, newCd);
    Assert.assertEquals(cd.hashCode(), newCd.hashCode());
    Assert.assertEquals(cd, newCd);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:ColumnDefinitionTest.java


示例12: testThriftConversion

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Test
public void testThriftConversion() throws Exception
{
    CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
                             .setComment("Test comment")
                             .setColumn_metadata(columnDefs)
                             .setKeyspace(KEYSPACE1)
                             .setName(CF_STANDARD1);

    // convert Thrift to CFMetaData
    CFMetaData cfMetaData = ThriftConversion.fromThrift(cfDef);

    CfDef thriftCfDef = new CfDef();
    thriftCfDef.keyspace = KEYSPACE1;
    thriftCfDef.name = CF_STANDARD1;
    thriftCfDef.default_validation_class = cfDef.default_validation_class;
    thriftCfDef.comment = cfDef.comment;
    thriftCfDef.column_metadata = new ArrayList<>();
    for (ColumnDef columnDef : columnDefs)
    {
        ColumnDef c = new ColumnDef();
        c.name = ByteBufferUtil.clone(columnDef.name);
        c.validation_class = columnDef.getValidation_class();
        c.index_name = columnDef.getIndex_name();
        c.index_type = IndexType.KEYS;
        thriftCfDef.column_metadata.add(c);
    }

    CfDef converted = ThriftConversion.toThrift(cfMetaData);

    assertEquals(thriftCfDef.keyspace, converted.keyspace);
    assertEquals(thriftCfDef.name, converted.name);
    assertEquals(thriftCfDef.default_validation_class, converted.default_validation_class);
    assertEquals(thriftCfDef.comment, converted.comment);
    assertEquals(new HashSet<>(thriftCfDef.column_metadata), new HashSet<>(converted.column_metadata));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:37,代码来源:SchemaKeyspaceTest.java


示例13: run

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
public boolean run() throws Exception
{
    CqlResult rs = client.execute_prepared_cql3_query(thriftId, partitions.get(0).getToken(), thriftArgs(partitions.get(0)), ThriftConversion.toThrift(cl));
    validate(rs);
    rowCount = rs.getRowsSize();
    partitionCount = Math.min(1, rowCount);
    return true;
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:9,代码来源:SchemaQuery.java


示例14: execute

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Override
public <V> V execute(Object preparedStatementId, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler)
{
    return handler.javaDriverHandler().apply(
            client.executePrepared(
                    (PreparedStatement) preparedStatementId,
                    queryParams,
                    ThriftConversion.fromThrift(state.settings.command.consistencyLevel)));
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:10,代码来源:CqlOperation.java


示例15: execute

import org.apache.cassandra.thrift.ThriftConversion; //导入依赖的package包/类
@Override
public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
{
    return handler.javaDriverHandler().apply(
            client.executePrepared(
                    (PreparedStatement) preparedStatementId,
                    queryParams,
                    ThriftConversion.fromThrift(state.settings.command.consistencyLevel)));
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:10,代码来源:CqlOperation.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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