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


Java ThriftConversion.fromThrift方法代码示例

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


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

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

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

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

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

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


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