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


Java Column.setValue方法代码示例

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


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

示例1: getMutation

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private Mutation getMutation(String columnName, Object value, long timestamp) {
    byte[] columnNameBytes;
    try {
        columnNameBytes = columnName.getBytes("UTF-8");
    }
    catch (UnsupportedEncodingException exc) {
        throw new StorageException("Unsupported character encoding for column name", exc);
    }
    byte[] valueBytes = convertValueToBytes(value);
    Column column = new Column();
    column.setName(columnNameBytes);
    column.setValue(valueBytes);
    column.setTimestamp(timestamp);
    ColumnOrSuperColumn columnOrSuperColumn = new ColumnOrSuperColumn();
    columnOrSuperColumn.setColumn(column);
    Mutation mutation = new Mutation();
    mutation.setColumn_or_supercolumn(columnOrSuperColumn);
    return mutation;
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:20,代码来源:Connection.java

示例2: createMutation

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private static Mutation createMutation(byte[] colName, byte[] colValue, long timestamp) {
    if (colValue == null) {
        colValue = EMPTY_BYTES;
    }
    Column col = new Column();
    col.setName(colName);
    col.setValue(colValue);
    col.setTimestamp(timestamp);
    
    ColumnOrSuperColumn cosc = new ColumnOrSuperColumn();
    cosc.setColumn(col);
    
    Mutation mutation = new Mutation();
    mutation.setColumn_or_supercolumn(cosc);
    return mutation;
}
 
开发者ID:QSFT,项目名称:Doradus,代码行数:17,代码来源:CassandraTransaction.java

示例3: InsertTest

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
 * Insert into IpUser Column Family
 */
public boolean InsertTest(String key, int val) {
	System.out.println("------------InsertTest--------------");

	try {
		ColumnParent parent = new ColumnParent("test");

		long timeStamp = System.currentTimeMillis();

		Column idColumnPageid = new Column();
		idColumnPageid.setName(this.cassandraUtil.toByteBuffer("signal"));
		idColumnPageid.setValue(this.cassandraUtil.toByteBuffer(String.valueOf(val)));
		idColumnPageid.setTimestamp(timeStamp);
		client.insert(this.cassandraUtil.toByteBuffer(key), parent, idColumnPageid, ConsistencyLevel.ONE);

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

示例4: UpdateMaxid

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
 * Update 'maxid' in CF 'ChapterSignalMap'
 */
public boolean UpdateMaxid(String signal) {
	
	try{
		ColumnParent parent = new ColumnParent("ChapterSignalMap");
		
		long timeStamp = System.currentTimeMillis();
		
		Column signalCol = new Column();
		signalCol.setName(this.cassandraUtil.toByteBuffer("maxid"));
		signalCol.setValue(this.cassandraUtil.toByteBuffer(signal));
		signalCol.setTimestamp(timeStamp);
		
		this.client.insert(this.cassandraUtil.toByteBuffer("maxid"), parent, signalCol, ConsistencyLevel.QUORUM);
		
	}catch(Exception e) {
		e.printStackTrace();
	}
	
	return true;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:24,代码来源:InsertChapterInfo.java

示例5: InsertTest3

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
 * Insert into IpUser Column Family
 */
public boolean InsertTest3(int userid, int key, String val) {
	System.out.println("------------InsertTest--------------");

	try {
		ColumnParent parent = new ColumnParent("test");

		long timeStamp = System.currentTimeMillis();

		Column idColumnPageid = new Column();
		idColumnPageid.setName(this.cassandraUtil.toByteBuffer(String.valueOf(key)));
		idColumnPageid.setValue(this.cassandraUtil.toByteBuffer(val));
		idColumnPageid.setTimestamp(timeStamp);
		client.insert(this.cassandraUtil.toByteBuffer(String.valueOf(userid)), parent, idColumnPageid, ConsistencyLevel.ONE);

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

示例6: InsertIntoUserChapter

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
	 * Insert into CF -- "UserChapter"
	 * @param int userid: the key of column   like '119115'
	 * @param int signal: chapter's signal	  like '23'
	 * @param String content: chapter's value like '"07018720_1.0.0.0.0"'
	 */
	public boolean InsertIntoUserChapter(int userid, int signal, String content){
//		System.out.println("------------InsertIntoUserChapter--------------");

		try {
			ColumnParent parent = new ColumnParent("UserChapter");

			long timeStamp = System.currentTimeMillis();

			Column userChapter = new Column();
			userChapter.setName(this.cassandraUtil.toByteBuffer(String.valueOf(signal)));
			userChapter.setValue(this.cassandraUtil.toByteBuffer(content));
			userChapter.setTimestamp(timeStamp);
			client.insert(this.cassandraUtil.toByteBuffer(String.valueOf(userid)), parent, userChapter, ConsistencyLevel.QUORUM);

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

示例7: InsertIntoSignalChapterMap

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
	 * Insert into CF -- "SignalChapterMap"
	 * @param int signal: chapter's signal	  like '23'
	 * @param String content: chapter's value like '"07018720_1.0.0.0.0"'
	 */
	public boolean InsertIntoSignalChapterMap(int signal, String content){
//		System.out.println("------------InsertIntoSignalChapterMap--------------");

		try {
			ColumnParent parent = new ColumnParent("SignalChapterMap");

			long timeStamp = System.currentTimeMillis();

			Column signalChapter = new Column();
			signalChapter.setName(this.cassandraUtil.toByteBuffer("content"));
			signalChapter.setValue(this.cassandraUtil.toByteBuffer(content));
			signalChapter.setTimestamp(timeStamp);
			client.insert(this.cassandraUtil.toByteBuffer(String.valueOf(signal)), parent, signalChapter, ConsistencyLevel.QUORUM);
			
			return true;
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:27,代码来源:InsertChapterInfo.java

示例8: update

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
 * update
 *
 * @throws Exception
 */
@Test
public void update() throws Exception {
	String KEYSPACE = "mock";
	client.set_keyspace(KEYSPACE);

	List<Mutation> mutations = new LinkedList<Mutation>();
	// <columnFamily,mutations>
	Map<String, List<Mutation>> columnfamilyMutaions = new HashMap<String, List<Mutation>>();// keyMutations
	// <rowKey,keyMutations>
	Map<ByteBuffer, Map<String, List<Mutation>>> rowKeyMutations = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();

	long timestamp = System.nanoTime();
	//
	Column column = new Column();
	column.setName(ByteBufferHelper.toByteBuffer("grad"));
	column.setValue(ByteBufferHelper.toByteBuffer("9"));
	column.setTimestamp(timestamp);
	//
	ColumnOrSuperColumn cos = new ColumnOrSuperColumn();
	cos.setColumn(column);
	//
	Mutation mutation = new Mutation();
	mutation.setColumn_or_supercolumn(cos);
	mutations.add(mutation);

	String COLUMN_FAMILY = "student";
	columnfamilyMutaions.put(COLUMN_FAMILY, mutations);

	String ROW_KEY = "Jack";
	rowKeyMutations.put(ByteBufferHelper.toByteBuffer(ROW_KEY),
			columnfamilyMutaions);

	// mutation_map, consistency_level
	client.batch_mutate(rowKeyMutations, ConsistencyLevel.ONE);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:41,代码来源:CassandraThriftDMLTest.java

示例9: insertColumnValue

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private void insertColumnValue(String parentName, String id, String name, String value, long ts) throws TException, TimedOutException, UnavailableException, InvalidRequestException, UnsupportedEncodingException {
  ColumnParent parent = new ColumnParent(parentName);
  Column column = new Column(toByteBuffer(name));
  column.setValue(toByteBuffer(value));
  column.setTimestamp(ts);
  getClient().insert(toByteBuffer(id), parent, column, ConsistencyLevel.ONE);
}
 
开发者ID:isparkes,项目名称:OpenRate,代码行数:8,代码来源:AbstractCassandraInputAdapter.java

示例10: toThriftResult

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public CqlResult toThriftResult()
{
    String UTF8 = "UTF8Type";
    CqlMetadata schema = new CqlMetadata(new HashMap<ByteBuffer, String>(),
            new HashMap<ByteBuffer, String>(),
            // The 2 following ones shouldn't be needed in CQL3
            UTF8, UTF8);

    for (ColumnSpecification name : metadata.names)
    {
        ByteBuffer colName = ByteBufferUtil.bytes(name.toString());
        schema.name_types.put(colName, UTF8);
        AbstractType<?> normalizedType = name.type instanceof ReversedType ? ((ReversedType)name.type).baseType : name.type;
        schema.value_types.put(colName, normalizedType.toString());

    }

    List<CqlRow> cqlRows = new ArrayList<CqlRow>(rows.size());
    for (List<ByteBuffer> row : rows)
    {
        List<Column> thriftCols = new ArrayList<Column>(metadata.names.size());
        for (int i = 0; i < metadata.names.size(); i++)
        {
            Column col = new Column(ByteBufferUtil.bytes(metadata.names.get(i).toString()));
            col.setValue(row.get(i));
            thriftCols.add(col);
        }
        // The key of CqlRow shoudn't be needed in CQL3
        cqlRows.add(new CqlRow(ByteBufferUtil.EMPTY_BYTE_BUFFER, thriftCols));
    }
    CqlResult res = new CqlResult(CqlResultType.ROWS);
    res.setRows(cqlRows).setSchema(schema);
    return res;
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:35,代码来源:ResultSet.java

示例11: getMutation

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private static Mutation getMutation(Text word, int sum) {
    Column c = new Column();
    c.setName(Arrays.copyOf(word.getBytes(), word.getLength()));
    c.setValue(ByteBufferUtil.bytes(String.valueOf(sum)));
    c.setTimestamp(System.currentTimeMillis());

    Mutation m = new Mutation();
    m.setColumn_or_supercolumn(new ColumnOrSuperColumn());
    m.column_or_supercolumn.setColumn(c);

    return m;
}
 
开发者ID:adrianchifor,项目名称:mapreduce-wordcount,代码行数:13,代码来源:Cassandra_WordCount.java

示例12: getMutation

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private static Mutation getMutation(Text word, int sum)
{
    Column c = new Column();
    c.setName(Arrays.copyOf(word.getBytes(), word.getLength()));
    c.setValue(ByteBufferUtil.bytes(String.valueOf(sum)));
    c.setTimestamp(System.currentTimeMillis());

    Mutation m = new Mutation();
    m.setColumn_or_supercolumn(new ColumnOrSuperColumn());
    m.column_or_supercolumn.setColumn(c);
    return m;
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:13,代码来源:WordCount.java

示例13: createMutation

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
public static Mutation createMutation(Object name, Object value, long timestamp, int ttl) {
  Column column = new Column();
  column.setName(toByteBuffer(name));
  column.setValue(toByteBuffer(value));
  column.setTimestamp(timestamp);
  if (ttl > 0) {
    column.setTtl(ttl);
  }

  Mutation mutation = new Mutation();
  mutation.column_or_supercolumn = new ColumnOrSuperColumn();
  mutation.column_or_supercolumn.column = column;
  return mutation;
}
 
开发者ID:spotify,项目名称:hdfs2cass,代码行数:15,代码来源:CassandraRecordUtils.java

示例14: createColumn

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
private Column createColumn(String name,String value){
	long timeStamp = System.currentTimeMillis();
	Column clm  = new Column();
	clm.setName(toByteBuffer(name));
	clm.setValue(toByteBuffer(value));
	clm.setTimestamp(timeStamp);
	return clm;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:9,代码来源:Record.java

示例15: InsertIntoChapterSignalMap

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
	 * Insert into CF -- "ChapterSignalMap"
	 * @param String content: chapter's value like '"07018720_1.0.0.0.0"'
	 * @param int signal: chapter's signal	  like '23'
	 * This function will columate 'maxid' automatic.
	 */
	public boolean InsertIntoChapterSignalMap(String content, int signal){
//		System.out.println("------------InsertIntoChapterSignalMap--------------");

		try {
			ColumnParent parent = new ColumnParent("ChapterSignalMap");

			long timeStamp = System.currentTimeMillis();
			
			// insert into new column
			Column chapterSignal = new Column();
			chapterSignal.setName(this.cassandraUtil.toByteBuffer("signal"));
			chapterSignal.setValue(this.cassandraUtil.toByteBuffer(String.valueOf(signal)));
			chapterSignal.setTimestamp(timeStamp);
			client.insert(this.cassandraUtil.toByteBuffer(content), parent, chapterSignal, ConsistencyLevel.QUORUM);
			
			// update 'maxid' column
			Column maxidColumn = new Column();
			maxidColumn.setName(this.cassandraUtil.toByteBuffer("maxid"));
			maxidColumn.setValue(this.cassandraUtil.toByteBuffer(String.valueOf(signal + 1)));
			maxidColumn.setTimestamp(timeStamp);
			client.insert(this.cassandraUtil.toByteBuffer("maxid"), parent, maxidColumn, ConsistencyLevel.QUORUM);			
			
			return true;
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:36,代码来源:InsertChapterInfo.java


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