• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Column类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
/**
 * get 讀取1個column
 *
 * @throws Exception
 */
@Test
public void get() throws Exception {
	String KEYSPACE = "mock";
	client.set_keyspace(KEYSPACE);

	// 讀取1個column
	String COLUMN_FAMILY = "student";
	ColumnPath columnPath = new ColumnPath(COLUMN_FAMILY);
	//
	String COLUMN = "grad";
	columnPath.setColumn(ByteBufferHelper.toByteBuffer(COLUMN));

	String ROW_KEY = "Jack";
	// key, column_path, consistency_level
	ColumnOrSuperColumn cos = client.get(
			ByteBufferHelper.toByteBuffer(ROW_KEY), columnPath,
			ConsistencyLevel.ONE);// NotFoundException

	Column column = cos.getColumn();
	System.out.println(ROW_KEY + ", "
			+ ByteHelper.toString(column.getName()) + ": "
			+ ByteHelper.toString(column.getValue()) + ", "
			+ column.getTimestamp());
	// Jack, grad: 5, 1380932164492000
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:31,代码来源:CassandraThriftDMLTest.java


示例2: getByCql

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
/**
 * getByCql
 *
 * @throws Exception
 */
@Test
public void getByCql() throws Exception {
	String KEYSPACE = "mock";
	client.set_keyspace(KEYSPACE);
	//
	String CQL = "select * from student where KEY='Jack'";
	// query, compression
	CqlResult result = client.execute_cql_query(
			ByteBufferHelper.toByteBuffer(CQL), Compression.NONE);
	System.out.println(result);

	for (CqlRow cqlRow : result.getRows()) {
		for (Column column : cqlRow.getColumns()) {
			System.out.println(ByteHelper.toString(cqlRow.getKey()) + ", "
					+ ByteHelper.toString(column.getName()) + ": "
					+ ByteHelper.toString(column.getValue()) + ", "
					+ column.getTimestamp());
			// Jack, KEY: Jack, -1
			// Jack, art: 87, 1380933848350
			// Jack, grad: 5, 1380932164492000
			// Jack, math: 97, 1380933848305
		}
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:30,代码来源:CassandraThriftDMLTest.java


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


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


示例5: QueryOneMinute

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


示例6: QueryOneMinute

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


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


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


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


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


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


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


示例13: open

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
public void open() throws Exception {
    TSocket sock = new TSocket(Config.getCassandraIP(), Config.getCassandraPort());
    sock.setTimeout(1000000);
    transport = new TFramedTransport(sock);
    client = new Cassandra.Client(new TBinaryProtocol(transport));
    transport.open();

    client.set_keyspace(Config.getCassandraKeyspace());
    cl = ConsistencyLevel.valueOf(Config.getCassandraConsistencyLevel());

    writeColumn = new Column();
    writeColumnFamily = new ColumnParent(Config.getCassandraColumnFamily());

    columnPath = new ColumnPath(Config.getCassandraColumnFamily());
    bytesRead = bytesWritten = readLatency = writeLatency = 0;
}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:17,代码来源:CassandraStorage.java


示例14: thriftify

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
private static Column thriftify(org.apache.cassandra.db.Cell c)
{
    ByteBuffer value = (c instanceof CounterCell)
                       ? ByteBufferUtil.bytes(CounterContext.instance().total(c.value()))
                       : c.value();
    return new Column(c.name().toByteBuffer()).setValue(value).setTimestamp(c.timestamp());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:QueryProcessor.java


示例15: run

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
public void run(final ThriftClient client) throws IOException
{
    final ByteBuffer key = getKey();
    final List<Column> columns = getColumns();

    List<Mutation> mutations = new ArrayList<>(columns.size());
    for (Column c : columns)
    {
        ColumnOrSuperColumn column = new ColumnOrSuperColumn().setColumn(c);
        mutations.add(new Mutation().setColumn_or_supercolumn(column));
    }
    Map<String, List<Mutation>> row = Collections.singletonMap(type.table, mutations);

    final Map<ByteBuffer, Map<String, List<Mutation>>> record = Collections.singletonMap(key, row);

    timeWithRetry(new RunOp()
    {
        @Override
        public boolean run() throws Exception
        {
            client.batch_mutate(record, settings.command.consistencyLevel);
            return true;
        }

        @Override
        public int partitionCount()
        {
            return 1;
        }

        @Override
        public int rowCount()
        {
            return 1;
        }
    });
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:38,代码来源:ThriftInserter.java


示例16: getColumns

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
protected List<Column> getColumns()
{
    final ColumnSelection selection = select();
    final List<ByteBuffer> values = getColumnValues(selection);
    final List<Column> columns = new ArrayList<>(values.size());
    final List<ByteBuffer> names = select().select(settings.columns.names);
    for (int i = 0 ; i < values.size() ; i++)
        columns.add(new Column(names.get(i))
                    .setValue(values.get(i))
                    .setTimestamp(settings.columns.timestamp != null
                                  ? Long.parseLong(settings.columns.timestamp)
                                  : FBUtilities.timestampMicros()));
    return columns;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:ThriftInserter.java


示例17: validateColumnNames

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
private static void validateColumnNames(Iterable<ByteBuffer> columns)
throws InvalidRequestException
{
    for (ByteBuffer name : columns)
    {
        if (name.remaining() > org.apache.cassandra.db.Column.MAX_NAME_LENGTH)
            throw new InvalidRequestException(String.format("column name is too long (%s > %s)",
                                                            name.remaining(),
                                                            org.apache.cassandra.db.Column.MAX_NAME_LENGTH));
        if (name.remaining() == 0)
            throw new InvalidRequestException("zero-length column name");
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:14,代码来源:QueryProcessor.java


示例18: thriftify

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
private static Column thriftify(org.apache.cassandra.db.Column c)
{
    ByteBuffer value = (c instanceof CounterColumn)
                       ? ByteBufferUtil.bytes(CounterContext.instance().total(c.value()))
                       : c.value();
    return new Column(c.name()).setValue(value).setTimestamp(c.timestamp());
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:QueryProcessor.java


示例19: printRows

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
private void printRows(CqlResult result) {
    for (CqlRow row : result.getRows()) {
        getLog().info("Row key: " + keyValidatorVal.getString(row.key));
        getLog().info("-----------------------------------------------");
        for (Column column : row.getColumns()) {
            getLog().info(" name: " + comparatorVal.getString(column.name));
            getLog().info(" value: " + defaultValidatorVal.getString(column.value));
            getLog().info("-----------------------------------------------");
        }

    }
}
 
开发者ID:mojohaus,项目名称:cassandra-maven-plugin,代码行数:13,代码来源:CqlExecCassandraMojo.java


示例20: get2

import org.apache.cassandra.thrift.Column; //导入依赖的package包/类
/**
 * get 讀取所有column
 *
 * @throws Exception
 */
@Test
public void get2() throws Exception {
	String KEYSPACE = "mock";
	client.set_keyspace(KEYSPACE);

	// 讀取所有column
	String COLUMN_FAMILY = "student";
	ColumnParent columnParent = new ColumnParent(COLUMN_FAMILY);

	// 術語
	SlicePredicate predicate = new SlicePredicate();

	// 範圍
	SliceRange sliceRange = new SliceRange();
	// sliceRange.setStart(ByteBufferHelper.toByteBuffer(new byte[0]));//開始
	sliceRange.setStart(new byte[0]);// 開始
	sliceRange.setFinish(new byte[0]);// 結束
	sliceRange.setCount(100);// 筆數
	//
	predicate.setSlice_range(sliceRange);

	String ROW_KEY = "Jack";
	// 結果
	// key, column_parent, predicate, consistency_level
	List<ColumnOrSuperColumn> results = client.get_slice(
			ByteBufferHelper.toByteBuffer(ROW_KEY), columnParent,
			predicate, ConsistencyLevel.ONE);

	for (ColumnOrSuperColumn cos : results) {
		Column column = cos.getColumn();
		System.out.println(ROW_KEY + ", "
				+ ByteHelper.toString(column.getName()) + ": "
				+ ByteHelper.toString(column.getValue()) + ", "
				+ column.getTimestamp());
		// Jack, art, 87, 1380788003220
		// Jack, grad, 5, 1380788003203
		// Jack, math, 97, 1380788003214
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:45,代码来源:CassandraThriftDMLTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WBMPImageWriterSpi类代码示例发布时间:2022-05-21
下一篇:
Java GroovyCodeSource类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap