本文整理汇总了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;
}
示例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;
}