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


Java ColumnOrSuperColumn.getSuper_column方法代码示例

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


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

示例1: QueryOneMinute

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的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.ColumnOrSuperColumn; //导入方法依赖的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.ColumnOrSuperColumn; //导入方法依赖的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: QueryUserIp

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check item is exist or not
 * 
 * return times of item
 */
public int QueryUserIp(String ip, String name){
	String NAME_KEY = name;
	String IP_SUPER_KEY = ip;
	String COLUMN_NAME = "times";
	String COLUMN_FAMILY = "UserIp";
	
	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(NAME_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,代码行数:35,代码来源:CassandraQuery.java

示例5: QueryBookIp

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的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

示例6: QueryBookUser

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的package包/类
/**
 * Query and Check BookUser
 * 
 * return times of column is exist, 0 or not
 */
public int QueryBookUser(String bookid, String user) {
	String BOOKID_KEY = bookid;
	String USER_SUPER_KEY = user;
	String COLUMN_NAME = "times";
	String COLUMN_FAMILY = "BookUser";
	
	try{
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.super_column = this.cassandraUtil.toByteBuffer(USER_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,代码行数:36,代码来源:CassandraQuery.java

示例7: QueryIpBookPage

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的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

示例8: QueryUserBookPage

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的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

示例9: superQuery

import org.apache.cassandra.thrift.ColumnOrSuperColumn; //导入方法依赖的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


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