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


Java ColumnPath.setSuper_columnIsSet方法代码示例

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


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

示例1: insertPOISpringTraining

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

示例2: insertPOICentralPark

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

示例3: insertPOIPhoenixZoo

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

示例4: insertPOIEmpireState

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
private void insertPOIEmpireState() 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 esbName = "Empire State Building";
		Column descCol = new Column(bytes("desc"));
		Column phoneCol = new Column(bytes("phone"));

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

		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 = esbCols;

		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(esbName), innerMap);

		client.batch_mutate(outerMap, CL);

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

示例5: InsertIpUser

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into IpUser Column Family
 */
public boolean InsertIpUser(String ip, String name, String time, int times) {
	System.out.println("------------InsertIpUser--------------");
	String IP_KEY = ip;
	String NAME_SUPER_KEY = name;
	String TIMES = String.valueOf(times);
	String LAST = this.tc.NormalTime(time);
	
	String COLUMN_NAME_TIMES = "times";
	String COLUMN_NAME_LAST  = "last";
	
	String COLUMN_FAMILY_NAME = "IpUser";
	
	try {
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();

		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_TIMES));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnLast = new Column();
		idColumnLast.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_LAST));
		idColumnLast.setValue(this.cassandraUtil.toByteBuffer(LAST));
		idColumnLast.setTimestamp(timeStamp);

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

		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(NAME_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);

		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY_NAME;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(NAME_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY_NAME, columnToAdd);

		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(IP_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.ONE);
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:70,代码来源:CassandraInsert.java

示例6: InsertUserIp

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into UserIp Column Family
 */
public boolean InsertUserIp(String ip, String name, String time, int times) {
	System.out.println("------------InsertUserIp--------------");
	String NAME_KEY = name;
	String IP_SUPER_KEY = ip;
	String TIMES = String.valueOf(times);
	String LAST = this.tc.NormalTime(time);
	
	String COLUMN_NAME_TIMES = "times";
	String COLUMN_NAME_LAST  = "last";
	
	String COLUMN_FAMILY_NAME = "UserIp";
	
	try {
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();

		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_TIMES));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnLast = new Column();
		idColumnLast.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_LAST));
		idColumnLast.setValue(this.cassandraUtil.toByteBuffer(LAST));
		idColumnLast.setTimestamp(timeStamp);

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

		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(IP_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);

		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY_NAME;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(IP_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY_NAME, columnToAdd);

		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(NAME_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:70,代码来源:CassandraInsert.java

示例7: InsertIntoBookIp

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into BookIp CF
 */
public boolean InsertIntoBookIp(String ip, String bookid, String last, int times) {
	System.out.println("------------InsertIntoBookIp--------------");
	String BOOKID_KEY = bookid;
	String IP_SUPER_KEY = ip;
	String TIMES = String.valueOf(times);
	String LAST = this.tc.NormalTime(last);
	
	String COLUMN_NAME_TIMES = "times";
	String COLUMN_NAME_LAST  = "last";
	
	String COLUMN_FAMILY_NAME = "BookIp";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();

		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_TIMES));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnLast = new Column();
		idColumnLast.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_LAST));
		idColumnLast.setValue(this.cassandraUtil.toByteBuffer(LAST));
		idColumnLast.setTimestamp(timeStamp);

		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnTimes);
		cols.add(idColumnLast);
		
		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(IP_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);

		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY_NAME;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(IP_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY_NAME, columnToAdd);

		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(BOOKID_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:70,代码来源:CassandraInsert.java

示例8: InsertIntoBookUser

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into BookUser CF
 */
public boolean InsertIntoBookUser(String user, String bookid, String last, int times){
	System.out.println("------------InsertIntoBookUser--------------");
	String BOOKID_KEY = bookid;
	String USER_SUPER_KEY = user;
	String TIMES = String.valueOf(times);
	String LAST = this.tc.NormalTime(last);
	
	String COLUMN_NAME_TIMES = "times";
	String COLUMN_NAME_LAST  = "last";
	
	String COLUMN_FAMILY_NAME = "BookUser";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();

		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_TIMES));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnLast = new Column();
		idColumnLast.setName(this.cassandraUtil.toByteBuffer(COLUMN_NAME_LAST));
		idColumnLast.setValue(this.cassandraUtil.toByteBuffer(LAST));
		idColumnLast.setTimestamp(timeStamp);

		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnTimes);
		cols.add(idColumnLast);
		
		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(USER_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);

		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY_NAME;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(USER_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY_NAME, columnToAdd);

		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(BOOKID_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}	
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:70,代码来源:CassandraInsert.java

