Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
( )
> GET /that/money
(wait for a few ms)
( )
> GET /that/money
(wait for a few ms)
{
GET /my_db/some_id
{
"_id": "some_id",
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
"and arrays": ["ain't", "it", "cool?"],
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
"and arrays": ["ain't", "it", "cool?"],
"dicts too!": { "don't":"try",
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
"and arrays": ["ain't", "it", "cool?"],
"dicts too!": { "don't":"try",
"this":"in",
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
"and arrays": ["ain't", "it", "cool?"],
"dicts too!": { "don't":"try",
"this":"in",
"Oracle!":null }
GET /my_db/some_id
{
"_id": "some_id",
"_rev": "1-24c8785964763c21d...",
"my_field1": "json does strings",
"numbers too": 123.12,
"and arrays": ["ain't", "it", "cool?"],
"dicts too!": { "don't":"try",
"this":"in",
"Oracle!":null }
}
Schema-less
How do I know what a
document means??
Duck-type your database
Duck-typing
def document_factory(doc):
def document_factory(doc):
if doc['look'] == Duck.look()
def document_factory(doc):
if doc['look'] == Duck.look()
and doc['swim'] == Duck.swim()
def document_factory(doc):
if doc['look'] == Duck.look()
and doc['swim'] == Duck.swim()
and doc['quack'] == Duck.quack():
def document_factory(doc):
if doc['look'] == Duck.look()
and doc['swim'] == Duck.swim()
and doc['quack'] == Duck.quack():
return Duck(doc)
def document_factory(doc):
def document_factory(doc):
if doc['type'] == 'Duck':
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
return Dog(doc)
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
return Dog(doc)
elif ...:
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
return Dog(doc)
elif ...:
...
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
return Dog(doc)
elif ...:
...
else:
def document_factory(doc):
if doc['type'] == 'Duck':
return Duck(doc)
elif doc['type'] == 'Dog':
return Dog(doc)
elif ...:
...
else:
return GenericDocument(doc)
def document_factory(doc):
def document_factory(doc):
import document_types
def document_factory(doc):
import document_types
doc_class = getattr(doc, doc['type'],
def document_factory(doc):
import document_types
doc_class = getattr(doc, doc['type'],
'GenericDocument')
def document_factory(doc):
import document_types
doc_class = getattr(doc, doc['type'],
'GenericDocument')
return doc_class(doc)
function map(doc) {
if (doc['type'] == 'person') {
emit(doc['name'], doc);
}
}
function map(doc) {
if (doc['type'] == 'person') {
emit(doc['name'], doc);
}
}
SELECT * FROM (
SELECT p.*, rownum rn
FROM people p ORDER BY name ASC
) WHERE rn BETWEEN 50 AND 60
SELECT * FROM (
SELECT p.*, rownum rn
FROM people p ORDER BY name ASC
) WHERE rn BETWEEN 50 AND 60
GET /people?reduce=false&limit=10&skip=50
function map(doc) {
for (i in doc['comment_ids']) {
var comment_id = doc['comment_ids'][i];
emit(doc['_id'], {'_id': comment_id });
}
}
GET /myblog/comments?
reduce=false&include_docs=true
GET /myblog/comments?
reduce=false&include_docs=true
[
{'key': 1, 'value': {'_id': 3, 'text': 'whoa'}},
{'key': 1, 'value': {'_id': 4, 'text': 'omg'}},
{'key': 5, 'value': {'_id': 5, 'text': 'ponies'}}
]
Cluster?
Replication!
Incremental,
Cluster?
Replication!
Incremental,
Fault Tolerant,
Cluster?
Replication!
Incremental,
Fault Tolerant,
Over HTTP
Cluster?
replication is expensive
replication is expensive
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
• Performance benchmarks