• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CachingOptions类的典型用法和代码示例

java 4次浏览

本文整理汇总了Java中org.apache.cassandra.cache.CachingOptions的典型用法代码示例。如果您正苦于以下问题:Java CachingOptions类的具体用法?Java CachingOptions怎么用?Java CachingOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CachingOptions类属于org.apache.cassandra.cache包,在下文中一共展示了CachingOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: migrateCachingOption

点赞 3

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
private static void migrateCachingOption()
{
    for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_CF)))
    {
        if (!row.has("caching"))
            continue;

        if (!CachingOptions.isLegacy(row.getString("caching")))
            continue;
        try
        {
            CachingOptions caching = CachingOptions.fromString(row.getString("caching"));
            CFMetaData table = CFMetaData.fromSchema(row);
            logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"), caching.toString(), table.ksName, table.cfName);
            String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF);
            long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)");
            table.toSchema(timestamp).apply();
        }
        catch (ConfigurationException e)
        {
            // shouldn't happen
        }
    }
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:25,
代码来源:SystemKeyspace.java

示例2: newIndexMetadata

点赞 3

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
/**
 * Creates CFMetaData for secondary index CF.
 * Secondary index CF has the same CF ID as parent's.
 *
 * @param parent Parent CF where secondary index is created
 * @param info Column definition containing secondary index definition
 * @param indexComparator Comparator for secondary index
 * @return CFMetaData for secondary index
 */
public static CFMetaData newIndexMetadata(CFMetaData parent, ColumnDefinition info, CellNameType indexComparator)
{
    // Depends on parent's cache setting, turn on its index CF's cache.
    // Row caching is never enabled; see CASSANDRA-5732
    CachingOptions indexCaching = parent.getCaching().keyCache.isEnabled()
                         ? CachingOptions.KEYS_ONLY
                         : CachingOptions.NONE;

    return new CFMetaData(parent.ksName, parent.indexColumnFamilyName(info), ColumnFamilyType.Standard, indexComparator, parent.cfId)
                         .keyValidator(info.type)
                         .readRepairChance(0.0)
                         .dcLocalReadRepairChance(0.0)
                         .gcGraceSeconds(0)
                         .caching(indexCaching)
                         .speculativeRetry(parent.speculativeRetry)
                         .compactionStrategyClass(parent.compactionStrategyClass)
                         .compactionStrategyOptions(parent.compactionStrategyOptions)
                         .reloadSecondaryIndexMetadata(parent)
                         .rebuild();
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:30,
代码来源:CFMetaData.java

示例3: defineSchema

点赞 3

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2));
    SchemaLoader.createKeyspace(KEYSPACE2,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE2, CF_STANDARD1));
    SchemaLoader.createKeyspace(KEYSPACE_CACHED,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE_CACHED, CF_CACHED).caching(CachingOptions.ALL));
    SchemaLoader.createKeyspace(KEYSPACE_CQL,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                CFMetaData.compile("CREATE TABLE " + CF_CQL + " ("
                                                 + "k int PRIMARY KEY,"
                                                 + "v1 text,"
                                                 + "v2 int"
                                                 + ")", KEYSPACE_CQL));
}
 

开发者ID:daidong,
项目名称:GraphTrek,
代码行数:27,
代码来源:CompactionsPurgeTest.java

示例4: getCachingOptions

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public CachingOptions getCachingOptions() throws SyntaxException, ConfigurationException
{
    CachingOptions options = null;
    Object val = properties.get(KW_CACHING);
    if (val == null)
        return null;
    else if (val instanceof Map)
        options = CachingOptions.fromMap(getMap(KW_CACHING));
    else if (val instanceof String) // legacy syntax
    {
        options = CachingOptions.fromString(getSimple(KW_CACHING));
        logger.warn("Setting caching options with deprecated syntax.");
    }
    return options;
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:16,
代码来源:CFPropDefs.java

示例5: applyToCFMetadata

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public void applyToCFMetadata(CFMetaData cfm) throws ConfigurationException, SyntaxException
{
    if (hasProperty(KW_COMMENT))
        cfm.comment(getString(KW_COMMENT, ""));

    cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance()));
    cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair()));
    cfm.gcGraceSeconds(getInt(KW_GCGRACESECONDS, cfm.getGcGraceSeconds()));
    int minCompactionThreshold = toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold());
    int maxCompactionThreshold = toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold());
    if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0)
        throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead.");
    cfm.minCompactionThreshold(minCompactionThreshold);
    cfm.maxCompactionThreshold(maxCompactionThreshold);
    cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive()));
    cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString())));
    cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod()));
    cfm.minIndexInterval(getInt(KW_MIN_INDEX_INTERVAL, cfm.getMinIndexInterval()));
    cfm.maxIndexInterval(getInt(KW_MAX_INDEX_INTERVAL, cfm.getMaxIndexInterval()));

    if (compactionStrategyClass != null)
    {
        cfm.compactionStrategyClass(compactionStrategyClass);
        cfm.compactionStrategyOptions(new HashMap<>(getCompactionOptions()));
    }

    cfm.bloomFilterFpChance(getDouble(KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance()));

    if (!getCompressionOptions().isEmpty())
        cfm.compressionParameters(CompressionParameters.create(getCompressionOptions()));
    CachingOptions cachingOptions = getCachingOptions();
    if (cachingOptions != null)
        cfm.caching(cachingOptions);
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:35,
代码来源:CFPropDefs.java

示例6: defineSchema

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE_CACHED,
            SimpleStrategy.class,
            KSMetaData.optsWithRF(1),
            SchemaLoader.standardCFMD(KEYSPACE_CACHED, CF_CACHED).caching(CachingOptions.ALL),
            SchemaLoader.standardCFMD(KEYSPACE_CACHED, CF_CACHEDINT)
                        .defaultValidator(IntegerType.instance)
                        .caching(new CachingOptions(new CachingOptions.KeyCache(CachingOptions.KeyCache.Type.ALL),
                                 new CachingOptions.RowCache(CachingOptions.RowCache.Type.HEAD, 100))));
}
 

开发者ID:daidong,
项目名称:GraphTrek,
代码行数:14,
代码来源:RowCacheTest.java

示例7: defineSchema

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws Exception
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD2),
                                SchemaLoader.indexCFMD(KEYSPACE1, CF_INDEXED, true),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARDLOWINDEXINTERVAL)
                                            .minIndexInterval(8)
                                            .maxIndexInterval(256)
                                            .caching(CachingOptions.NONE));
}
 

开发者ID:daidong,
项目名称:GraphTrek,
代码行数:16,
代码来源:SSTableReaderTest.java

示例8: defineSchema

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
    SchemaLoader.prepareServer();
    SchemaLoader.createKeyspace(KEYSPACE1,
                                SimpleStrategy.class,
                                KSMetaData.optsWithRF(1),
                                SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARDLOWiINTERVAL)
                                            .minIndexInterval(8)
                                            .maxIndexInterval(256)
                                            .caching(CachingOptions.NONE));
}
 

开发者ID:daidong,
项目名称:GraphTrek,
代码行数:13,
代码来源:IndexSummaryManagerTest.java

