现在的位置: 首页 > 综合 > 正文

NoSQL>CouchDB>Technical Overview(技术概述)

2013年03月18日 ⁄ 综合 ⁄ 共 1722字 ⁄ 字号 评论关闭

基于版本1.2

文档存储

如果说表是SQL Server的存储单元,那么文档documents就是CouchDB的存储单元。每个文档都有一个唯一的ID。开发人员可以根据CouchDB提供的RESTful HTTP API对文档进行增删查改。

SQL Server里表的列,也就是字段,有Int,String,Text,boolean等等类型,CouchDB里的文档的字段,也有类型,类型是以字符串为主。CouchDB里的文档暂时没有字段个数限制,和字段的大小限制。

CouchDB没有什么锁机制。修改文档的过程就是,读取文档,修改文档,返回文档。如果你读取了文档,正在修改文档,别人早你一步改了同样的文档,那么你所作的修改,会覆盖别人的修改。

文档修改,要么整个修改成功,要么失败,不会部分字段修改成功,部分字段却修改失败。

 

ACID Properties

The CouchDB file layout and commitment system features all Atomic Consistent Isolated Durable (ACID) properties. On-disk, CouchDB never overwrites committed data or associated structures, ensuring the database file is always in a consistent state. This is a “crash-only" design where the CouchDB server does not go through a shut down process, it's simply terminated.

什么原子性,一致性,隔离性,持久性就不说了。CouchDB不会重写你递交的数据,这个设计保证了CouchDB不会突然自己当掉。 因为这样不会产生读写冲突。

 

Document updates (add, edit, delete) are serialized, except for binary blobs which are written concurrently. Database readers are never locked out and never have to wait on writers or other readers. Any number of clients can be reading documents without being locked out or interrupted by concurrent updates, even on the same document. CouchDB read operations use a Multi-Version Concurrency Control (MVCC) model where each client sees a consistent snapshot of the database from the beginning to the end of the read operation.

CouchDB没有查询锁,就是说就算CouchDB正在写入文档,或者更新文档,或者其他人正在查询文档,你也能查询CouchDB文档。因为CouchDB采用了多版本同步控制模型MVCC来保证,每个客户端查询到的文档都是一致的。

 

Documents are indexed in b-trees by their name (DocID) and a Sequence ID. Each update to a database instance generates a new sequential number. Sequence IDs are used later for incrementally finding changes in a database. These b-tree indexes are updated simultaneously when documents are saved or deleted. The index updates always occur at the end of the file (append-only updates).

CouchDB文档索引采用B-tree算法,每次更新CouchDB都会产生一个数字,你可以根据这个数字来查找数据库的更改。当你保存或者删除了文档,文档索引都会更新。

 

 

抱歉!评论已关闭.