版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Introduction toApache Cassandra,(for Java developers!),Nate McCall zznate,Brief Intro,NOT a key/value store Columns are dynamic inside a column family SSTables are immutable SSTables merged on reads All nodes share the same role (i.e. no single point of failure) Trading ACID compliance for scalabili
2、ty is a fundamental design decision,How does this impact development?,Substantially. For operations affecting the same data, that data will become consistent eventually as determined by the timestamps. But you can trade availability for consistency. (More on this later) You can store whatever you wa
3、nt. Its all just bytes. You need to think about how you will query the data before you write it.,Neat. So Now What?,Like any database, you need a client! Python: Telephus: Pycassa: Java: Hector: Pelops: Kundera Datanucleus JDO: Grails: grails-cassandra: .NET: FluentCassandra: Aquiles: Ruby: Cassandr
4、a: PHP: phpcassa: SimpleCassie:,. but do not roll your own,Thrift,Fast, efficient serialization and network IO. Lots of clients available (you can probably use it in other places as well) Why you dont want to work with the Thrift API directly: SuperColumn ColumnOrSuperColumn ColumnParent.super_colum
5、n ColumnPath.super_column Map mutationMap,Higher Level Client,Hector JMX Counters Add/remove hosts: automatically programatically via JMX Plugable load balancing Complete encapsulation of Thrift API Type-safe approach to dealing with Apache Cassandra Lightweight ORM (supports JPA 1.0 annotations) Ma
6、venized!/maven2/me/prettyprint/,CQL,Currently in Apache Cassandra trunk Experimental Lots of possibilities fromtest/system/test_cql.py: UPDATE StandardLong1 SET 1L=1, 2L=2, 3L=3, 4L=4 WHERE KEY=aa SELECT cd1, col FROM Standard1 WHERE KEY = kd DELETE cd1, col FROM Standard1 WHERE
7、 KEY = kd,Avro?,Gone. Added too much complexity after Thrift caught up. None of the libraries distinguished themselves as being a particularly crappy choice for serialization. (SeeCASSANDRA-1765),Thrift API Methods,Retrieving Writing/Removing Meta Information Schema Manipulation,Thrift API Methods -
8、 Retrieving,get: retrieve a single column for a key get_slice: retrieve a slice of columns for a key multiget_slice: retrieve a slice of columns for a list of keys get_count: counts the columns of key (you have to deserialize the row to do it) get_range_slices: retrieve a slice for a range of keys g
9、et_indexed_slices (FTW!),Thrift API Methods - Writing/Removing,insert batch_mutate (batch insertion AND deletion) remove truncate*,Thrift API Methods - Meta Information,describe_cluster_name describe_version describe_keyspace describe_keyspaces,Thrift API Methods - Schema,system_add_keyspace system_
10、update_keyspace system_drop_keyspace system_add_column_family system_update_column_family system_drop_column_family,vs. RDBMS - Consistency Level,Consistency istunable per request! Cassandra provides consistency when R + W N (read replica count +write replica count replication factor). * CONSITENCY
11、LEVEL FAILURE IS NOT A ROLLBACK* Idempotent: an operation can be applied multiple times without changing the result,vs. RDBMS - Append Only,Proper data modelling will minimizes seeks (Go to Tylers presentation for more!),On to the Code., Uses Maven. Really basic. Modify/abuse/alter as needed. Descri
12、ptions of what is going on and how to run each example are in the Javadoc comments. Sample data is based on North American Numbering Plan /wiki/North_American_Numbering_Plan,Data Shape,512 202 30.27 097.74 W TX Austin 512 203 30.27 097.74 L TX Austin 512 204 30.32 097.73 W TX A
13、ustin 512 205 30.32 097.73 W TX Austin 512 206 30.32 097.73 L TX Austin,Get a Single Column for a Key,GetCityForNpanxx.java Retrieve a single column with: Name Value Timestamp TTL,Get the Contents of a Row,GetSliceForNpanxx.java Retrieves a list of columns (Hector wraps these in a ColumnSlice) Slice
14、Predicate can either be explicit set of columns OR a range (more on ranges soon) Another messy either/or choice encapsulated by Hector,Get the (sorted!) Columns of a Row,GetSliceForStateCity.java Shows why the choice of comparator is important (this is the order in which the columns hit the disk - t
15、ake advantage of it) Can be easily modified to return results in reverse order (but this is slightly slower),Get the Same Slice from Several Rows,MultigetSliceForNpanxx.java Very similar to get_slice examples, except we provide a list of keys,Get Slices From a Range of Rows,GetRangeSlicesForStateCit
16、y.java Like multiget_slice, except we can specify a KeyRange (encapsulated by RangeSlicesQuery#setKeys(start, end) The results of this query will be significantly more meaningful with OrderPreservingPartitioner (try this at home!),Get Slices From a Range of Rows - 2,GetSliceForAreaCodeCity.java Comp
17、ound column name for controlling ranges Comparator at work on text field,Get Slices from Indexed Columns,GetIndexedSlicesForCityState.java You only need to index a single column to apply clauses on other columns (BUT- the indexed column must be present with an EQUALS clause!) (Its just another Colum
18、nFamily maintained automatically),Insert, Update and Delete,. are effectively the same operation. InsertRowsForColumnFamilies.java DeleteRowsForColumnFamily.java Run each in succession (in whichever combination you like) and verify your results on the CLI Hint: watch the timestamps bin/cassandra-cli
19、 -host localhost use Tutorial; list AreaCode; list Npanxx; list StateCity;,Stuff I Punted on for the Sake of Brevity,meta_* methods CassandraClusterTest.java: L43-81 hector system_* methods SchemaManipulation.java hector-examples CassandraClusterTest.java: L84-157 hector ORM (it works and is in production) ORM Documentation multiple nodes failure scenarios Data modelling (go see Tylers presentation),Things to Remember,deletes and timestamp granularity range ghosts u
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年秋季大学新生军训 阅兵分列式训练
- 2026年秋季初中新生军训 军训中的感恩教育课件
- 2026年承德石油高专高职单招职业适应性测试考试模拟试卷含完整答案详解(夺冠)
- 2024年太原汾河职业学院高职单招职业适应性测试考试模拟试卷附答案详解【能力提升】
- 2026年西安海棠职业学院单招职业技能考试题库及答案详解【名师系列】
- 2024年山东雁山职业学院高职单招职业适应性测试考试题库及答案详解(考点梳理)
- 人工智能在保险理赔自动化中的实践
- 2026年秋季高中新生军训 军歌学唱与士气鼓舞教学方案
- 2025年汾河文旅职业学院高职单招职业技能考试模拟试卷完整参考答案详解
- 2026年山西阳泉市单招综合素质考试题库及答案详解【夺冠系列】
- 美的仓库管理制度
- 母婴保健技术服务考核标准与操作规范手册
- 关于农业防灾减灾工作落实情况的汇报
- 2025《煤矿安全规程》“一通三防”修订内容理解课件
- 委托审价合同范本
- GB/T 29485-2025船舶与海洋技术电气舵角指示器
- 食品快检考试题及答案
- T-CEMA 048-2025 体重管理门诊建设指南
- 2025年大连辅警协警招聘考试备考题库及答案详解一套
- 2025年中级经济师考试中级保险专业真题及答案
- 服装厂生产流程标准化操作手册
评论
0/150
提交评论