本文整理汇总了Java中org.apache.cassandra.config.CFMetaData.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java CFMetaData.Builder方法的具体用法?Java CFMetaData.Builder怎么用?Java CFMetaData.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.config.CFMetaData
的用法示例。
在下文中一共展示了CFMetaData.Builder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: metadataBuilder
import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
public CFMetaData.Builder metadataBuilder()
{
CFMetaData.Builder builder = CFMetaData.Builder.create(keyspace(), columnFamily(), isDense, isCompound, hasCounters);
builder.withId(id);
for (int i = 0; i < keyAliases.size(); i++)
builder.addPartitionKey(keyAliases.get(i), keyTypes.get(i));
for (int i = 0; i < columnAliases.size(); i++)
builder.addClusteringColumn(columnAliases.get(i), clusteringTypes.get(i));
boolean isStaticCompact = !isDense && !isCompound;
for (Map.Entry<ColumnIdentifier, AbstractType> entry : columns.entrySet())
{
ColumnIdentifier name = entry.getKey();
// Note that for "static" no-clustering compact storage we use static for the defined columns
if (staticColumns.contains(name) || isStaticCompact)
builder.addStaticColumn(name, entry.getValue());
else
builder.addRegularColumn(name, entry.getValue());
}
boolean isCompactTable = isDense || !isCompound;
if (isCompactTable)
{
CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(builder.usedColumnNames());
// Compact tables always have a clustering and a single regular value.
if (isStaticCompact)
{
builder.addClusteringColumn(names.defaultClusteringName(), UTF8Type.instance);
builder.addRegularColumn(names.defaultCompactValueName(), hasCounters ? CounterColumnType.instance : BytesType.instance);
}
else if (isDense && !builder.hasRegulars())
{
// Even for dense, we might not have our regular column if it wasn't part of the declaration. If
// that's the case, add it but with a specific EmptyType so we can recognize that case later
builder.addRegularColumn(names.defaultCompactValueName(), EmptyType.instance);
}
}
return builder;
}
示例2: createNewCFMetaData
import org.apache.cassandra.config.CFMetaData; //导入方法依赖的package包/类
public static CFMetaData createNewCFMetaData(final Descriptor inputSSTableDescriptor,
final CFMetaData metadata) {
final CFMetaData.Builder cfMetadataBuilder = CFMetaData.Builder.create(inputSSTableDescriptor.ksname,
inputSSTableDescriptor.cfname);
final Collection<ColumnDefinition> colDefs = metadata.allColumns();
for (ColumnDefinition colDef : colDefs) {
switch (colDef.kind) {
case PARTITION_KEY:
cfMetadataBuilder.addPartitionKey(colDef.name, colDef.cellValueType());
break;
case CLUSTERING:
cfMetadataBuilder.addClusteringColumn(colDef.name, colDef.cellValueType());
break;
case STATIC:
cfMetadataBuilder.addStaticColumn(colDef.name, colDef.cellValueType());
break;
default:
cfMetadataBuilder.addRegularColumn(colDef.name, colDef.cellValueType());
}
}
cfMetadataBuilder.withPartitioner(metadata.partitioner);
final CFMetaData cfm = cfMetadataBuilder.build();
cfm.compression(CompressionParams.DEFAULT);
return cfm;
}