本文整理汇总了Java中org.apache.cassandra.thrift.Column.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Column.getValue方法的具体用法?Java Column.getValue怎么用?Java Column.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.thrift.Column
的用法示例。
在下文中一共展示了Column.getValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QueryOneMinute
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public List<String> QueryOneMinute(String min) {
List<String> userList = new ArrayList<String>();
try {
List<ColumnOrSuperColumn> results = client.get_slice(Utils
.toByteBuffer(min), columnParent, predicate,
ConsistencyLevel.ONE);
for (ColumnOrSuperColumn cc : results) {
SuperColumn superColumn = cc.getSuper_column();
List<Column> list = superColumn.getColumns();
for (Column c : list) {
String columnName = new String(c.getName(), "UTF-8");
if (columnName.equals("username")) {
String value = new String(c.getValue(), "UTF-8");
if (!userList.contains(value)) {
userList.add(value);
}
}
}
}
} catch (Exception e) {
System.out.println(e);
}
return userList;
}
示例2: QueryOneMinute
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public List<String> QueryOneMinute(String min){
List<String> bookList = new ArrayList<String>();
try {
List<ColumnOrSuperColumn> results = client.get_slice(Utils
.toByteBuffer(min), columnParent, predicate,
ConsistencyLevel.ONE);
for (ColumnOrSuperColumn cc : results) {
SuperColumn superColumn = cc.getSuper_column();
List<Column> list = superColumn.getColumns();
for (Column c : list) {
String columnName = new String(c.getName(), "UTF-8");
if (columnName.equals("bookno")) {
String value = new String(c.getValue(), "UTF-8");
if (!bookList.contains(value)) {
bookList.add(value);
}
}
}
}
} catch (Exception e) {
System.out.println(e);
}
return bookList;
}
示例3: convertKeySliceList
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private List<Map<String,Object>> convertKeySliceList(List<KeySlice> keySliceList, String primaryKeyName) {
List<Map<String,Object>> rowList = new ArrayList<Map<String,Object>>();
try {
for (KeySlice keySlice: keySliceList) {
List<ColumnOrSuperColumn> columnList = keySlice.getColumns();
if (!columnList.isEmpty()) {
byte[] keyBytes = keySlice.getKey();
String key = new String(keyBytes, "UTF-8");
Map<String,Object> columnMap = new HashMap<String,Object>();
columnMap.put(primaryKeyName, key);
for (ColumnOrSuperColumn columnOrSuperColumn: columnList) {
Column column = columnOrSuperColumn.getColumn();
byte[] columnNameBytes = column.getName();
String columnName = new String(columnNameBytes, "UTF-8");
byte[] valueBytes = column.getValue();
String value = new String(valueBytes, "UTF-8");
if (value.equals(NULL_VALUE_STRING))
value = null;
columnMap.put(columnName, value);
}
rowList.add(columnMap);
}
}
return rowList;
}
catch (UnsupportedEncodingException exc) {
throw new StorageException("Character encoding exception with key range", exc);
}
}
示例4: getColumnValue
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* Decode the supplied column value. Uses the default validation class to
* decode the value if the column is not explicitly defined in the schema.
*
* @param aCol
* @return
* @throws KettleException
*/
public Object getColumnValue(Column aCol) throws KettleException {
String colName = getColumnName(aCol);
// Clients should use getKey() for getting the key
if (colName.equals("KEY")) {
return null;
}
String decoder = m_columnMeta.get(colName);
if (decoder == null) {
// column is not in schema so use default validator
decoder = m_defaultValidationClass;
}
String fullDecoder = decoder;
if (decoder.indexOf('(') > 0) {
decoder = decoder.substring(0, decoder.indexOf('('));
}
if (decoder.indexOf("BytesType") > 0) {
return aCol.getValue(); // raw bytes
}
ByteBuffer valueBuff = aCol.bufferForValue();
Object result = getColumnValue(valueBuff, fullDecoder);
// check for indexed values
if (m_indexedVals.containsKey(colName)) {
HashSet<Object> vals = m_indexedVals.get(colName);
// look for the correct index
int foundIndex = -1;
Object[] indexedV = vals.toArray();
for (int i = 0; i < indexedV.length; i++) {
if (indexedV[i].equals(result)) {
foundIndex = i;
break;
}
}
if (foundIndex >= 0) {
result = new Integer(foundIndex);
} else {
result = null; // any values that are not indexed are unknown...
}
}
return result;
}
示例5: QueryFromBCPRelation
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* To query from 'BCPRelation'
* @param bookChapterList
*/
public void QueryFromBCPRelation (List<List<String>> bookChapterList){
SlicePredicate predicate = new SlicePredicate();
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "BCPRelation";
try{
for (int i = 0; i < bookChapterList.size(); ++i) {
List<String> innerResult = new ArrayList<String>();
List<String> innerList = bookChapterList.get(i);
// Deal with a single book info list
String bookId = innerList.get(0);
List<String> chapterList = innerList.subList(1, innerList.size());
innerResult.add(bookId);
// Query from cassandra
List<ColumnOrSuperColumn> results = client.get_slice(this.cassandraUtil.toByteBuffer(bookId), parent, predicate,ConsistencyLevel.ONE);
// Iterator SuperColumn List
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
// Get detail information of a single chapter
String chapterLevel = "";
String chapterTitle = "";
for (Column column : columns2) {
String columnName = new String(column.getName(), "UTF-8");
if (columnName.equalsIgnoreCase("ChapterLevel")) {
chapterLevel = new String(column.getValue(), "UTF-8");
} else if (columnName.equalsIgnoreCase("ChapterLabel")) {
chapterTitle = new String(column.getValue(), "UTF-8");
}
}
// Iterator chapterList insert into map
for(int j = 0; j < chapterList.size(); ++j){
if(chapterLevel.equals(chapterList.get(j))) {
innerResult.add(chapterTitle);
}
}
}
this.finalResult.add(innerResult);
}
}catch(Exception e) {
LOG.warn("Error when dealing bookChapterList");
e.printStackTrace();
}
}
示例6: QueryRecordMinute
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* Query from cf [RecordMinute]
* @param queryWord
* @return
*/
public Map<String, Integer> QueryRecordMinute(String queryWord) {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.114", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
Map<String, Integer> ipCountHash = new HashMap<String, Integer>();
try {
tr.open();
client.set_keyspace("CadalSecTest");
// read entire row
SlicePredicate predicate = new SlicePredicate();// new SliceRange(new byte[0], new byte[0], false, 10)
SliceRange range = new SliceRange();
range.start = Utils.toByteBuffer("");
range.finish = Utils.toByteBuffer("");
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "RecordMinute";
List<ColumnOrSuperColumn> results = client.get_slice(Utils.toByteBuffer(queryWord), parent, predicate, ConsistencyLevel.ONE);
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
for (Column column : columns2) {
if((new String(column.getName(), "UTF-8")).equals("ip")) {
String ip = new String(column.getValue(), "UTF-8");
if(ipCountHash.containsKey(ip)) {
ipCountHash.put(ip, ipCountHash.get(ip) + 1);
}else{
ipCountHash.put(ip, 1);
}
}else{
continue;
}
}
}
tr.close();
return ipCountHash;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例7: QueryRecordTimeSlide
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* Query from cf [RecordMinute]
* @param queryTimeStart
* @param queryTimeEnd
* @return
*/
public Map<String, Integer> QueryRecordTimeSlide(String queryTimeStart, String queryTimeEnd) {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.114", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
Date dateQuery = this.timeOp.getFormatDate(queryTimeStart);
Date dateEnd = this.timeOp.getFormatDate(queryTimeEnd);
Map<String, Integer> ipCountHash = new HashMap<String, Integer>();
try {
tr.open();
client.set_keyspace("CadalSecTest");
// read entire row
SlicePredicate predicate = new SlicePredicate();// new SliceRange(new byte[0], new byte[0], false, 10)
SliceRange range = new SliceRange();
range.start = Utils.toByteBuffer("");
range.finish = Utils.toByteBuffer("");
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "RecordMinute";
String queryWord = this.timeOp.getFormatDate(dateQuery);
while(dateQuery.before(dateEnd)) {
List<ColumnOrSuperColumn> results = client.get_slice(Utils.toByteBuffer(queryWord), parent, predicate, ConsistencyLevel.ONE);
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
for (Column column : columns2) {
if((new String(column.getName(), "UTF-8")).equals("ip")) {
String ip = new String(column.getValue(), "UTF-8");
if(ipCountHash.containsKey(ip)) {
ipCountHash.put(ip, ipCountHash.get(ip) + 1);
}else{
ipCountHash.put(ip, 1);
}
}else{
continue;
}
}
}
dateQuery = this.timeOp.getFormatDate(this.timeOp.getPreDate(dateQuery, "m", 1));
queryWord = this.timeOp.getFormatDate(dateQuery);
}
tr.close();
return ipCountHash;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例8: QueryRecordMinute
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public void QueryRecordMinute(String queryWord) {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.111", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
try {
tr.open();
client.set_keyspace("CadalSecTest");
// read entire row
//System.out.println("------------Entire---------------");
SlicePredicate predicate = new SlicePredicate();//null, new SliceRange(new byte[0], new byte[0], false, 10)
SliceRange range = new SliceRange();
range.start = toByteBuffer("");
range.finish = toByteBuffer("");
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "RecordMinute";
String username = "";
String bookno = "";
List<ColumnOrSuperColumn> results = client.get_slice(toByteBuffer(queryWord), parent, predicate, ConsistencyLevel.ONE);
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
// To get map<username, list[bookno]>
for (Column column : columns2) {
//System.out.println(new String(column.getName(), "UTF-8") + " -> "+ new String(column.getValue(), "UTF-8"));
String columnName = new String(column.getName(), "UTF-8");
if(columnName.equals("username")) {
username = new String(column.getValue(), "UTF-8");
}else if(columnName.equals("bookno")) {
bookno = new String(column.getValue(), "UTF-8");
}
}
if(this.MapUserBook.containsKey(username)) {
if(!this.MapUserBook.get(username).contains(bookno)) {
this.MapUserBook.get(username).add(bookno);
}
}else{
ArrayList<String> bookList = new ArrayList<String>();
bookList.add(bookno);
this.MapUserBook.put(username, bookList);
}
//System.out.println("-------------------------------------------------");
}
tr.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: GetChapterLevel
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* This function is used to deal many pages of a book, to find all chapter_level info of pages.
* @param bookNo like: 07018720
* @param pageNoList just like: <<23>, <45>, <2>>
* @return List of book_page:<<07018720_1.1.0.0.0>, <07018720_2.0.0.0.0>, <07018720_1.2.0.0.0>>
*/
@SuppressWarnings("unchecked")
public List<String> GetChapterLevel(String bookNo, List<Integer> pageNoList){
SlicePredicate predicate = new SlicePredicate();
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "BCPRelation";
Map<String, String> tmpMap = new HashMap<String, String>();
List<String> returnStrList = new ArrayList<String>();
try {
List<ColumnOrSuperColumn> results = client.get_slice(this.cassandraUtil.toByteBuffer(bookNo), parent, predicate,ConsistencyLevel.ONE);
// Iterator SuperColumn List
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
// Get detail information of a single chapter
int startPage = 0;
int endPage = 0;
String chapterLevel = "";
for (Column column : columns2) {
String columnName = new String(column.getName(), "UTF-8");
if (columnName.equalsIgnoreCase("ChapterLevel")) {
chapterLevel = new String(column.getValue(), "UTF-8");
} else if (columnName.equalsIgnoreCase("StartPage")) {
startPage = Integer.valueOf(new String(column.getValue(), "UTF-8")).intValue();
} else if (columnName.equalsIgnoreCase("EndPage")) {
endPage = Integer.valueOf(new String(column.getValue(), "UTF-8")).intValue();
}
}
// Iterator PageNoList insert into map
for(int j = 0; j < pageNoList.size(); ++j){
if(MatchRange(pageNoList.get(j), startPage, endPage)) {
tmpMap.put(bookNo + "_" + chapterLevel, "");
}
}
}
// Convert Map to List
Iterator iter = tmpMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry)iter.next();
Object key = entry.getKey();
returnStrList.add(key.toString());
}
return returnStrList;
} catch (Exception e) {
e.printStackTrace();
}
return returnStrList;
}
示例10: QueryFromBCPRelation
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* To query from 'BCPRelation'
* @param bookChapterList
* @return
*/
@SuppressWarnings("unchecked")
public List<String> QueryFromBCPRelation (List<String> bookChapterList){
List<String> chapterList = new ArrayList<String>();
SlicePredicate predicate = new SlicePredicate();
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "BCPRelation";
try{
Map<String, List<String>> mapBookChapter = this.Preprocess(bookChapterList);
for (Iterator iter = mapBookChapter.keySet().iterator(); iter.hasNext();) {
Object key = iter.next();
Object val = mapBookChapter.get(key);
List<ColumnOrSuperColumn> results = client.get_slice(this.cassandraUtil.toByteBuffer(key.toString()), parent, predicate,ConsistencyLevel.ONE);
// Iterator SuperColumn List
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
// Get detail information of a single chapter
String chapterLevel = "";
String chapterTitle = "";
for (Column column : columns2) {
String columnName = new String(column.getName(), "UTF-8");
if (columnName.equalsIgnoreCase("ChapterLevel")) {
chapterLevel = new String(column.getValue(), "UTF-8");
} else if (columnName.equalsIgnoreCase("ChapterLabel")) {
chapterTitle = new String(column.getValue(), "UTF-8");
}
}
// Iterator PageNoList insert into map
List<String> listStr = (List<String>) val;
for(int j = 0; j < listStr.size(); ++j){
if(chapterLevel.equals(listStr.get(j))) {
chapterList.add(chapterTitle);
}
}
}
}
return chapterList;
}catch(Exception e) {
LOG.warn("Error when dealing bookChapterList");
e.printStackTrace();
}
return chapterList;
}
示例11: QueryRecordMinuteTwo
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
* Query from cf [RecordMinute]
* to GetCassandraInfo function
* @param queryWord
*/
public void QueryRecordMinuteTwo(String queryWord, FileWriter writer) {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.118", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
try {
tr.open();
client.set_keyspace("CadalSecTest");
// read entire row
SlicePredicate predicate = new SlicePredicate();//null, new SliceRange(new byte[0], new byte[0], false, 10)
SliceRange range = new SliceRange();
range.start = toByteBuffer("");
range.finish = toByteBuffer("");
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "RecordMinute";
List<ColumnOrSuperColumn> results = client.get_slice(toByteBuffer(queryWord), parent, predicate, ConsistencyLevel.ONE);
String strTmp = "";
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
List<Column> columns2 = superColumn2.getColumns();
for (Column column : columns2) {
if(new String(column.getName(), "UTF-8").equals("username") && new String(column.getValue(), "UTF-8").equals("None")) {
strTmp = "";
break;
}
strTmp += new String(column.getValue(), "UTF-8");
strTmp += "####";
}
if(strTmp.length() < 1) {
continue;
}
writer.write(strTmp);
writer.write("\n");
strTmp = "";
}
tr.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: getChapterInfo
import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public void getChapterInfo() {
SlicePredicate predicate = new SlicePredicate();// null, new
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
predicate.setSlice_range(range);
ColumnParent parent = new ColumnParent();
parent.column_family = "BCPRelation";
try {
List<ColumnOrSuperColumn> results = client.get_slice(toByteBuffer(bookNo), parent, predicate,ConsistencyLevel.ONE);
for (ColumnOrSuperColumn result : results) {
SuperColumn superColumn2 = result.super_column;
System.out.println(new String(superColumn2.getName(), "UTF-8"));
List<Column> columns2 = superColumn2.getColumns();
String chapterName = null;
int startPage = 0;
int endPage = 0;
String chapterLevel = "";
for (Column column : columns2) {
String columnName = new String(column.getName(), "UTF-8");
if (columnName.equalsIgnoreCase("ChapterLevel")) {
chapterLevel = new String(column.getValue(), "UTF-8");
} else if (columnName.equalsIgnoreCase("StartPage")) {
startPage = Integer.parseInt(new String(column.getValue(), "UTF-8"));
} else if (columnName.equalsIgnoreCase("EndPage")) {
endPage = Integer.parseInt(new String(column.getValue(), "UTF-8"));
} else if (columnName.equalsIgnoreCase("ChapterLabel")) {
chapterName = new String(column.getValue(), "UTF-8");
}
}
if (MatchRange(pageNo, startPage, endPage)) {
System.out.println("BookNo:" + bookNo + " PageNo:" + pageNo + " in[" + chapterName + "]:"
+ " StartPage:" + startPage + " EndPage:" + endPage);
System.out.println(chapterLevel);
}
}
} catch (Exception e) {
e.printStackTrace();
}
// tr.close();
}