本文整理汇总了Java中org.apache.cassandra.thrift.CqlRow.getColumns方法的典型用法代码示例。如果您正苦于以下问题:Java CqlRow.getColumns方法的具体用法?Java CqlRow.getColumns怎么用?Java CqlRow.getColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.thrift.CqlRow
的用法示例。
在下文中一共展示了CqlRow.getColumns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getByCql
import org.apache.cassandra.thrift.CqlRow; //导入方法依赖的package包/类
/**
* getByCql
*
* @throws Exception
*/
@Test
public void getByCql() throws Exception {
String KEYSPACE = "mock";
client.set_keyspace(KEYSPACE);
//
String CQL = "select * from student where KEY='Jack'";
// query, compression
CqlResult result = client.execute_cql_query(
ByteBufferHelper.toByteBuffer(CQL), Compression.NONE);
System.out.println(result);
for (CqlRow cqlRow : result.getRows()) {
for (Column column : cqlRow.getColumns()) {
System.out.println(ByteHelper.toString(cqlRow.getKey()) + ", "
+ ByteHelper.toString(column.getName()) + ": "
+ ByteHelper.toString(column.getValue()) + ", "
+ column.getTimestamp());
// Jack, KEY: Jack, -1
// Jack, art: 87, 1380933848350
// Jack, grad: 5, 1380932164492000
// Jack, math: 97, 1380933848305
}
}
}
示例2: convertThriftCqlRow
import org.apache.cassandra.thrift.CqlRow; //导入方法依赖的package包/类
private static Map<String, ByteBuffer> convertThriftCqlRow(CqlRow row)
{
Map<String, ByteBuffer> m = new HashMap<>();
for (org.apache.cassandra.thrift.Column column : row.getColumns())
m.put(UTF8Type.instance.getString(column.bufferForName()), column.value);
return m;
}
示例3: fromThriftCqlRow
import org.apache.cassandra.thrift.CqlRow; //导入方法依赖的package包/类
/**
* Create CFMetaData from thrift {@link CqlRow} that contains columns from schema_columnfamilies.
*
* @param row CqlRow containing columns from schema_columnfamilies.
* @return CFMetaData derived from CqlRow
*/
public static CFMetaData fromThriftCqlRow(CqlRow row)
{
Map<String, ByteBuffer> columns = new HashMap<>();
try
{
for (org.apache.cassandra.thrift.Column column : row.getColumns())
columns.put(ByteBufferUtil.string(column.bufferForName()), column.value);
}
catch (CharacterCodingException ignore)
{
}
UntypedResultSet.Row cql3row = new UntypedResultSet.Row(columns);
return fromSchemaNoColumnsNoTriggers(cql3row);
}
示例4: printRows
import org.apache.cassandra.thrift.CqlRow; //导入方法依赖的package包/类
private void printRows(CqlResult result) {
for (CqlRow row : result.getRows()) {
getLog().info("Row key: " + keyValidatorVal.getString(row.key));
getLog().info("-----------------------------------------------");
for (Column column : row.getColumns()) {
getLog().info(" name: " + comparatorVal.getString(column.name));
getLog().info(" value: " + defaultValidatorVal.getString(column.value));
getLog().info("-----------------------------------------------");
}
}
}
示例5: cassandraRowToKettle
import org.apache.cassandra.thrift.CqlRow; //导入方法依赖的package包/类
/**
* Converts a cassandra row to a Kettle row
*
* @param metaData meta data on the cassandra column family being read from
* @param cassandraRow a row from the column family
* @param outputFormatMap a Map of output field names to indexes in the
* outgoing Kettle row structure
* @return a Kettle row
* @throws KettleException if a problem occurs
*/
public Object[] cassandraRowToKettle(CassandraColumnMetaData metaData,
CqlRow cassandraRow, Map<String, Integer> outputFormatMap)
throws KettleException {
Object[] outputRowData = RowDataUtil
.allocateRowData(m_outputRowMeta.size());
Object key = metaData.getKeyValue(cassandraRow);
if (key == null) {
throw new KettleException("Unable to obtain a key value for the row!");
}
String keyName = metaData.getKeyName();
int keyIndex = m_outputRowMeta.indexOfValue(keyName);
if (keyIndex < 0) {
throw new KettleException("Unable to find the key field name '" + keyName
+ "' in the output row meta data!");
}
outputRowData[keyIndex] = key;
// do the columns
List<Column> rowColumns = cassandraRow.getColumns();
for (Column aCol : rowColumns) {
String colName = metaData.getColumnName(aCol);
Integer outputIndex = outputFormatMap.get(colName);
if (outputIndex != null) {
Object colValue = metaData.getColumnValue(aCol);
outputRowData[outputIndex.intValue()] = colValue;
}
}
return outputRowData;
}