看了四個小時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 MappingAPP
- 對前端開發中常使用的函式方法的一個小總結前端函式
- 第一個mpvue小程式開發完了,來總結下吧Vue
- 使用nodeJS寫一個簡單的小爬蟲NodeJS爬蟲
- 姍姍來遲的一個總結
- Vue一個案例引發「動畫」的使用總結Vue動畫
- 使用VUE寫一段時間專案的個人總結-元件篇Vue元件
- TypeScript Partial 使用的一個小技巧TypeScript
- 做個簡單的一年小結
- 總結十個Python 字典用法的使用技巧Python
- linux環境下phpize使用的一個小技巧分享給大家LinuxPHP
- 一個大四前端實習生的2018年總結前端
- RediSearch的簡單使用與總結Redis
- 一個小廠演算法工程師的2022個人年終總結演算法工程師
- 使用 Vue.js 和 Flask 來構建一個單頁的AppVue.jsFlaskAPP
- Android一個小知識點: 多個介面同時使用一個資源佈局的時候,修改背景需要注意的坑Android
- Element-UI個人使用總結UI
- 推薦一個清單工具
- 運動時誰還不來個姨媽:一個結合大姨媽的運動打卡小程式
- Docker 19.03.13的四個使用細節Docker
- clickhouse使用的一點總結
- SimpleDateFormat.format的簡單使用小結ORM
- 使用go效率工具一小時輕鬆搭建一個簡單可靠的訂單系統,使用dtm解決分散式事務超級簡單Go分散式
- 回首 2022 -> 展望 2023,一個簡單的年終總結
- 在 Flutter 中使用 setState 時的 6 個簡單技巧Flutter
- 建立一個簡單的小程式
- 這 3 個 Set 集合的實現有點簡單,那來做個總結吧
- 小學期第一週個人總結
- 總結:使用MyBatis Generator時遇到的坑MyBatis
- 總結Spring Cloud各個元件配套使用SpringCloud元件
- 一個應屆生的 2018 總結以及面試小 tips面試
- 一個想活得簡單的程式猿的2022年終總結!
- 使用python的scrapy來編寫一個爬蟲Python爬蟲
- 19 個來自 2019 React Conf 的總結React
- 使用setInterval與clearInterval踩的小坑總結
- 使用node啟動一個簡單的服務
- 一個簡單的例子教會您使用javapJava
- 使用 Python 構建一個簡單的 RESTful APIPythonRESTAPI
- 使用“純”Servlet做一個單表的CRUD操作Servlet