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


Java SuperColumn类代码示例

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


SuperColumn类属于org.apache.cassandra.thrift包,在下文中一共展示了SuperColumn类的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: insertPOISpringTraining

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private void insertPOISpringTraining() throws Exception {
	Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
	List<Mutation> columnsToAdd = new ArrayList<Mutation>();

	long timestamp = System.nanoTime();
	String keyName = "Spring Training";
	Column descCol = new Column(bytes("desc"));
	Column phoneCol = new Column(bytes("phone"));

	List<Column> cols = new ArrayList<Column>();
	cols.add(descCol);
	cols.add(phoneCol);

	Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

	Mutation columns = new Mutation();
	ColumnOrSuperColumn descCosc = new ColumnOrSuperColumn();
	SuperColumn sc = new SuperColumn();
	sc.name = bytes(CAMBRIA_NAME);
	sc.columns = cols;

	descCosc.super_column = sc;
	columns.setColumn_or_supercolumn(descCosc);

	columnsToAdd.add(columns);

	String superCFName = "PointOfInterest";
	ColumnPath cp = new ColumnPath();
	cp.column_family = superCFName;
	cp.setSuper_column(CAMBRIA_NAME.getBytes());
	cp.setSuper_columnIsSet(true);

	innerMap.put(superCFName, columnsToAdd);
	outerMap.put(bytes(keyName), innerMap);

	client.batch_mutate(outerMap, CL);

	LOG.debug("Done inserting Spring Training.");
}
 
开发者ID:lhfei,项目名称:hadoop-in-action,代码行数:40,代码来源:Prepopulate.java

示例4: insertPOICentralPark

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private void insertPOICentralPark() throws Exception {

		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnsToAdd = new ArrayList<Mutation>();

		long ts = System.nanoTime();
		String keyName = "Central Park";
		Column descCol = new Column(bytes("desc"));

		// no phone column for park

		List<Column> cols = new ArrayList<Column>();
		cols.add(descCol);

		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn descCosc = new ColumnOrSuperColumn();
		SuperColumn waldorfSC = new SuperColumn();
		waldorfSC.name = bytes(WALDORF_NAME);
		waldorfSC.columns = cols;

		descCosc.super_column = waldorfSC;
		columns.setColumn_or_supercolumn(descCosc);

		columnsToAdd.add(columns);

		String superCFName = "PointOfInterest";
		ColumnPath cp = new ColumnPath();
		cp.column_family = superCFName;
		cp.setSuper_column(WALDORF_NAME.getBytes());
		cp.setSuper_columnIsSet(true);

		innerMap.put(superCFName, columnsToAdd);
		outerMap.put(bytes(keyName), innerMap);

		client.batch_mutate(outerMap, CL);

		LOG.debug("Done inserting Central Park.");
	}
 
开发者ID:lhfei,项目名称:hadoop-in-action,代码行数:41,代码来源:Prepopulate.java

示例5: unthriftifySuper

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private IColumn unthriftifySuper(SuperColumn super_column) {
  org.apache.cassandra.db.SuperColumn sc = new org.apache.cassandra.db.SuperColumn(
      super_column.name, subComparator);
  for (Column column : super_column.columns) {
    sc.addColumn(unthriftifySimple(column));
  }
  return sc;
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:9,代码来源:ColumnFamilyWideRowRecordReader.java

示例6: unthriftifySuperCounter

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private IColumn unthriftifySuperCounter(CounterSuperColumn superColumn) {
  org.apache.cassandra.db.SuperColumn sc = new org.apache.cassandra.db.SuperColumn(
      superColumn.name, subComparator);
  for (CounterColumn column : superColumn.columns) {
    sc.addColumn(unthriftifyCounter(column));
  }
  return sc;
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:9,代码来源:ColumnFamilyWideRowRecordReader.java

示例7: unthriftifySuper

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private IColumn unthriftifySuper(SuperColumn super_column)
{
    org.apache.cassandra.db.SuperColumn sc = new org.apache.cassandra.db.SuperColumn(super_column.name, subComparator);
    for (Column column : super_column.columns)
    {
        sc.addColumn(unthriftifySimple(column));
    }
    return sc;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:10,代码来源:ColumnFamilyRecordReader.java

示例8: unthriftifySuperCounter

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private IColumn unthriftifySuperCounter(CounterSuperColumn superColumn)
{
    org.apache.cassandra.db.SuperColumn sc = new org.apache.cassandra.db.SuperColumn(superColumn.name, subComparator);
    for (CounterColumn column : superColumn.columns)
        sc.addColumn(unthriftifyCounter(column));
    return sc;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:8,代码来源:ColumnFamilyRecordReader.java

示例9: 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

示例10: QueryUserIp

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

示例11: 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

示例12: QueryBookUser

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

示例13: 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

示例14: 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

示例15: insertPOIPhoenixZoo

import org.apache.cassandra.thrift.SuperColumn; //导入依赖的package包/类
private void insertPOIPhoenixZoo() throws Exception {

		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnsToAdd = new ArrayList<Mutation>();

		long ts = System.currentTimeMillis();
		String keyName = "Phoenix Zoo";
		Column descCol = new Column(bytes("desc"));

		Column phoneCol = new Column(bytes("phone"));

		List<Column> cols = new ArrayList<Column>();
		cols.add(descCol);
		cols.add(phoneCol);

		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		String cambriaName = "Cambria Suites Hayden";

		Mutation columns = new Mutation();
		ColumnOrSuperColumn descCosc = new ColumnOrSuperColumn();
		SuperColumn sc = new SuperColumn();
		sc.name = bytes(cambriaName);
		sc.columns = cols;

		descCosc.super_column = sc;
		columns.setColumn_or_supercolumn(descCosc);

		columnsToAdd.add(columns);

		String superCFName = "PointOfInterest";
		ColumnPath cp = new ColumnPath();
		cp.column_family = superCFName;
		cp.setSuper_column(cambriaName.getBytes());
		cp.setSuper_columnIsSet(true);

		innerMap.put(superCFName, columnsToAdd);
		outerMap.put(bytes(keyName), innerMap);

		client.batch_mutate(outerMap, CL);

		LOG.debug("Done inserting Phoenix Zoo.");
	}
 
开发者ID:lhfei,项目名称:hadoop-in-action,代码行数:44,代码来源:Prepopulate.java


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