本文整理汇总了Java中org.apache.cassandra.thrift.ColumnParent类的典型用法代码示例。如果您正苦于以下问题:Java ColumnParent类的具体用法?Java ColumnParent怎么用?Java ColumnParent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ColumnParent类属于org.apache.cassandra.thrift包,在下文中一共展示了ColumnParent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
public void run(final ThriftClient client) throws IOException
{
final SlicePredicate predicate = select().predicate();
final ByteBuffer key = getKey();
timeWithRetry(new RunOp()
{
@Override
public boolean run() throws Exception
{
List<?> r = client.get_slice(key, new ColumnParent(type.table), predicate, settings.command.consistencyLevel);
return r != null && r.size() > 0;
}
@Override
public int partitionCount()
{
return 1;
}
@Override
public int rowCount()
{
return 1;
}
});
}
示例2: State
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
public State(Command type, StressSettings settings, StressMetrics metrics)
{
this.type = type;
this.timer = metrics.getTiming().newTimer();
if (type == Command.MIXED)
readWriteSelector = ((SettingsCommandMixed) settings.command).selector();
else
readWriteSelector = null;
this.settings = settings;
this.keyGen = settings.keys.newKeyGen();
this.rowGen = settings.columns.newRowGen();
this.metrics = metrics;
if (!settings.columns.useSuperColumns)
columnParents = Collections.singletonList(new ColumnParent(settings.schema.columnFamily));
else
{
ColumnParent[] cp = new ColumnParent[settings.columns.superColumns];
for (int i = 0 ; i < cp.length ; i++)
cp[i] = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes("S" + i));
columnParents = Arrays.asList(cp);
}
}
示例3: getColumnValue
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
private String getColumnValue(String ks, String cf, String colName, String key, String validator)
throws AuthenticationException, AuthorizationException, InvalidRequestException, UnavailableException, TimedOutException, TException, NotFoundException, IOException
{
Cassandra.Client client = getClient();
client.set_keyspace(ks);
ByteBuffer key_user_id = ByteBufferUtil.bytes(key);
long timestamp = System.currentTimeMillis();
ColumnPath cp = new ColumnPath(cf);
ColumnParent par = new ColumnParent(cf);
cp.column = ByteBufferUtil.bytes(colName);
// read
ColumnOrSuperColumn got = client.get(key_user_id, cp, ConsistencyLevel.ONE);
return parseType(validator).getString(got.getColumn().value);
}
示例4: CasTimeReader
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
public CasTimeReader() {
try {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.111",
9160));
TProtocol proto = new TBinaryProtocol(tr);
client = new Cassandra.Client(proto);
tr.open();
client.set_keyspace("CadalSecTest");
predicate = new SlicePredicate();
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
range.setCount(10000);
predicate.setSlice_range(range);
columnParent = new ColumnParent();
columnParent.setColumn_family("RecordMinute");
} catch (Exception e) {
System.out.println(e);
}
}
示例5: CasTimeBook
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
public CasTimeBook() {
try {
TTransport tr = new TFramedTransport(new TSocket("10.15.61.111",
9160));
TProtocol proto = new TBinaryProtocol(tr);
client = new Cassandra.Client(proto);
tr.open();
client.set_keyspace("CadalSecTest");
predicate = new SlicePredicate();
SliceRange range = new SliceRange();
range.setStart(new byte[0]);
range.setFinish(new byte[0]);
range.setCount(10000);
predicate.setSlice_range(range);
columnParent = new ColumnParent();
columnParent.setColumn_family("RecordMinute");
} catch (Exception e) {
System.out.println(e);
}
}
示例6: InsertTest
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
示例7: InsertTest2
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
示例8: InsertTest3
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
示例9: InsertIntoUserChapter
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
}
示例10: InsertIntoSignalChapterMap
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
}
示例11: UpdateMaxid
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
示例12: open
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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;
}
示例13: run
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的package包/类
public void run(final ThriftClient client) throws IOException
{
final ColumnSelection select = select();
final ByteBuffer key = getKey();
final List<ByteBuffer> expect = getColumnValues(select);
timeWithRetry(new RunOp()
{
@Override
public boolean run() throws Exception
{
List<ColumnOrSuperColumn> row = client.get_slice(key, new ColumnParent(type.table), select.predicate(), settings.command.consistencyLevel);
if (expect == null)
return !row.isEmpty();
if (row == null)
return false;
if (row.size() != expect.size())
return false;
for (int i = 0 ; i < row.size() ; i++)
if (!row.get(i).getColumn().bufferForValue().equals(expect.get(i)))
return false;
return true;
}
@Override
public int partitionCount()
{
return 1;
}
@Override
public int rowCount()
{
return 1;
}
});
}
示例14: get2
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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
}
}
示例15: insertColumnValue
import org.apache.cassandra.thrift.ColumnParent; //导入依赖的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);
}