看了四個小時hector guide,借用一個hector的使用清單來總結下hector的使用
import static me.prettyprint.cassandra.utils.StringUtils.bytes;
import static me.prettyprint.cassandra.utils.StringUtils.string;
import org.apache.cassandra.service.Column;
import org.apache.cassandra.service.ColumnPath;
public class ExampleClient {
public static void main(String[] args) throws IllegalStateException,
PoolExhaustedException, Exception {
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
// A load balanced version would look like this:
// CassandraClient client = pool.borrowClient(new String[] {"cas1:9160",
// "cas2:9160", "cas3:9160"});
try {
Keyspace keyspace = client.getKeyspace("Keyspace1");
ColumnPath columnPath = new ColumnPath("Standard1", null,
bytes("網址"));
// insert
keyspace.insert("逖靖寒的世界", columnPath,
bytes("http://gpcuster.cnblogs.com"));
// read
Column col = keyspace.getColumn("逖靖寒的世界", columnPath);
System.out
.println("Read from cassandra: " + string(col.getValue()));
} finally {
// return client to pool. do it in a finally block to make sure it's
// executed
pool.releaseClient(client);
}
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23937368/viewspace-1050522/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- hector tips
- 簡單的hector連線casssandra測試
- 使用Hector和Scala持久化Cassandra資料庫持久化資料庫
- cassandra&hector版本問題
- [論文閱讀] Hector MappingAPP
- hector-v2-client-doc.pdf read notesclient
- Oracle index 使用的一個總結OracleIndex
- 第一個mpvue小程式開發完了,來總結下吧Vue
- 對前端開發中常使用的函式方法的一個小總結前端函式
- 姍姍來遲的一個總結
- 使用sql*plus時的一個安全小問題SQL
- Vue一個案例引發「動畫」的使用總結Vue動畫
- 使用nodeJS寫一個簡單的小爬蟲NodeJS爬蟲
- TypeScript Partial 使用的一個小技巧TypeScript
- SQL*Loader的使用總結(四)SQL
- yum源使用的幾個報錯小總結 (例如: python2.6.6 下yum不能使用: No module named yum)Python
- 推薦一個清單工具
- 一個在高盛工作的學姐總結的12個時間管理妙招
- 建一個使用者來備份另外一個使用者的資料
- 總結十個Python 字典用法的使用技巧Python
- linux環境下phpize使用的一個小技巧分享給大家LinuxPHP
- 運動時誰還不來個姨媽:一個結合大姨媽的運動打卡小程式
- 使用 Vue.js 和 Flask 來構建一個單頁的AppVue.jsFlaskAPP
- 各位老大,請確認一下,使用ORACLE EBS 你們公司是否在這個清單中Oracle
- 一個使用者執行另外一個使用者的過程查詢的是哪個使用者下的物件物件
- RediSearch的簡單使用與總結Redis
- 一個網友的總結
- Android一個小知識點: 多個介面同時使用一個資源佈局的時候,修改背景需要注意的坑Android
- 一個大四前端實習生的2018年總結前端
- 一個簡單的例子教會您使用javapJava
- linux下使用ls命令時遇到的一個怪異現象Linux
- 使用go效率工具一小時輕鬆搭建一個簡單可靠的訂單系統,使用dtm解決分散式事務超級簡單Go分散式
- 一個程式設計師使用 PPT 的小技巧程式設計師
- 在 Flutter 中使用 setState 時的 6 個簡單技巧Flutter
- win下使用expdp的enclude引數時一個物件和多個物件的幾種寫法!物件
- 這 3 個 Set 集合的實現有點簡單,那來做個總結吧
- golang-web框架revel一個表單提交的總結GolangWeb框架
- 【lsof】使用lsof獲得打來 1521埠的程式清單