当前位置: 首页>>代码示例>>Java>>正文


Java FBUtilities.fromJsonMap方法代码示例

本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.fromJsonMap方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.fromJsonMap方法的具体用法?Java FBUtilities.fromJsonMap怎么用?Java FBUtilities.fromJsonMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.utils.FBUtilities的用法示例。


在下文中一共展示了FBUtilities.fromJsonMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromSchema

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
 * Deserialize columns from storage-level representation
 *
 * @param serializedColumns storage-level partition containing the column definitions
 * @return the list of processed ColumnDefinitions
 */
public static List<ColumnDefinition> fromSchema(UntypedResultSet serializedColumns, String ksName, String cfName, AbstractType<?> rawComparator, boolean isSuper)
{
    List<ColumnDefinition> cds = new ArrayList<>();
    for (UntypedResultSet.Row row : serializedColumns)
    {
        Kind kind = row.has(KIND)
                  ? Kind.deserialize(row.getString(KIND))
                  : Kind.REGULAR;

        Integer componentIndex = null;
        if (row.has(COMPONENT_INDEX))
            componentIndex = row.getInt(COMPONENT_INDEX);
        else if (kind == Kind.CLUSTERING_COLUMN && isSuper)
            componentIndex = 1; // A ColumnDefinition for super columns applies to the column component

        // Note: we save the column name as string, but we should not assume that it is an UTF8 name, we
        // we need to use the comparator fromString method
        AbstractType<?> comparator = getComponentComparator(rawComparator, componentIndex, kind);
        ColumnIdentifier name = new ColumnIdentifier(comparator.fromString(row.getString(COLUMN_NAME)), comparator);

        AbstractType<?> validator;
        try
        {
            validator = TypeParser.parse(row.getString(TYPE));
        }
        catch (RequestValidationException e)
        {
            throw new RuntimeException(e);
        }

        IndexType indexType = null;
        if (row.has(INDEX_TYPE))
            indexType = IndexType.valueOf(row.getString(INDEX_TYPE));

        Map<String, String> indexOptions = null;
        if (row.has(INDEX_OPTIONS))
            indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));

        String indexName = null;
        if (row.has(INDEX_NAME))
            indexName = row.getString(INDEX_NAME);

        cds.add(new ColumnDefinition(ksName, cfName, name, validator, indexType, indexOptions, indexName, componentIndex, kind));
    }

    return cds;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:54,代码来源:ColumnDefinition.java

示例2: fromSchema

import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/**
 * Deserialize columns from storage-level representation
 *
 * @param serializedColumns storage-level partition containing the column definitions
 * @return the list of processed ColumnDefinitions
 */
public static List<ColumnDefinition> fromSchema(Row serializedColumns, CFMetaData cfm)
{
    List<ColumnDefinition> cds = new ArrayList<>();

    String query = String.format("SELECT * FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.SCHEMA_COLUMNS_CF);
    for (UntypedResultSet.Row row : QueryProcessor.resultify(query, serializedColumns))
    {
        Type type = row.has(TYPE)
                  ? Enum.valueOf(Type.class, row.getString(TYPE).toUpperCase())
                  : Type.REGULAR;

        Integer componentIndex = null;
        if (row.has(COMPONENT_INDEX))
            componentIndex = row.getInt(COMPONENT_INDEX);
        else if (type == Type.CLUSTERING_KEY && cfm.isSuper())
            componentIndex = 1; // A ColumnDefinition for super columns applies to the column component

        ByteBuffer name = cfm.getComponentComparator(componentIndex, type).fromString(row.getString(COLUMN_NAME));

        AbstractType<?> validator;
        try
        {
            validator = TypeParser.parse(row.getString(VALIDATOR));
        }
        catch (RequestValidationException e)
        {
            throw new RuntimeException(e);
        }

        IndexType indexType = null;
        if (row.has(INDEX_TYPE))
            indexType = IndexType.valueOf(row.getString(INDEX_TYPE));

        Map<String, String> indexOptions = null;
        if (row.has(INDEX_OPTIONS))
            indexOptions = FBUtilities.fromJsonMap(row.getString(INDEX_OPTIONS));

        String indexName = null;
        if (row.has(INDEX_NAME))
            indexName = row.getString(INDEX_NAME);

        cds.add(new ColumnDefinition(name, validator, indexType, indexOptions, indexName, componentIndex, type));
    }

    return cds;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:53,代码来源:ColumnDefinition.java


注:本文中的org.apache.cassandra.utils.FBUtilities.fromJsonMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。