示例9: applyToCFMetadata

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public void applyToCFMetadata(CFMetaData cfm) throws ConfigurationException, SyntaxException
{
    if (hasProperty(KW_COMMENT))
        cfm.comment(getString(KW_COMMENT, ""));

    cfm.readRepairChance(getDouble(KW_READREPAIRCHANCE, cfm.getReadRepairChance()));
    cfm.dcLocalReadRepairChance(getDouble(KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair()));
    cfm.gcGraceSeconds(getInt(KW_GCGRACESECONDS, cfm.getGcGraceSeconds()));
    int minCompactionThreshold = toInt(KW_MINCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MINCOMPACTIONTHRESHOLD), cfm.getMinCompactionThreshold());
    int maxCompactionThreshold = toInt(KW_MAXCOMPACTIONTHRESHOLD, getCompactionOptions().get(KW_MAXCOMPACTIONTHRESHOLD), cfm.getMaxCompactionThreshold());
    if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0)
        throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead.");
    cfm.minCompactionThreshold(minCompactionThreshold);
    cfm.maxCompactionThreshold(maxCompactionThreshold);
    cfm.defaultTimeToLive(getInt(KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive()));
    cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getString(KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString())));
    cfm.memtableFlushPeriod(getInt(KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod()));
    cfm.populateIoCacheOnFlush(getBoolean(KW_POPULATE_IO_CACHE_ON_FLUSH, cfm.populateIoCacheOnFlush()));
    cfm.minIndexInterval(getInt(KW_MIN_INDEX_INTERVAL, cfm.getMinIndexInterval()));
    cfm.maxIndexInterval(getInt(KW_MAX_INDEX_INTERVAL, cfm.getMaxIndexInterval()));

    if (compactionStrategyClass != null)
    {
        cfm.compactionStrategyClass(compactionStrategyClass);
        cfm.compactionStrategyOptions(new HashMap<>(getCompactionOptions()));
    }

    cfm.bloomFilterFpChance(getDouble(KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance()));

    if (!getCompressionOptions().isEmpty())
        cfm.compressionParameters(CompressionParameters.create(getCompressionOptions()));
    CachingOptions cachingOptions = getCachingOptions();
    if (cachingOptions != null)
        cfm.caching(cachingOptions);
}
 

开发者ID:rajath26,
项目名称:cassandra-trunk,
代码行数:36,
代码来源:CFPropDefs.java

示例10: migrateCachingOption

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
private static void migrateCachingOption()
{
    for (UntypedResultSet.Row row : processInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_CF)))
    {
        if (!row.has("caching"))
            continue;

        if (!CachingOptions.isLegacy(row.getString("caching")))
            continue;
        try
        {
            CachingOptions caching = CachingOptions.fromString(row.getString("caching"));
            CFMetaData table = CFMetaData.fromSchema(row);
            logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"), caching.toString(), table.ksName, table.cfName);
            String query = String.format("SELECT writetime(type) "
                    + "FROM system.%s "
                    + "WHERE keyspace_name = '%s' AND columnfamily_name = '%s'",
                    SCHEMA_COLUMNFAMILIES_CF,
                    table.ksName,
                    table.cfName);
            long timestamp = processInternal(query).one().getLong("writetime(type)");
            table.toSchema(timestamp).apply();
        }
        catch (ConfigurationException e)
        {
            // shouldn't happen
        }
    }
}
 

开发者ID:rajath26,
项目名称:cassandra-trunk,
代码行数:30,
代码来源:SystemKeyspace.java

