本文整理汇总了Java中org.apache.cassandra.dht.LocalPartitioner类的典型用法代码示例。如果您正苦于以下问题:Java LocalPartitioner类的具体用法?Java LocalPartitioner怎么用?Java LocalPartitioner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocalPartitioner类属于org.apache.cassandra.dht包,在下文中一共展示了LocalPartitioner类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import org.apache.cassandra.dht.LocalPartitioner; //导入依赖的package包/类
public static SSTableReader open(Descriptor desc, CFMetaData metadata) throws IOException
{
IPartitioner p = desc.cfname.contains(SECONDARY_INDEX_NAME_SEPARATOR)
? new LocalPartitioner(metadata.getKeyValidator())
: StorageService.getPartitioner();
return open(desc, componentsFor(desc), metadata, p);
}
示例2: indexCfsMetadata
import org.apache.cassandra.dht.LocalPartitioner; //导入依赖的package包/类
/**
* Construct the CFMetadata for an index table, the clustering columns in the index table
* vary dependent on the kind of the indexed value.
* @param baseCfsMetadata
* @param indexMetadata
* @return
*/
public static final CFMetaData indexCfsMetadata(CFMetaData baseCfsMetadata, IndexMetadata indexMetadata)
{
Pair<ColumnDefinition, IndexTarget.Type> target = parseTarget(baseCfsMetadata, indexMetadata);
CassandraIndexFunctions utils = getFunctions(indexMetadata, target);
ColumnDefinition indexedColumn = target.left;
AbstractType<?> indexedValueType = utils.getIndexedValueType(indexedColumn);
// Tables for legacy KEYS indexes are non-compound and dense
CFMetaData.Builder builder = indexMetadata.isKeys()
? CFMetaData.Builder.create(baseCfsMetadata.ksName,
baseCfsMetadata.indexColumnFamilyName(indexMetadata),
true, false, false)
: CFMetaData.Builder.create(baseCfsMetadata.ksName,
baseCfsMetadata.indexColumnFamilyName(indexMetadata));
builder = builder.withId(baseCfsMetadata.cfId)
.withPartitioner(new LocalPartitioner(indexedValueType))
.addPartitionKey(indexedColumn.name, indexedColumn.type)
.addClusteringColumn("partition_key", baseCfsMetadata.partitioner.partitionOrdering());
if (indexMetadata.isKeys())
{
// A dense, compact table for KEYS indexes must have a compact
// value column defined, even though it is never used
CompactTables.DefaultNames names =
CompactTables.defaultNameGenerator(ImmutableSet.of(indexedColumn.name.toString(), "partition_key"));
builder = builder.addRegularColumn(names.defaultCompactValueName(), EmptyType.instance);
}
else
{
// The clustering columns for a table backing a COMPOSITES index are dependent
// on the specific type of index (there are specializations for indexes on collections)
builder = utils.addIndexClusteringColumns(builder, baseCfsMetadata, indexedColumn);
}
return builder.build().reloadIndexMetadataProperties(baseCfsMetadata);
}
示例3: tableFromSSTable
import org.apache.cassandra.dht.LocalPartitioner; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static CFMetaData tableFromSSTable(File path) throws IOException, NoSuchFieldException, IllegalAccessException {
Preconditions.checkNotNull(path);
Descriptor desc = Descriptor.fromFilename(path.getAbsolutePath());
EnumSet<MetadataType> types = EnumSet.of(MetadataType.VALIDATION, MetadataType.STATS, MetadataType.HEADER);
Map<MetadataType, MetadataComponent> sstableMetadata = desc.getMetadataSerializer().deserialize(desc, types);
ValidationMetadata validationMetadata = (ValidationMetadata) sstableMetadata.get(MetadataType.VALIDATION);
Preconditions.checkNotNull(validationMetadata, "Validation Metadata could not be resolved, accompanying Statistics.db file must be missing.");
SerializationHeader.Component header = (SerializationHeader.Component) sstableMetadata.get(MetadataType.HEADER);
Preconditions.checkNotNull(header, "Metadata could not be resolved, accompanying Statistics.db file must be missing.");
IPartitioner partitioner = validationMetadata.partitioner.endsWith("LocalPartitioner") ?
new LocalPartitioner(header.getKeyType()) :
FBUtilities.newPartitioner(validationMetadata.partitioner);
DatabaseDescriptor.setPartitionerUnsafe(partitioner);
AbstractType<?> keyType = header.getKeyType();
List<AbstractType<?>> clusteringTypes = header.getClusteringTypes();
Map<ByteBuffer, AbstractType<?>> staticColumns = header.getStaticColumns();
Map<ByteBuffer, AbstractType<?>> regularColumns = header.getRegularColumns();
int id = cfCounter.incrementAndGet();
CFMetaData.Builder builder = CFMetaData.Builder.create("turtle" + id, "turtles" + id);
staticColumns.entrySet().stream()
.forEach(entry ->
builder.addStaticColumn(UTF8Type.instance.getString(entry.getKey()), entry.getValue()));
regularColumns.entrySet().stream()
.forEach(entry ->
builder.addRegularColumn(UTF8Type.instance.getString(entry.getKey()), entry.getValue()));
List<AbstractType<?>> partTypes = keyType.getComponents();
for(int i = 0; i < partTypes.size(); i++) {
builder.addPartitionKey("partition" + (i > 0 ? i : ""), partTypes.get(i));
}
for (int i = 0; i < clusteringTypes.size(); i++) {
builder.addClusteringColumn("row" + (i > 0 ? i : ""), clusteringTypes.get(i));
}
CFMetaData metaData = builder.build();
Schema.instance.setKeyspaceMetadata(KeyspaceMetadata.create(metaData.ksName, KeyspaceParams.local(),
Tables.of(metaData), Views.none(), getTypes(), Functions.none()));
return metaData;
}