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


Java SuperColumn.getColumns方法代码示例

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


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

示例1: QueryOneMinute

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:25,代码来源:CasTimeReader.java

示例2: QueryOneMinute

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:25,代码来源:CasTimeBook.java

示例3: QueryIpUser

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check item is exist or not
 * 
 * return times of item
 */
public int QueryIpUser(String ip, String name){
	String IP_KEY = ip;
	String NAME_SUPER_KEY = name;
	String COLUMN_NAME = "times";
	String COLUMN_FAMILY = "IpUser";
	
	try{
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.super_column = this.cassandraUtil.toByteBuffer(NAME_SUPER_KEY);
		
		ColumnOrSuperColumn columnOrSuperColumn = client.get(this.cassandraUtil.toByteBuffer(IP_KEY), columnPath, ConsistencyLevel.ONE);

		SuperColumn superColumn = columnOrSuperColumn.getSuper_column();
		
		List<Column> columns = superColumn.getColumns();
		
		for(Column col : columns) {
			String title = new String(col.getName(), "UTF-8") ;
			
			if(title.equals(COLUMN_NAME)){
				return Integer.parseInt(new String(col.getValue(), "UTF-8"));     // get "times" column and return 
			}
		}
	}catch(Exception e){
		return 0;
	}

	return 0;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:36,代码来源:CassandraQuery.java

示例4: QueryBookIp

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check BookIp
 * 
 * return times of column is exist, 0 or not
 */
public int QueryBookIp(String bookid, String ip) {
	String BOOKID_KEY = bookid;
	String IP_SUPER_KEY = ip;
	String COLUMN_NAME = "times";
	String COLUMN_FAMILY = "BookIp";

	try {
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.super_column = this.cassandraUtil.toByteBuffer(IP_SUPER_KEY);

		ColumnOrSuperColumn columnOrSuperColumn = client.get(this.cassandraUtil.toByteBuffer(BOOKID_KEY), columnPath,ConsistencyLevel.ONE);

		SuperColumn superColumn = columnOrSuperColumn.getSuper_column();

		List<Column> columns = superColumn.getColumns();


		for (Column col : columns) {
			String title = new String(col.getName(), "UTF-8");
			if (title.equals(COLUMN_NAME)) {
				return Integer.parseInt(new String(col.getValue(), "UTF-8"));
			}
		}

	} catch (Exception e) {
		return 0;
	}

	return 0;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:37,代码来源:CassandraQuery.java

示例5: QueryIpBookPage

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check IpBookPage
 * 
 * return times of column is exist, 0 or not
 */
public int QueryIpBookPage(String ip, String book) {
	String IP_KEY = ip;
	String BOOKID_SUPER_KEY = book;
	String COLUMN_FAMILY = "IpBookPage";
	String COLUMN_NAME = "times";
	
	try{
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.super_column = this.cassandraUtil.toByteBuffer(BOOKID_SUPER_KEY);
		
		ColumnOrSuperColumn columnOrSuperColumn = client.get(this.cassandraUtil.toByteBuffer(IP_KEY), columnPath, ConsistencyLevel.ONE);
		
		SuperColumn superColumn = columnOrSuperColumn.getSuper_column();
		
		List<Column> columns = superColumn.getColumns();
		
		for(Column col : columns) {
			String title = new String(col.getName(), "UTF-8");
			if(title.equals(COLUMN_NAME)) {
				return Integer.parseInt(new String(col.getValue(), "UTF-8"));
			}
		}
		
	}catch(Exception e){
		return 0;
	}
	
	return 0;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:36,代码来源:CassandraQuery.java

示例6: QueryUserBookPage

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check UserBookPage
 * 
 * return times of column is exist, 0 or not
 */
public int QueryUserBookPage(String user, String book) {
	String USER_KEY = user;
	String BOOK_SUPER_KEY = book;
	String COLUMN_FAMILY = "UserBookPage";
	String COLUMN_NAME = "times";
	
	try{
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.super_column = this.cassandraUtil.toByteBuffer(BOOK_SUPER_KEY);
		
		ColumnOrSuperColumn columnOrSuperColumn = client.get(this.cassandraUtil.toByteBuffer(USER_KEY), columnPath, ConsistencyLevel.ONE);
		
		SuperColumn superColumn = columnOrSuperColumn.getSuper_column();
		
		List<Column> columns = superColumn.getColumns();
		
		for(Column col : columns) {
			String title = new String(col.getName(), "UTF-8");
			if(title.equals(COLUMN_NAME)) {
				return Integer.parseInt(new String(col.getValue(), "UTF-8"));
			}
		}
		
	}catch(Exception e) {
		return 0;
	}
	
	return 0;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:36,代码来源:CassandraQuery.java

示例7: QueryRecordMinute

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
	 * Query from cf [RecordMinute]
	 * @param queryWord
	 */
	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");
//			client.set_keyspace("CadalSec");
			
			// read single column
//			System.out.println("------------Single---------------");
//			ColumnPath columnPath = new ColumnPath();
//			columnPath.column_family = "RecordMinute";
//			columnPath.super_column = toByteBuffer("e140d64d-cc0f-423b-8ccc-312ed508f563");
//			
//			ColumnOrSuperColumn columnOrSuperColumn = client.get(toByteBuffer(queryWord), columnPath, ConsistencyLevel.ONE);
//
//			SuperColumn superColumn = columnOrSuperColumn.getSuper_column();
//			
//			List<Column> columns = superColumn.getColumns();
//			
//			for(Column col : columns) {
//				System.out.println(new String(col.getName(), "UTF-8") + " --> " + new String(col.getValue(), "UTF-8"));
//			}
			
			// 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";
			
			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();
				
				System.out.println(new String(superColumn2.getName(), "UTF-8"));
				
				for (Column column : columns2) {
					System.out.println(new String(column.getName(), "UTF-8") + " -> "+ new String(column.getValue(), "UTF-8"));
				}
				System.out.println("----------------------------------------");
			}
			
			tr.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:61,代码来源:CassandraOp.java

示例8: QueryFromBCPRelation

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:67,代码来源:QueryBCPRelation.java

示例9: superQuery

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * Super-Column Query
 */
public void superQuery() {
	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("Keyspace2");
		
		// read single column
		System.out.println("------------Single---------------");
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = "Super";
		columnPath.super_column = toByteBuffer("100900");
		
		ColumnOrSuperColumn columnOrSuperColumn = client.get(toByteBuffer("Yanfei"), columnPath, ConsistencyLevel.ONE);

		SuperColumn superColumn = columnOrSuperColumn.getSuper_column();
		
		List<Column> columns = superColumn.getColumns();
		
		for(Column col : columns) {
			System.out.println(new String(col.getName(), "UTF-8") + " --> " + new String(col.getValue(), "UTF-8"));
		}
		
		// 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("100100");
		range.finish = toByteBuffer("100300");
		predicate.setSlice_range(range);
		
		ColumnParent parent = new ColumnParent();
		parent.column_family = "Super";
		
		List<ColumnOrSuperColumn> results = client.get_slice(toByteBuffer("Yanfei"), parent, predicate, ConsistencyLevel.ONE);
		for (ColumnOrSuperColumn result : results) {
			SuperColumn superColumn2 = result.super_column;
			
			List<Column> columns2 = superColumn2.getColumns();
			
			System.out.println(new String(superColumn2.getName(), "UTF-8"));
			
			for (Column column : columns2) {
				System.out.println(new String(column.getName(), "UTF-8") + " -> "+ new String(column.getValue(), "UTF-8"));
			}
		}
		
		tr.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:58,代码来源:TestSuper.java

示例10: QueryRecordMinuteTwo

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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();
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:54,代码来源:CassandraOp.java

示例11: QueryRecordMinute

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:53,代码来源:CasSchoolPV.java

示例12: QueryRecordTimeSlide

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:65,代码来源:CasSchoolPV.java

示例13: QueryRecordMinute

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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();
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:59,代码来源:CassandraOp.java

示例14: GetChapterLevel

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的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;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:75,代码来源:ChapterLevel.java

示例15: GetAllInfoOfUser

import org.apache.cassandra.thrift.SuperColumn; //导入方法依赖的package包/类
/**
 * To get all book-page information about an allocated 'username'
 * @param String username: like 'zju' 'Yanfei'
 */
public Map<String, List<String>> GetAllInfoOfUser(String username) {
	
	Map<String, List<String>> infoMap = new HashMap<String, List<String>>();
	
	SlicePredicate predicate = new SlicePredicate();// null, new
	SliceRange range = new SliceRange();
	
	range.setStart(new byte[0]);
	range.setFinish(new byte[0]); 
	range.setCount(200000);
	
	predicate.setSlice_range(range);

	ColumnParent parent = new ColumnParent();
	parent.column_family = "UserBookPage";

	String bookid;
	List<String> listPage = null;
	
	try {
		List<ColumnOrSuperColumn> results = client.get_slice(this.cassandraUtil.toByteBuffer(username), parent, predicate, ConsistencyLevel.ONE);
		
		for (ColumnOrSuperColumn result : results) {
			listPage = new ArrayList<String>();
			
			SuperColumn superColumn2 = result.super_column;
			
			bookid = "";
			bookid = new String(superColumn2.getName(), "UTF-8");           // bookid
			
			List<Column> columns2 = superColumn2.getColumns();
			
			for (Column column : columns2) {
				String columnName = new String(column.getName(), "UTF-8");
				
				if(columnName.equalsIgnoreCase("times")){
					continue;
				}else{
					listPage.add(new String(column.getName(), "UTF-8"));     // page-number
				}
			}
			
			infoMap.put(bookid, listPage);
		}
		
		return infoMap;
	} catch (Exception e) {
		 e.printStackTrace();
		 return infoMap;
	}

}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:57,代码来源:UserBookPageInfo.java


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