示例11: applyPropertiesToCFMetadata

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public static void applyPropertiesToCFMetadata(CFMetaData cfm, CFPropDefs cfProps) throws InvalidRequestException, ConfigurationException
{
    if (cfProps.hasProperty(CFPropDefs.KW_COMPACTION_STRATEGY_CLASS))
        cfm.compactionStrategyClass(cfProps.compactionStrategyClass);

    if (cfProps.hasProperty(CFPropDefs.KW_COMPARATOR))
        throw new InvalidRequestException("Can't change CF comparator after creation");

    if (cfProps.hasProperty(CFPropDefs.KW_COMMENT))
        cfm.comment(cfProps.getProperty(CFPropDefs.KW_COMMENT));

    if (cfProps.hasProperty(CFPropDefs.KW_DEFAULTVALIDATION))
    {
        try
        {
            cfm.defaultValidator(cfProps.getValidator());
        }
        catch (RequestValidationException e)
        {
            throw new InvalidRequestException(String.format("Invalid validation type %s",
                                                            cfProps.getProperty(CFPropDefs.KW_DEFAULTVALIDATION)));
        }
    }

    cfm.readRepairChance(cfProps.getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, cfm.getReadRepairChance()));
    cfm.dcLocalReadRepairChance(cfProps.getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE, cfm.getDcLocalReadRepair()));
    cfm.gcGraceSeconds(cfProps.getPropertyInt(CFPropDefs.KW_GCGRACESECONDS, cfm.getGcGraceSeconds()));
    int minCompactionThreshold = cfProps.getPropertyInt(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD, cfm.getMinCompactionThreshold());
    int maxCompactionThreshold = cfProps.getPropertyInt(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD, cfm.getMaxCompactionThreshold());
    if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0)
        throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead.");
    cfm.minCompactionThreshold(minCompactionThreshold);
    cfm.maxCompactionThreshold(maxCompactionThreshold);
    cfm.caching(CachingOptions.fromString(cfProps.getPropertyString(CFPropDefs.KW_CACHING, cfm.getCaching().toString())));
    cfm.defaultTimeToLive(cfProps.getPropertyInt(CFPropDefs.KW_DEFAULT_TIME_TO_LIVE, cfm.getDefaultTimeToLive()));
    cfm.speculativeRetry(CFMetaData.SpeculativeRetry.fromString(cfProps.getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, cfm.getSpeculativeRetry().toString())));
    cfm.bloomFilterFpChance(cfProps.getPropertyDouble(CFPropDefs.KW_BF_FP_CHANCE, cfm.getBloomFilterFpChance()));
    cfm.memtableFlushPeriod(cfProps.getPropertyInt(CFPropDefs.KW_MEMTABLE_FLUSH_PERIOD, cfm.getMemtableFlushPeriod()));

    if (!cfProps.compactionStrategyOptions.isEmpty())
    {
        cfm.compactionStrategyOptions(new HashMap<String, String>());
        for (Map.Entry<String, String> entry : cfProps.compactionStrategyOptions.entrySet())
            cfm.compactionStrategyOptions.put(entry.getKey(), entry.getValue());
    }

    if (!cfProps.compressionParameters.isEmpty())
    {
        cfm.compressionParameters(CompressionParameters.create(cfProps.compressionParameters));
    }
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:52,
代码来源:AlterTableStatement.java

示例12: getCFMetaData

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
/**
 * Returns a CFMetaData instance based on the parameters parsed from this
 * <code>CREATE</code> statement, or defaults where applicable.
 *
 * @param keyspace keyspace to apply this column family to
 * @return a CFMetaData instance corresponding to the values parsed from this statement
 * @throws InvalidRequestException on failure to validate parsed parameters
 */
