本文整理汇总了Java中org.apache.cassandra.utils.FBUtilities.fromJsonList方法的典型用法代码示例。如果您正苦于以下问题:Java FBUtilities.fromJsonList方法的具体用法?Java FBUtilities.fromJsonList怎么用?Java FBUtilities.fromJsonList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.utils.FBUtilities
的用法示例。
在下文中一共展示了FBUtilities.fromJsonList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrievePartitionKeyValidator
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/** retrieve the key validator from system.schema_columnfamilies table */
private void retrievePartitionKeyValidator(Cassandra.Client client) throws Exception
{
String keyspace = ConfigHelper.getOutputKeyspace(conf);
String cfName = ConfigHelper.getOutputColumnFamily(conf);
String query = "SELECT key_validator," +
" key_aliases," +
" column_aliases " +
"FROM system.schema_columnfamilies " +
"WHERE keyspace_name='%s' and columnfamily_name='%s'";
String formatted = String.format(query, keyspace, cfName);
CqlResult result = client.execute_cql3_query(ByteBufferUtil.bytes(formatted), Compression.NONE, ConsistencyLevel.ONE);
Column rawKeyValidator = result.rows.get(0).columns.get(0);
String validator = ByteBufferUtil.string(ByteBuffer.wrap(rawKeyValidator.getValue()));
keyValidator = parseType(validator);
Column rawPartitionKeys = result.rows.get(0).columns.get(1);
String keyString = ByteBufferUtil.string(ByteBuffer.wrap(rawPartitionKeys.getValue()));
logger.debug("partition keys: {}", keyString);
List<String> keys = FBUtilities.fromJsonList(keyString);
partitionKeyColumns = new String[keys.size()];
int i = 0;
for (String key : keys)
{
partitionKeyColumns[i] = key;
i++;
}
Column rawClusterColumns = result.rows.get(0).columns.get(2);
String clusterColumnString = ByteBufferUtil.string(ByteBuffer.wrap(rawClusterColumns.getValue()));
logger.debug("cluster columns: {}", clusterColumnString);
clusterColumns = FBUtilities.fromJsonList(clusterColumnString);
}
示例2: retrievePartitionKeyValidator
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/** retrieve the key validator from system.schema_columnfamilies table */
private void retrievePartitionKeyValidator(Cassandra.Client client) throws Exception
{
String keyspace = ConfigHelper.getOutputKeyspace(conf);
String cfName = ConfigHelper.getOutputColumnFamily(conf);
String query = "SELECT key_validator," +
" key_aliases," +
" column_aliases " +
"FROM system.schema_columnfamilies " +
"WHERE keyspace_name='%s' and columnfamily_name='%s'";
String formatted = String.format(query, keyspace, cfName);
CqlResult result = client.execute_cql3_query(ByteBufferUtil.bytes(formatted), Compression.NONE, ConsistencyLevel.ONE);
Column rawKeyValidator = result.rows.get(0).columns.get(0);
String validator = ByteBufferUtil.string(ByteBuffer.wrap(rawKeyValidator.getValue()));
keyValidator = parseType(validator);
Column rawPartitionKeys = result.rows.get(0).columns.get(1);
String keyString = ByteBufferUtil.string(ByteBuffer.wrap(rawPartitionKeys.getValue()));
logger.debug("partition keys: " + keyString);
List<String> keys = FBUtilities.fromJsonList(keyString);
partitionKeyColumns = new String[keys.size()];
int i = 0;
for (String key : keys)
{
partitionKeyColumns[i] = key;
i++;
}
Column rawClusterColumns = result.rows.get(0).columns.get(2);
String clusterColumnString = ByteBufferUtil.string(ByteBuffer.wrap(rawClusterColumns.getValue()));
logger.debug("cluster columns: " + clusterColumnString);
clusterColumns = FBUtilities.fromJsonList(clusterColumnString);
}
示例3: getCfDef
import org.apache.cassandra.utils.FBUtilities; //导入方法依赖的package包/类
/** return the CfDef for the column family */
protected CfDef getCfDef(Cassandra.Client client)
throws InvalidRequestException,
UnavailableException,
TimedOutException,
SchemaDisagreementException,
TException,
CharacterCodingException,
NotFoundException,
org.apache.cassandra.exceptions.InvalidRequestException,
ConfigurationException
{
// get CF meta data
String query = "SELECT type," +
" comparator," +
" subcomparator," +
" default_validator," +
" key_validator," +
" key_aliases " +
"FROM system.schema_columnfamilies " +
"WHERE keyspace_name = '%s' " +
" AND columnfamily_name = '%s' ";
CqlResult result = client.execute_cql3_query(
ByteBufferUtil.bytes(String.format(query, keyspace, column_family)),
Compression.NONE,
ConsistencyLevel.ONE);
if (result == null || result.rows == null || result.rows.isEmpty())
return null;
Iterator<CqlRow> iteraRow = result.rows.iterator();
CfDef cfDef = new CfDef();
cfDef.keyspace = keyspace;
cfDef.name = column_family;
boolean cql3Table = false;
if (iteraRow.hasNext())
{
CqlRow cqlRow = iteraRow.next();
cfDef.column_type = ByteBufferUtil.string(cqlRow.columns.get(0).value);
cfDef.comparator_type = ByteBufferUtil.string(cqlRow.columns.get(1).value);
ByteBuffer subComparator = cqlRow.columns.get(2).value;
if (subComparator != null)
cfDef.subcomparator_type = ByteBufferUtil.string(subComparator);
cfDef.default_validation_class = ByteBufferUtil.string(cqlRow.columns.get(3).value);
cfDef.key_validation_class = ByteBufferUtil.string(cqlRow.columns.get(4).value);
String keyAliases = ByteBufferUtil.string(cqlRow.columns.get(5).value);
List<String> keys = FBUtilities.fromJsonList(keyAliases);
// classis thrift tables
if (keys.size() == 0)
{
CFDefinition cfDefinition = getCfDefinition(keyspace, column_family, client);
for (ColumnIdentifier column : cfDefinition.keys.keySet())
{
String key = column.toString();
String type = cfDefinition.keys.get(column).type.toString();
logger.debug("name: {}, type: {} ", key, type);
keys.add(key);
}
}
else
cql3Table = true;
}
cfDef.column_metadata = getColumnMetadata(client, cql3Table);
return cfDef;
}