本文整理汇总了Java中org.apache.cassandra.thrift.IndexType.KEYS属性的典型用法代码示例。如果您正苦于以下问题:Java IndexType.KEYS属性的具体用法?Java IndexType.KEYS怎么用?Java IndexType.KEYS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.cassandra.thrift.IndexType
的用法示例。
在下文中一共展示了IndexType.KEYS属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerializeDeserialize
@Test
public void testSerializeDeserialize() throws Exception
{
ColumnDefinition cd0 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinitionName0"),
BytesType.instance,
IndexType.KEYS,
null,
"random index name 0",
null);
ColumnDefinition cd1 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinition1"),
LongType.instance,
null,
null,
null,
null);
testSerializeDeserialize(cd0);
testSerializeDeserialize(cd1);
}
示例2: testSerializeDeserialize
@Test
public void testSerializeDeserialize() throws Exception
{
ColumnDefinition cd0 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinitionName0"),
BytesType.instance,
IndexType.KEYS,
"random index name 0");
ColumnDefinition cd1 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinition1"),
LongType.instance,
null,
null);
testSerializeDeserialize(cd0);
testSerializeDeserialize(cd1);
}
示例3: testThriftConversion
@Test
public void testThriftConversion() throws Exception
{
CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
.setComment("Test comment")
.setColumn_metadata(columnDefs)
.setKeyspace(KEYSPACE)
.setName(COLUMN_FAMILY);
// convert Thrift to CFMetaData
CFMetaData cfMetaData = CFMetaData.fromThrift(cfDef);
CfDef thriftCfDef = new CfDef();
thriftCfDef.keyspace = KEYSPACE;
thriftCfDef.name = COLUMN_FAMILY;
thriftCfDef.default_validation_class = cfDef.default_validation_class;
thriftCfDef.comment = cfDef.comment;
thriftCfDef.column_metadata = new ArrayList<ColumnDef>();
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 = cfMetaData.toThrift();
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: testThriftConversion
@Test
public void testThriftConversion() throws Exception
{
CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
.setComment("Test comment")
.setColumn_metadata(columnDefs)
.setKeyspace(KEYSPACE)
.setName(COLUMN_FAMILY);
// convert Thrift to CFMetaData
CFMetaData cfMetaData = CFMetaData.fromThrift(cfDef);
CfDef thriftCfDef = new CfDef();
thriftCfDef.keyspace = KEYSPACE;
thriftCfDef.name = COLUMN_FAMILY;
thriftCfDef.default_validation_class = cfDef.default_validation_class;
thriftCfDef.comment = cfDef.comment;
thriftCfDef.column_metadata = new ArrayList<ColumnDef>();
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 = cfMetaData.toThrift();
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(thriftCfDef.column_metadata, converted.column_metadata);
}
示例5: testThriftConversion
@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));
}
示例6: testThriftConversion
@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 = CFMetaData.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<ColumnDef>();
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 = cfMetaData.toThrift();
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));
}
示例7: testThriftToAvroConversion
@Test
public void testThriftToAvroConversion() throws Exception
{
CfDef cfDef = new CfDef().setDefault_validation_class(AsciiType.class.getCanonicalName())
.setComment("Test comment")
.setColumn_metadata(columnDefs)
.setKeyspace(KEYSPACE)
.setName(COLUMN_FAMILY);
// convert Thrift to CFMetaData
CFMetaData cfMetaData = CFMetaData.fromThrift(cfDef);
// make a correct Avro object
CfDef thriftCfDef = new CfDef();
thriftCfDef.keyspace = KEYSPACE;
thriftCfDef.name = COLUMN_FAMILY;
thriftCfDef.default_validation_class = cfDef.default_validation_class;
thriftCfDef.comment = cfDef.comment;
thriftCfDef.column_metadata = new ArrayList<ColumnDef>();
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 = cfMetaData.toThrift();
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(thriftCfDef.column_metadata, converted.column_metadata);
}
示例8: addColumn
/**
* adding a column to an column family
*
* @throws Exception
*/
@Test
public void addColumn() throws Exception {
String KEYSPACE = "mock";
client.set_keyspace(KEYSPACE);
//
String COLUMN_FAMILY = "student";
CfDef cd = getColumnFamily(client, KEYSPACE, COLUMN_FAMILY);
// column
String COLUMN = "grad";
ColumnDef columnDef = new ColumnDef(
ByteBufferHelper.toByteBuffer(COLUMN), "UTF8Type");
columnDef.index_type = IndexType.KEYS;
columnDef.index_name = "ix_" + COLUMN_FAMILY + "_" + COLUMN;
cd.addToColumn_metadata(columnDef);
client.system_update_column_family(cd);
//
System.out.println("add column [" + COLUMN + "]");// InvalidRequestException(why:Duplicate
// index name
// student_grade_idx)
// column
COLUMN = "math";
ColumnDef columnDef2 = new ColumnDef(
ByteBufferHelper.toByteBuffer(COLUMN), "UTF8Type");
columnDef2.index_type = IndexType.KEYS;
columnDef2.index_name = "ix_" + COLUMN_FAMILY + "_" + COLUMN;
cd.addToColumn_metadata(columnDef2);
client.system_update_column_family(cd);
//
System.out.println("add column [" + COLUMN + "]");
// column
COLUMN = "art";
ColumnDef columnDef3 = new ColumnDef(
ByteBufferHelper.toByteBuffer(COLUMN), "UTF8Type");
columnDef3.index_type = IndexType.KEYS;
columnDef3.index_name = "ix_" + COLUMN_FAMILY + "_" + COLUMN;
cd.addToColumn_metadata(columnDef3);
client.system_update_column_family(cd);
//
System.out.println("add column [" + COLUMN + "]");
}