版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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年平顶山文化艺术职业学院单招职业倾向性考试题库带答案详解(a卷)
- 2026年山西省晋城市单招职业适应性考试题库附答案详解(培优a卷)
- 2026年广东省广州市单招职业适应性考试题库带答案详解(黄金题型)
- 2026年广西制造工程职业技术学院单招职业技能测试题库附参考答案详解(研优卷)
- 胸腺继发恶性肿瘤的护理
- 2026年广东省单招职业适应性测试题库含答案详解(b卷)
- 2026年山西省运城市单招职业倾向性考试题库附答案详解(突破训练)
- 财产保险承保试卷及答案
- 职场汇报逻辑搭建:从结构化表达到高效呈现
- 2025至2030中国冷链物流仓储设施区域分布及运营效率优化分析报告
- 旅行社运营实务电子课件 2.1 走进旅行社门市
- 《健身气功八段锦》教案
- 乳腺良性肿瘤日间手术临床路径临床路径
- CBCC中国建筑色卡色
- (完整版)简单儿童对比涂色画画-可打印(干货)
- GB/T 16924-2008钢件的淬火与回火
- 中考语文专题复习专题一汉字读写课件
- 腹腔镜辅助下阴式子宫切除的课件
- 交管12123驾照学法减分题库200题(含答案完整版)
- 医院卒中中心护理组职责
- 露天煤矿边坡雷达管理制度 (试行)
评论
0/150
提交评论