public CFMetaData getCFMetaData(String keyspace, List<ByteBuffer> variables) throws InvalidRequestException
{
    validate(variables);

    try
    {
        boolean isDense = columns.isEmpty();
        CFMetaData newCFMD = new CFMetaData(keyspace,
                                            name,
                                            ColumnFamilyType.Standard,
                                            CellNames.fromAbstractType(cfProps.getComparator(), isDense));

        if (CFMetaData.DEFAULT_COMPRESSOR != null && cfProps.compressionParameters.isEmpty())
            cfProps.compressionParameters.put(CompressionParameters.SSTABLE_COMPRESSION, CFMetaData.DEFAULT_COMPRESSOR);
        int maxCompactionThreshold = getPropertyInt(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD, CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD);
        int minCompactionThreshold = getPropertyInt(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD, CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD);
        if (minCompactionThreshold <= 0 || maxCompactionThreshold <= 0)
            throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been deprecated, set the compaction option 'enabled' to false instead.");

        newCFMD.isDense(isDense)
               .addAllColumnDefinitions(getColumns(newCFMD))
               .comment(cfProps.getProperty(CFPropDefs.KW_COMMENT))
               .readRepairChance(getPropertyDouble(CFPropDefs.KW_READREPAIRCHANCE, CFMetaData.DEFAULT_READ_REPAIR_CHANCE))
               .dcLocalReadRepairChance(getPropertyDouble(CFPropDefs.KW_DCLOCALREADREPAIRCHANCE, CFMetaData.DEFAULT_DCLOCAL_READ_REPAIR_CHANCE))
               .gcGraceSeconds(getPropertyInt(CFPropDefs.KW_GCGRACESECONDS, CFMetaData.DEFAULT_GC_GRACE_SECONDS))
               .defaultValidator(cfProps.getValidator())
               .minCompactionThreshold(minCompactionThreshold)
               .maxCompactionThreshold(maxCompactionThreshold)
               .keyValidator(TypeParser.parse(CFPropDefs.comparators.get(getKeyType())))
               .compactionStrategyClass(cfProps.compactionStrategyClass)
               .compactionStrategyOptions(cfProps.compactionStrategyOptions)
               .compressionParameters(CompressionParameters.create(cfProps.compressionParameters))
               .caching(CachingOptions.fromString(getPropertyString(CFPropDefs.KW_CACHING, CFMetaData.DEFAULT_CACHING_STRATEGY.toString())))
               .speculativeRetry(CFMetaData.SpeculativeRetry.fromString(getPropertyString(CFPropDefs.KW_SPECULATIVE_RETRY, CFMetaData.DEFAULT_SPECULATIVE_RETRY.toString())))
               .bloomFilterFpChance(getPropertyDouble(CFPropDefs.KW_BF_FP_CHANCE, null))
               .memtableFlushPeriod(getPropertyInt(CFPropDefs.KW_MEMTABLE_FLUSH_PERIOD, 0))
               .defaultTimeToLive(getPropertyInt(CFPropDefs.KW_DEFAULT_TIME_TO_LIVE, CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE));

        // CQL2 can have null keyAliases
        if (keyAlias != null)
            newCFMD.addColumnDefinition(ColumnDefinition.partitionKeyDef(newCFMD, keyAlias, newCFMD.getKeyValidator(), null));

        return newCFMD.rebuild();
    }
    catch (ConfigurationException | SyntaxException e)
    {
        throw new InvalidRequestException(e.toString());
    }
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:58,
代码来源:CreateColumnFamilyStatement.java

示例13: getCaching

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public CachingOptions getCaching()
{
    return caching;
}
 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:5,
代码来源:CFMetaData.java

示例14: fromThrift

点赞 2

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public static CFMetaData fromThrift(org.apache.cassandra.thrift.CfDef cf_def) throws InvalidRequestException, ConfigurationException
{
    ColumnFamilyType cfType = ColumnFamilyType.create(cf_def.column_type);
    if (cfType == null)
        throw new InvalidRequestException("Invalid column type " + cf_def.column_type);

    applyImplicitDefaults(cf_def);

    try
    {
        AbstractType<?> rawComparator = TypeParser.parse(cf_def.comparator_type);
        AbstractType<?> subComparator = cfType == ColumnFamilyType.Standard
                                      ? null
                                      : cf_def.subcomparator_type == null ? BytesType.instance : TypeParser.parse(cf_def.subcomparator_type);

        // Dense for thrit is simplified as all column metadata are REGULAR
        boolean isDense = (cf_def.column_metadata == null || cf_def.column_metadata.isEmpty()) && !isCQL3OnlyPKComparator(rawComparator);
        CellNameType comparator = CellNames.fromAbstractType(makeRawAbstractType(rawComparator, subComparator), isDense);

        UUID cfId = Schema.instance.getId(cf_def.keyspace, cf_def.name);
        if (cfId == null)
            cfId = UUIDGen.getTimeUUID();

        CFMetaData newCFMD = new CFMetaData(cf_def.keyspace,
                                            cf_def.name,
                                            cfType,
                                            comparator,
                                            cfId);

        if (cf_def.isSetGc_grace_seconds()) { newCFMD.gcGraceSeconds(cf_def.gc_grace_seconds); }
        if (cf_def.isSetMin_compaction_threshold()) { newCFMD.minCompactionThreshold(cf_def.min_compaction_threshold); }
        if (cf_def.isSetMax_compaction_threshold()) { newCFMD.maxCompactionThreshold(cf_def.max_compaction_threshold); }
        if (cf_def.isSetCompaction_strategy())
            newCFMD.compactionStrategyClass = createCompactionStrategy(cf_def.compaction_strategy);
        if (cf_def.isSetCompaction_strategy_options())
            newCFMD.compactionStrategyOptions(new HashMap<>(cf_def.compaction_strategy_options));
        if (cf_def.isSetBloom_filter_fp_chance())
            newCFMD.bloomFilterFpChance(cf_def.bloom_filter_fp_chance);
        if (cf_def.isSetMemtable_flush_period_in_ms())
            newCFMD.memtableFlushPeriod(cf_def.memtable_flush_period_in_ms);
        if (cf_def.isSetCaching() || cf_def.isSetCells_per_row_to_cache())
            newCFMD.caching(CachingOptions.fromThrift(cf_def.caching, cf_def.cells_per_row_to_cache));
        if (cf_def.isSetRead_repair_chance())
            newCFMD.readRepairChance(cf_def.read_repair_chance);
        if (cf_def.isSetDefault_time_to_live())
            newCFMD.defaultTimeToLive(cf_def.default_time_to_live);
        if (cf_def.isSetDclocal_read_repair_chance())
            newCFMD.dcLocalReadRepairChance(cf_def.dclocal_read_repair_chance);
        if (cf_def.isSetMin_index_interval())
            newCFMD.minIndexInterval(cf_def.min_index_interval);
        if (cf_def.isSetMax_index_interval())
            newCFMD.maxIndexInterval(cf_def.max_index_interval);
        if (cf_def.isSetSpeculative_retry())
            newCFMD.speculativeRetry(SpeculativeRetry.fromString(cf_def.speculative_retry));
        if (cf_def.isSetPopulate_io_cache_on_flush())
            newCFMD.populateIoCacheOnFlush(cf_def.populate_io_cache_on_flush);
        if (cf_def.isSetTriggers())
            newCFMD.triggers(TriggerDefinition.fromThrift(cf_def.triggers));

        CompressionParameters cp = CompressionParameters.create(cf_def.compression_options);

        if (cf_def.isSetKey_validation_class()) { newCFMD.keyValidator(TypeParser.parse(cf_def.key_validation_class)); }
        if (cf_def.isSetKey_alias() && !(newCFMD.keyValidator instanceof CompositeType))
            newCFMD.addOrReplaceColumnDefinition(ColumnDefinition.partitionKeyDef(newCFMD, cf_def.key_alias, newCFMD.keyValidator, null));

        return newCFMD.addAllColumnDefinitions(ColumnDefinition.fromThrift(newCFMD, cf_def.column_metadata))
                      .comment(cf_def.comment)
                      .defaultValidator(TypeParser.parse(cf_def.default_validation_class))
                      .compressionParameters(cp)
                      .rebuild();
    }
    catch (SyntaxException | MarshalException e)
    {
        throw new ConfigurationException(e.getMessage());
    }
}
 

开发者ID:rajath26,
项目名称:cassandra-trunk,
代码行数:77,
代码来源:CFMetaData.java

示例15: caching

点赞 1

import org.apache.cassandra.cache.CachingOptions; //导入依赖的package包/类
public CFMetaData caching(CachingOptions prop) {caching = prop; return this;} 

开发者ID:vcostet,
项目名称:cassandra-kmean,
代码行数:2,
代码来源:CFMetaData.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)