本文整理汇总了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);
}
}
}
示例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);
}
}
示例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));
}
示例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);
}
示例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));
}