14. • Keys and values are arbitrary byte arrays.
• Data is stored sorted by key.
• The basic operations are Put(key,value),
Get(key), Delete(key).
• Multiple changes can be made in one atomic
batch.
• Users can create a transient snapshot to get
a consistent view of data.
• Forward and backward iteration is supported
over the data.
• Data is automatically compressed using the
Snappy compression library.
15. • Keys and values are arbitrary byte arrays.
• Data is stored sorted by key.
• The basic operations are Put(key,value),
Get(key), Delete(key).
• Multiple changes can be made in one atomic
batch.
• Users can create a transient snapshot to get
a consistent view of data.
• Forward and backward iteration is supported
over the data.
• Data is automatically compressed using the
Snappy compression library.
16. std::string value;
leveldb::Status s =
db->Get(
leveldb::ReadOptions(),
key1,
&value);
s = db->Put(
leveldb::WriteOptions(),
key2,
value);
s = db->Delete(
leveldb::WriteOptions(),
key1);
17. • Keys and values are arbitrary byte arrays.
• Data is stored sorted by key.
• The basic operations are Put(key,value),
simple key/value store와 다른 특징.
Get(key), Delete(key).
a persistent ordered map
• Multiple changes can be made in one atomic
custom comparison function 지원.
batch. range query가 싸겠다.
• Users can create a transient iteration이 가능 get
이런 특징 때문에 snapshot to
a consistent view of data.
• Forward and backward iteration is supported
over the data.
• Data is automatically compressed using the
Snappy compression library.
18. // DB에 있는 모든 key/value 순회
leveldb::Iterator* it =
db->NewIterator(leveldb::ReadOptions());
for (it->SeekToFirst();
it->Valid(); it->Next())
{
cout << it->key().ToString() << ": “ <<
it->value().ToString() << endl;
}
19. • Keys and values are arbitrary byte arrays.
• Data is stored sorted by key.
• The basic operations are Put(key,value),
Get(key), Delete(key).
• Multiple changes can be made in one atomic
batch.
• Users can create a transient snapshot to get
a consistent view of data.
• Forward and backward iteration is supported
over the data.
• Data is automatically compressed using the
Snappy compression library.
20. leveldb::ReadOptions options;
options.snapshot = db->GetSnapshot();
//…
// db를 업데이트한다.
leveldb::Iterator* iter = db->NewIterator(options);
// 업데이트를 하기 전 Shapshot DB를 읽는다.
delete iter;
db->ReleaseSnapshot(options.snapshot);