示例9: InsertIntoIpBookPage

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into IpBookPage CF
 */
public boolean InsertIntoIpBookPage(String ip, String book, String page, int times, String time) {
	System.out.println("------------InsertIntoIpBookPage--------------");
	String IP_KEY = ip;
	String BOOK_SUPER_KEY = book;
	
	String PAGE_TITLE = page;
	String PAGE_VALUE = this.tc.NormalTime(time);
	
	String TIMES_TITLE = "times";
	String TIMES_VALUE = String.valueOf(times);
	
	String COLUMN_FAMILY = "IpBookPage";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();
		
		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(TIMES_TITLE));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES_VALUE));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnPage = new Column();
		idColumnPage.setName(this.cassandraUtil.toByteBuffer(PAGE_TITLE));
		idColumnPage.setValue(this.cassandraUtil.toByteBuffer(PAGE_VALUE));
		idColumnPage.setTimestamp(timeStamp);

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

		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(BOOK_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);
		
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(BOOK_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY, columnToAdd);
		
		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(IP_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.ONE);

		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:71,代码来源:CassandraInsert.java

示例10: InsertIntoUserBookPage

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into UserBookPage CF
 */
public boolean InsertIntoUserBookPage(String user, String book, String page, int times, String time) {
	System.out.println("------------InsertIntoUserBookPage--------------");
	String USER_KEY = user;
	String BOOK_SUPER_KEY = book;
	
	String PAGE_TITLE = page;
	String PAGE_VALUE = this.tc.NormalTime(time);
	
	String TIMES_TITLE = "times";
	String TIMES_VALUE = String.valueOf(times);
	
	String COLUMN_FAMILY = "UserBookPage";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();
		
		// Construct Column
		Column idColumnTimes = new Column();
		idColumnTimes.setName(this.cassandraUtil.toByteBuffer(TIMES_TITLE));
		idColumnTimes.setValue(this.cassandraUtil.toByteBuffer(TIMES_VALUE));
		idColumnTimes.setTimestamp(timeStamp);

		Column idColumnPage = new Column();
		idColumnPage.setName(this.cassandraUtil.toByteBuffer(PAGE_TITLE));
		idColumnPage.setValue(this.cassandraUtil.toByteBuffer(PAGE_VALUE));
		idColumnPage.setTimestamp(timeStamp);

		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnTimes);
		cols.add(idColumnPage);
		
		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(BOOK_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);
		
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(BOOK_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY, columnToAdd);
		
		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(USER_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);
	
		return true;
	}catch(Exception e) {
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:71,代码来源:CassandraInsert.java

示例11: InsertIpQueryBook

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into IpQueryBook CF
 */
public boolean InsertIpQueryBook(String ip, String superUuid, String query,String book, String time) {
	System.out.println("------------InsertIpQueryBook--------------");
	String IP_KEY = ip;
	String UUID_SUPER_KEY = superUuid;
	
	String QUERY_TITLE = "query";
	String QUERY_VALUE = query;
	
	String BOOK_TITLE = book;
	String BOOK_VALUE = time;
	
	String COLUMN_FAMILY = "IpQueryBook";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();
		
		// Construct Column
		Column idColumnQuery = new Column();
		idColumnQuery.setName(this.cassandraUtil.toByteBuffer(QUERY_TITLE));
		idColumnQuery.setValue(this.cassandraUtil.toByteBuffer(QUERY_VALUE));
		idColumnQuery.setTimestamp(timeStamp);
		
		Column idColumnBook = new Column();
		idColumnBook.setName(this.cassandraUtil.toByteBuffer(BOOK_TITLE));
		idColumnBook.setValue(this.cassandraUtil.toByteBuffer(BOOK_VALUE));
		idColumnBook.setTimestamp(timeStamp);
		
		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnQuery);
		cols.add(idColumnBook);
		
		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(UUID_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);
		
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(UUID_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY, columnToAdd);
		
		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(IP_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);			
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:71,代码来源:CassandraInsert.java

示例12: InsertUserQueryBook

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
/**
 * Insert into UserQueryBook CF
 */
public boolean InsertUserQueryBook(String name, String superUuid, String query, String book, String time) {
	System.out.println("------------InsertUserQueryBook--------------");
	String USER_KEY = name;
	String UUID_SUPER_KEY = superUuid;
	
	String QUERY_TITLE = "query";
	String QUERY_VALUE = query;
	
	String BOOK_TITLE = book;
	String BOOK_VALUE = time;
	
	String COLUMN_FAMILY = "UserQueryBook";
	
	try{
		Map<ByteBuffer, Map<String, List<Mutation>>> outerMap = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
		List<Mutation> columnToAdd = new ArrayList<Mutation>();

		long timeStamp = System.currentTimeMillis();
		
		// Construct Column
		Column idColumnQuery = new Column();
		idColumnQuery.setName(this.cassandraUtil.toByteBuffer(QUERY_TITLE));
		idColumnQuery.setValue(this.cassandraUtil.toByteBuffer(QUERY_VALUE));
		idColumnQuery.setTimestamp(timeStamp);
		
		Column idColumnBook = new Column();
		idColumnBook.setName(this.cassandraUtil.toByteBuffer(BOOK_TITLE));
		idColumnBook.setValue(this.cassandraUtil.toByteBuffer(BOOK_VALUE));
		idColumnBook.setTimestamp(timeStamp);
		
		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnQuery);
		cols.add(idColumnBook);
		
		// Map Key-super_key-column
		Map<String, List<Mutation>> innerMap = new HashMap<String, List<Mutation>>();

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = this.cassandraUtil.toByteBuffer(UUID_SUPER_KEY);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);
		
		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = COLUMN_FAMILY;
		columnPath.setSuper_column(this.cassandraUtil.toByteBuffer(UUID_SUPER_KEY));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(COLUMN_FAMILY, columnToAdd);
		
		// Insert Operator
		outerMap.put(this.cassandraUtil.toByteBuffer(USER_KEY), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.QUORUM);			
		
		return true;
	}catch(Exception e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:71,代码来源:CassandraInsert.java

示例13: superStore

import org.apache.cassandra.thrift.ColumnPath; //导入方法依赖的package包/类
public void superStore(String str) {
	String key_name = "Yanfei";
	String super_key_name = "100300";
	String ColumnFamilyName = "Super";
	String[] strList = str.split(" ");

	try {

		TTransport tr = new TFramedTransport(new TSocket("10.15.61.111", 9160));
		TProtocol proto = new TBinaryProtocol(tr);
		Cassandra.Client client = new Cassandra.Client(proto);
		
		tr.open();
		
		client.set_keyspace("Keyspace2");
		
		long timeStamp = System.currentTimeMillis();

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

		// 
		Column idColumnIp = new Column();
		idColumnIp.setName(toByteBuffer("ip"));
		idColumnIp.setValue(toByteBuffer(strList[0]));
		idColumnIp.setTimestamp(timeStamp);

		Column idColumnBookid = new Column();
		idColumnBookid.setName(toByteBuffer("bookid"));
		idColumnBookid.setValue(toByteBuffer(strList[1]));
		idColumnBookid.setTimestamp(timeStamp);

		Column idColumnPageid = new Column();
		idColumnPageid.setName(toByteBuffer("pageid"));
		idColumnPageid.setValue(toByteBuffer(strList[2]));
		idColumnPageid.setTimestamp(timeStamp);

		List<Column> cols = new ArrayList<Column>();
		cols.add(idColumnIp);
		cols.add(idColumnBookid);
		cols.add(idColumnPageid);

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

		Mutation columns = new Mutation();
		ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
		SuperColumn superColumn = new SuperColumn();

		superColumn.name = toByteBuffer(super_key_name);
		superColumn.columns = cols;

		columnOrSuperColumn.super_column = superColumn;
		columns.setColumn_or_supercolumn(columnOrSuperColumn);

		columnToAdd.add(columns);

		ColumnPath columnPath = new ColumnPath();
		columnPath.column_family = ColumnFamilyName;
		columnPath.setSuper_column(toByteBuffer(super_key_name));
		columnPath.setSuper_columnIsSet(true);

		innerMap.put(ColumnFamilyName, columnToAdd);

		// 
		outerMap.put(toByteBuffer(key_name), innerMap);

		client.batch_mutate(outerMap, ConsistencyLevel.ONE);
		
		tr.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:75,代码来源:TestSuper.java


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