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