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


Java Column.setName方法代码示例

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


在下文中一共展示了Column.setName方法的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: 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

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

示例5: InsertTest2

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
/**
 * Insert into IpUser Column Family
 */
public boolean InsertTest2(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("content"));
		idColumnPageid.setValue(this.cassandraUtil.toByteBuffer(val));
		idColumnPageid.setTimestamp(timeStamp);
		client.insert(this.cassandraUtil.toByteBuffer(String.valueOf(key)), parent, idColumnPageid, ConsistencyLevel.ONE);

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

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

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

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

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

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

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

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

示例14: write

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
@Override
public void write(String keySpace, CassandraProxyClient client, JobConf jc) throws IOException {
    ConsistencyLevel flevel = getConsistencyLevel(jc);
    int batchMutation = getBatchMutationSize(jc);
    Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();

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

    int count = 0;
    // TODO check for counter
    for (CassandraColumn col : columns) {
        Column cassCol = new Column();
        cassCol.setValue(col.getValue());
        cassCol.setTimestamp(col.getTimeStamp());
        cassCol.setName(col.getColumn());

        ColumnOrSuperColumn thisCol = new ColumnOrSuperColumn();
        thisCol.setColumn(cassCol);

        Mutation mutation = new Mutation();
        mutation.setColumn_or_supercolumn(thisCol);

        List<Mutation> mutList = maps.get(col.getColumnFamily());
        if (mutList == null) {
            mutList = new ArrayList<Mutation>();
            maps.put(col.getColumnFamily(), mutList);
        }

        mutList.add(mutation);
        count++;

        if (count == batchMutation) {
            mutation_map.put(key, maps);

            commitChanges(keySpace, client, flevel, mutation_map);

            //reset mutation map, maps and count;
            mutation_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
            maps = new HashMap<String, List<Mutation>>();
            count = 0;
        }
    }

    if (count > 0) {
        mutation_map.put(key, maps);
        commitChanges(keySpace, client, flevel, mutation_map);
    }
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:49,代码来源:CassandraPut.java

示例15: write

import org.apache.cassandra.thrift.Column; //导入方法依赖的package包/类
@Override
public void write(String keySpace, CassandraProxyClient client, JobConf jc) throws IOException {
    ConsistencyLevel flevel = getConsistencyLevel(jc);
    int batchMutation = getBatchMutationSize(jc);
    Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
    Map<String, List<Mutation>> maps = new HashMap<String, List<Mutation>>();

    int count = 0;
    for (CassandraPut c : subColumns) {
        List<Column> columns = new ArrayList<Column>();
        for (CassandraColumn col : c.getColumns()) {
            Column cassCol = new Column();
            cassCol.setValue(col.getValue());
            cassCol.setTimestamp(col.getTimeStamp());
            cassCol.setName(col.getColumn());
            columns.add(cassCol);

            ColumnOrSuperColumn thisSuperCol = new ColumnOrSuperColumn();
            thisSuperCol.setSuper_column(new SuperColumn(c.getKey(), columns));

            Mutation mutation = new Mutation();
            mutation.setColumn_or_supercolumn(thisSuperCol);

            List<Mutation> mutList = maps.get(col.getColumnFamily());
            if (mutList == null) {
                mutList = new ArrayList<Mutation>();
                maps.put(col.getColumnFamily(), mutList);
            }

            mutList.add(mutation);

            count++;

            if (count == batchMutation) {
                mutation_map.put(key, maps);

                commitChanges(keySpace, client, flevel, mutation_map);

                //reset mutation map, maps and count;
                mutation_map = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
                maps = new HashMap<String, List<Mutation>>();
                count = 0;
            }

        }
    }

    if (count > 0) {
        mutation_map.put(key, maps);
        commitChanges(keySpace, client, flevel, mutation_map);
    }
}
 
开发者ID:2013Commons,项目名称:hive-cassandra,代码行数:53,代码来源:CassandraSuperPut.java


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