本文整理汇总了C++中WT_BM类的典型用法代码示例。如果您正苦于以下问题:C++ WT_BM类的具体用法?C++ WT_BM怎么用?C++ WT_BM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WT_BM类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: __wt_btree_stat_init
/*
* __wt_btree_stat_init --
* Initialize the Btree statistics.
*/
int
__wt_btree_stat_init(WT_SESSION_IMPL *session, uint32_t flags)
{
WT_BM *bm;
WT_BTREE *btree;
WT_DECL_RET;
WT_DSRC_STATS *stats;
WT_PAGE *page;
btree = S2BT(session);
bm = btree->bm;
stats = &btree->dhandle->stats;
WT_RET(bm->stat(bm, session, stats));
WT_STAT_SET(stats, btree_fixed_len, btree->bitcnt);
WT_STAT_SET(stats, btree_maximum_depth, btree->maximum_depth);
WT_STAT_SET(stats, btree_maxintlitem, btree->maxintlitem);
WT_STAT_SET(stats, btree_maxintlpage, btree->maxintlpage);
WT_STAT_SET(stats, btree_maxleafitem, btree->maxleafitem);
WT_STAT_SET(stats, btree_maxleafpage, btree->maxleafpage);
page = NULL;
if (LF_ISSET(WT_STATISTICS_FAST))
return (0);
while ((ret = __wt_tree_walk(session, &page, 0)) == 0 && page != NULL)
WT_RET(__stat_page(session, page, stats));
return (ret == WT_NOTFOUND ? 0 : ret);
}
开发者ID:umerazad,项目名称:wiredtiger,代码行数:34,代码来源:bt_stat.c
示例2: __wt_rec_track_wrapup_err
/*
* __wt_rec_track_wrapup_err --
* Resolve the page's list of tracked objects after an error occurs.
*/
int
__wt_rec_track_wrapup_err(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_BM *bm;
WT_DECL_RET;
WT_PAGE_MODIFY *mod;
WT_PAGE_TRACK *track;
uint32_t i;
bm = session->btree->bm;
/*
* After a failed reconciliation of a page, discard entries added in the
* current reconciliation, their information is incorrect, additionally,
* clear the in-use flag in preparation for the next reconciliation.
*/
mod = page->modify;
for (track = mod->track, i = 0; i < mod->track_entries; ++track, ++i)
if (F_ISSET(track, WT_TRK_JUST_ADDED)) {
/*
* The in-use flag is used to avoid discarding backing
* blocks: if an object is both just-added and in-use,
* we allocated the blocks on this run, and we want to
* discard them on error.
*/
if (F_ISSET(track, WT_TRK_INUSE))
WT_TRET(bm->free(bm, session,
track->addr.addr, track->addr.size));
__wt_free(session, track->addr.addr);
memset(track, 0, sizeof(*track));
} else
F_CLR(track, WT_TRK_INUSE);
return (ret);
}
开发者ID:tierney,项目名称:wiredtiger,代码行数:39,代码来源:rec_track.c
示例3: __meta_track_apply
/*
* __meta_track_apply --
* Apply the changes in a metadata tracking record.
*/
static int
__meta_track_apply(WT_SESSION_IMPL *session, WT_META_TRACK *trk)
{
WT_BM *bm;
WT_BTREE *btree;
WT_DECL_RET;
switch (trk->op) {
case WT_ST_EMPTY: /* Unused slot */
break;
case WT_ST_CHECKPOINT: /* Checkpoint, see above */
btree = trk->dhandle->handle;
bm = btree->bm;
WT_WITH_DHANDLE(session, trk->dhandle,
ret = bm->checkpoint_resolve(bm, session));
break;
case WT_ST_DROP_COMMIT:
if ((ret =
__wt_block_manager_drop(session, trk->a, false)) != 0)
__wt_err(session, ret,
"metadata remove dropped file %s", trk->a);
break;
case WT_ST_LOCK:
WT_WITH_DHANDLE(session, trk->dhandle,
ret = __wt_session_release_btree(session));
break;
case WT_ST_FILEOP:
case WT_ST_REMOVE:
case WT_ST_SET:
break;
}
__meta_track_clear(session, trk);
return (ret);
}
开发者ID:GYGit,项目名称:mongo,代码行数:39,代码来源:meta_track.c
示例4: __wt_btree_stat_init
/*
* __wt_btree_stat_init --
* Initialize the Btree statistics.
*/
int
__wt_btree_stat_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst)
{
WT_BM *bm;
WT_BTREE *btree;
WT_DSRC_STATS **stats;
btree = S2BT(session);
bm = btree->bm;
stats = btree->dhandle->stats;
WT_RET(bm->stat(bm, session, stats[0]));
WT_STAT_SET(session, stats, btree_fixed_len, btree->bitcnt);
WT_STAT_SET(session, stats, btree_maximum_depth, btree->maximum_depth);
WT_STAT_SET(session, stats, btree_maxintlkey, btree->maxintlkey);
WT_STAT_SET(session, stats, btree_maxintlpage, btree->maxintlpage);
WT_STAT_SET(session, stats, btree_maxleafkey, btree->maxleafkey);
WT_STAT_SET(session, stats, btree_maxleafpage, btree->maxleafpage);
WT_STAT_SET(session, stats, btree_maxleafvalue, btree->maxleafvalue);
WT_STAT_SET(session, stats, cache_bytes_inuse,
__wt_btree_bytes_inuse(session));
if (F_ISSET(cst, WT_STAT_TYPE_CACHE_WALK))
__wt_curstat_cache_walk(session);
if (F_ISSET(cst, WT_STAT_TYPE_TREE_WALK))
WT_RET(__stat_tree_walk(session));
return (0);
}
开发者ID:Machyne,项目名称:mongo,代码行数:36,代码来源:bt_stat.c
示例5: __wt_compact_page_skip
/*
* __wt_compact_page_skip --
* Return if the block-manager wants us to re-write this page.
*/
int
__wt_compact_page_skip(
WT_SESSION_IMPL *session, WT_PAGE *parent, WT_REF *ref, int *skipp)
{
WT_BM *bm;
uint32_t addr_size;
const uint8_t *addr;
bm = S2BT(session)->bm;
/*
* There's one compaction test we do before we read the page, to see
* if the block-manager thinks it useful to rewrite the page. If a
* rewrite won't help, we don't want to do I/O for nothing. For that
* reason, this check is done in a call from inside the tree-walking
* routine.
*
* Ignore everything but on-disk pages, we've already done a pass over
* the in-memory pages.
*/
if (ref->state != WT_REF_DISK) {
*skipp = 1;
return (0);
}
__wt_get_addr(parent, ref, &addr, &addr_size);
if (addr == NULL) {
*skipp = 1;
return (0);
}
return (bm->compact_page_skip(bm, session, addr, addr_size, skipp));
}
开发者ID:umerazad,项目名称:wiredtiger,代码行数:37,代码来源:bt_compact.c
示例6: __wt_compact_page_skip
/*
* __wt_compact_page_skip --
* Return if compaction requires we read this page.
*/
int
__wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp)
{
WT_BM *bm;
size_t addr_size;
u_int type;
const uint8_t *addr;
*skipp = false; /* Default to reading. */
type = 0; /* Keep compiler quiet. */
bm = S2BT(session)->bm;
/*
* We aren't holding a hazard pointer, so we can't look at the page
* itself, all we can look at is the WT_REF information. If there's no
* address, the page isn't on disk, but we have to read internal pages
* to walk the tree regardless; throw up our hands and read it.
*/
__wt_ref_info(ref, &addr, &addr_size, &type);
if (addr == NULL)
return (0);
/*
* Internal pages must be read to walk the tree; ask the block-manager
* if it's useful to rewrite leaf pages, don't do the I/O if a rewrite
* won't help.
*/
return (type == WT_CELL_ADDR_INT ? 0 :
bm->compact_page_skip(bm, session, addr, addr_size, skipp));
}
开发者ID:Arikes,项目名称:mongo,代码行数:35,代码来源:bt_compact.c
示例7: __wt_compact
/*
* __wt_compact --
* Compact a file.
*/
int
__wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_BM *bm;
WT_CONFIG_ITEM cval;
WT_DECL_RET;
WT_PAGE *page;
int trigger, skip;
bm = S2BT(session)->bm;
WT_DSTAT_INCR(session, session_compact);
WT_RET(__wt_config_gets(session, cfg, "trigger", &cval));
trigger = (int)cval.val;
/* Check if compaction might be useful. */
WT_RET(bm->compact_skip(bm, session, trigger, &skip));
if (skip)
return (0);
/*
* Walk the cache reviewing in-memory pages to see if they need to be
* re-written. This requires looking at page reconciliation results,
* which means the page cannot be reconciled at the same time as it's
* being reviewed for compaction. The underlying functions ensure we
* don't collide with page eviction, but we need to make sure we don't
* collide with checkpoints either, they are the other operation that
* can reconcile a page.
*/
__wt_spin_lock(session, &S2C(session)->metadata_lock);
WT_RET(__wt_bt_cache_op(session, NULL, WT_SYNC_COMPACT));
__wt_spin_unlock(session, &S2C(session)->metadata_lock);
/*
* Walk the tree, reviewing on-disk pages to see if they need to be
* re-written.
*/
for (page = NULL;;) {
WT_RET(__wt_tree_walk(session, &page, WT_TREE_COMPACT));
if (page == NULL)
break;
/*
* The only pages returned by the tree walk function are pages
* we want to re-write; mark the page and tree dirty.
*/
if ((ret = __wt_page_modify_init(session, page)) != 0) {
WT_TRET(__wt_page_release(session, page));
WT_RET(ret);
}
__wt_page_and_tree_modify_set(session, page);
WT_DSTAT_INCR(session, btree_compact_rewrite);
}
return (0);
}
开发者ID:umerazad,项目名称:wiredtiger,代码行数:62,代码来源:bt_compact.c
示例8: __ovfl_reuse_wrapup_err
/*
* __ovfl_reuse_wrapup_err --
* Resolve the page's overflow reuse list after an error occurs.
*/
static int
__ovfl_reuse_wrapup_err(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_BM *bm;
WT_DECL_RET;
WT_OVFL_REUSE **e, **head, *reuse;
size_t decr;
int i;
bm = S2BT(session)->bm;
head = page->modify->ovfl_track->ovfl_reuse;
/*
* Discard any overflow records that were just added, freeing underlying
* blocks.
*
* First, walk the overflow reuse lists (except for the lowest one),
* fixing up skiplist links.
*/
for (i = WT_SKIP_MAXDEPTH - 1; i > 0; --i)
for (e = &head[i]; (reuse = *e) != NULL;) {
if (!F_ISSET(reuse, WT_OVFL_REUSE_JUST_ADDED)) {
e = &reuse->next[i];
continue;
}
*e = reuse->next[i];
}
/*
* Second, discard any overflow record with a just-added flag, clear the
* flags for the next run.
*/
decr = 0;
for (e = &head[0]; (reuse = *e) != NULL;) {
if (!F_ISSET(reuse, WT_OVFL_REUSE_JUST_ADDED)) {
F_CLR(reuse, WT_OVFL_REUSE_INUSE);
e = &reuse->next[0];
continue;
}
*e = reuse->next[0];
if (WT_VERBOSE_ISSET(session, WT_VERB_OVERFLOW))
WT_RET(
__ovfl_reuse_verbose(session, page, reuse, "free"));
WT_TRET(bm->free(
bm, session, WT_OVFL_REUSE_ADDR(reuse), reuse->addr_size));
decr += WT_OVFL_SIZE(reuse, WT_OVFL_REUSE);
__wt_free(session, reuse);
}
if (decr != 0)
__wt_cache_page_inmem_decr(session, page, decr);
return (0);
}
开发者ID:Andiry,项目名称:mongo,代码行数:59,代码来源:rec_track.c
示例9: __compact_rewrite
/*
* __compact_rewrite --
* Return if a page needs to be re-written.
*/
static int
__compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp)
{
WT_BM *bm;
WT_DECL_RET;
WT_PAGE *page;
WT_PAGE_MODIFY *mod;
size_t addr_size;
const uint8_t *addr;
*skipp = true; /* Default skip. */
bm = S2BT(session)->bm;
page = ref->page;
mod = page->modify;
/*
* Ignore the root: it may not have a replacement address, and besides,
* if anything else gets written, so will it.
*/
if (__wt_ref_is_root(ref))
return (0);
/* Ignore currently dirty pages, they will be written regardless. */
if (__wt_page_is_modified(page))
return (0);
/*
* If the page is clean, test the original addresses.
* If the page is a 1-to-1 replacement, test the replacement addresses.
* Ignore empty pages, they get merged into the parent.
*/
if (mod == NULL || mod->rec_result == 0) {
WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, NULL));
if (addr == NULL)
return (0);
WT_RET(
bm->compact_page_skip(bm, session, addr, addr_size, skipp));
} else if (mod->rec_result == WT_PM_REC_REPLACE) {
/*
* The page's modification information can change underfoot if
* the page is being reconciled, serialize with reconciliation.
*/
WT_RET(__wt_fair_lock(session, &page->page_lock));
ret = bm->compact_page_skip(bm, session,
mod->mod_replace.addr, mod->mod_replace.size, skipp);
WT_TRET(__wt_fair_unlock(session, &page->page_lock));
WT_RET(ret);
}
return (0);
}
开发者ID:Zhangwusheng,项目名称:wiredtiger,代码行数:57,代码来源:bt_compact.c
示例10: __wt_btree_stat_init
/*
* __wt_btree_stat_init --
* Initialize the Btree statistics.
*/
int
__wt_btree_stat_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst)
{
WT_BM *bm;
WT_BTREE *btree;
WT_DECL_RET;
WT_DSRC_STATS **stats;
WT_REF *next_walk;
btree = S2BT(session);
bm = btree->bm;
stats = btree->dhandle->stats;
WT_RET(bm->stat(bm, session, stats[0]));
WT_STAT_SET(session, stats, btree_fixed_len, btree->bitcnt);
WT_STAT_SET(session, stats, btree_maximum_depth, btree->maximum_depth);
WT_STAT_SET(session, stats, btree_maxintlkey, btree->maxintlkey);
WT_STAT_SET(session, stats, btree_maxintlpage, btree->maxintlpage);
WT_STAT_SET(session, stats, btree_maxleafkey, btree->maxleafkey);
WT_STAT_SET(session, stats, btree_maxleafpage, btree->maxleafpage);
WT_STAT_SET(session, stats, btree_maxleafvalue, btree->maxleafvalue);
/* Everything else is really, really expensive. */
if (!F_ISSET(cst, WT_CONN_STAT_ALL))
return (0);
/*
* Clear the statistics we're about to count.
*/
WT_STAT_SET(session, stats, btree_column_deleted, 0);
WT_STAT_SET(session, stats, btree_column_fix, 0);
WT_STAT_SET(session, stats, btree_column_internal, 0);
WT_STAT_SET(session, stats, btree_column_rle, 0);
WT_STAT_SET(session, stats, btree_column_variable, 0);
WT_STAT_SET(session, stats, btree_entries, 0);
WT_STAT_SET(session, stats, btree_overflow, 0);
WT_STAT_SET(session, stats, btree_row_internal, 0);
WT_STAT_SET(session, stats, btree_row_leaf, 0);
next_walk = NULL;
while ((ret = __wt_tree_walk(
session, &next_walk, 0)) == 0 && next_walk != NULL) {
WT_WITH_PAGE_INDEX(session,
ret = __stat_page(session, next_walk->page, stats));
WT_RET(ret);
}
return (ret == WT_NOTFOUND ? 0 : ret);
}
开发者ID:sylvanchil,项目名称:mongo,代码行数:53,代码来源:bt_stat.c
示例11: __wt_addr_string
/*
* __wt_addr_string --
* Load a buffer with a printable, nul-terminated representation of an
* address.
*/
const char *
__wt_addr_string(
WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, uint32_t size)
{
WT_BM *bm;
bm = S2BT(session)->bm;
if (addr == NULL) {
buf->data = "[NoAddr]";
buf->size = WT_STORE_SIZE(strlen("[NoAddr]"));
} else if (bm->addr_string(bm, session, buf, addr, size) != 0) {
buf->data = "[Error]";
buf->size = WT_STORE_SIZE(strlen("[Error]"));
}
return (buf->data);
}
开发者ID:RolfAndreassen,项目名称:wiredtiger,代码行数:22,代码来源:bt_misc.c
示例12: __wt_ovfl_discard
/*
* __wt_ovfl_discard --
* Discard an on-page overflow value, and reset the page's cell.
*/
int
__wt_ovfl_discard(WT_SESSION_IMPL *session, WT_CELL *cell)
{
WT_BM *bm;
WT_BTREE *btree;
WT_CELL_UNPACK *unpack, _unpack;
WT_DECL_RET;
btree = S2BT(session);
bm = btree->bm;
unpack = &_unpack;
__wt_cell_unpack(cell, unpack);
/*
* Finally remove overflow key/value objects, called when reconciliation
* finishes after successfully writing a page.
*
* Keys must have already been instantiated and value objects must have
* already been cached (if they might potentially still be read by any
* running transaction).
*
* Acquire the overflow lock to avoid racing with a thread reading the
* backing overflow blocks.
*/
WT_RET(__wt_writelock(session, btree->ovfl_lock));
switch (unpack->raw) {
case WT_CELL_KEY_OVFL:
__wt_cell_type_reset(session,
unpack->cell, WT_CELL_KEY_OVFL, WT_CELL_KEY_OVFL_RM);
break;
case WT_CELL_VALUE_OVFL:
__wt_cell_type_reset(session,
unpack->cell, WT_CELL_VALUE_OVFL, WT_CELL_VALUE_OVFL_RM);
break;
WT_ILLEGAL_VALUE(session);
}
WT_TRET(__wt_writeunlock(session, btree->ovfl_lock));
/* Free the backing disk blocks. */
WT_TRET(bm->free(bm, session, unpack->data, unpack->size));
return (ret);
}
开发者ID:qihsh,项目名称:mongo,代码行数:50,代码来源:bt_ovfl.c
示例13: __wt_debug_addr
/*
* __wt_debug_addr --
* Read and dump a disk page in debugging mode, using an addr/size pair.
*/
int
__wt_debug_addr(WT_SESSION_IMPL *session,
const uint8_t *addr, size_t addr_size, const char *ofile)
{
WT_BM *bm;
WT_DECL_ITEM(buf);
WT_DECL_RET;
bm = S2BT(session)->bm;
WT_RET(__wt_scr_alloc(session, 1024, &buf));
WT_ERR(bm->read(bm, session, buf, addr, addr_size));
ret = __wt_debug_disk(session, buf->mem, ofile);
err: __wt_scr_free(session, &buf);
return (ret);
}
开发者ID:Andiry,项目名称:mongo,代码行数:21,代码来源:bt_debug.c
示例14: __wt_addr_string
/*
* __wt_addr_string --
* Load a buffer with a printable, nul-terminated representation of an
* address.
*/
const char *
__wt_addr_string(WT_SESSION_IMPL *session,
const uint8_t *addr, size_t addr_size, WT_ITEM *buf)
{
WT_BM *bm;
WT_BTREE *btree;
btree = S2BT_SAFE(session);
if (addr == NULL) {
buf->data = "[NoAddr]";
buf->size = strlen("[NoAddr]");
} else if (btree == NULL || (bm = btree->bm) == NULL ||
bm->addr_string(bm, session, buf, addr, addr_size) != 0) {
buf->data = "[Error]";
buf->size = strlen("[Error]");
}
return (buf->data);
}
开发者ID:Zhangwusheng,项目名称:wiredtiger,代码行数:24,代码来源:bt_misc.c
示例15: __cursor_size_chk
/*
* __cursor_size_chk --
* Return if an inserted item is too large.
*/
static inline int
__cursor_size_chk(WT_SESSION_IMPL *session, WT_ITEM *kv)
{
WT_BM *bm;
WT_BTREE *btree;
WT_DECL_RET;
size_t size;
btree = S2BT(session);
bm = btree->bm;
if (btree->type == BTREE_COL_FIX) {
/* Fixed-size column-stores take a single byte. */
if (kv->size != 1)
WT_RET_MSG(session, EINVAL,
"item size of %" WT_SIZET_FMT " does not match "
"fixed-length file requirement of 1 byte",
kv->size);
return (0);
}
/* Don't waste effort, 1GB is always cool. */
if (kv->size <= WT_GIGABYTE)
return (0);
/*
* There are two checks: what we are willing to store in the tree, and
* what the block manager can actually write.
*/
if (kv->size > WT_BTREE_MAX_OBJECT_SIZE)
ret = EINVAL;
else {
size = kv->size;
ret = bm->write_size(bm, session, &size);
}
if (ret != 0)
WT_RET_MSG(session, ret,
"item size of %" WT_SIZET_FMT " exceeds the maximum "
"supported size",
kv->size);
return (0);
}
开发者ID:3rf,项目名称:mongo,代码行数:46,代码来源:bt_cursor.c
示例16: __wt_block_manager_open
/*
* __wt_block_manager_open --
* Open a file.
*/
int
__wt_block_manager_open(WT_SESSION_IMPL *session,
const char *filename, const char *cfg[], int forced_salvage, WT_BM **bmp)
{
WT_BM *bm;
WT_DECL_RET;
*bmp = NULL;
WT_RET(__wt_calloc_def(session, 1, &bm));
__bm_method_set(bm, 0);
WT_ERR(__wt_block_open(
session, filename, cfg, forced_salvage, &bm->block));
*bmp = bm;
return (0);
err: WT_TRET(bm->close(bm, session));
return (ret);
}
开发者ID:niumowm,项目名称:wiredtiger,代码行数:25,代码来源:block_mgr.c
示例17: __wt_block_manager_open
/*
* __wt_block_manager_open --
* Open a file.
*/
int
__wt_block_manager_open(WT_SESSION_IMPL *session,
const char *filename, const char *cfg[],
bool forced_salvage, bool readonly, uint32_t allocsize, WT_BM **bmp)
{
WT_BM *bm;
WT_DECL_RET;
*bmp = NULL;
WT_RET(__wt_calloc_one(session, &bm));
__bm_method_set(bm, false);
WT_ERR(__wt_block_open(session, filename, cfg,
forced_salvage, readonly, allocsize, &bm->block));
*bmp = bm;
return (0);
err: WT_TRET(bm->close(bm, session));
return (ret);
}
开发者ID:BobbWu,项目名称:wiredtiger,代码行数:26,代码来源:block_mgr.c
示例18: __compact_rewrite
/*将多余的文件空间compact到合适的位置,如果ref在compact范围内,返回skip = 1,表示文件空间不能进行compact*/
static int __compact_rewrite(WT_SESSION_IMPL* session, WT_REF* ref, int* skipp)
{
WT_BM *bm;
WT_DECL_RET;
WT_PAGE *page;
WT_PAGE_MODIFY *mod;
size_t addr_size;
const uint8_t *addr;
*skipp = 1;
bm = S2BT(session)->bm;
page = ref->page;
mod = page->modify;
/*root page是不能被compact*/
if (__wt_ref_is_root(ref))
return 0;
/*ref指向的是个脏页,不进行compact*/
if (__wt_page_is_modified(page))
return (0);
/*假如page一已经被清空的,直接判断是否可以它的block空间compact*/
if (mod == NULL || F_ISSET(mod, WT_PM_REC_MASK) == 0) {
WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, NULL));
if (addr == NULL)
return (0);
WT_RET(bm->compact_page_skip(bm, session, addr, addr_size, skipp));
}
else if (F_ISSET(mod, WT_PM_REC_MASK) == WT_PM_REC_REPLACE){ /*如果page空间是替换,那么进行替换block的compact操作判断*/
WT_PAGE_LOCK(session, page);
ret = bm->compact_page_skip(bm, session, mod->mod_replace.addr, mod->mod_replace.size, skipp);
WT_PAGE_UNLOCK(session, page);
WT_RET(ret);
}
return 0;
}
开发者ID:rain10154,项目名称:wiredtiger,代码行数:40,代码来源:bt_compact.c
示例19: __wt_compact_page_skip
/*在读取ref对应的page时,检查它是否需要compact*/
int __wt_compact_page_skip(WT_SESSION_IMPL* session, WT_REF* ref, int* skipp)
{
WT_BM *bm;
size_t addr_size;
u_int type;
const uint8_t *addr;
*skipp = 0;
type = 0;
bm = S2BT(session)->bm;
/*
* We aren't holding a hazard pointer, so we can't look at the page
* itself, all we can look at is the WT_REF information. If there's no
* address, the page isn't on disk, but we have to read internal pages
* to walk the tree regardless; throw up our hands and read it.
*/
WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, &type));
if (addr == NULL)
return 0;
return (type == WT_CELL_ADDR_INT ? 0 : bm->compact_page_skip(bm, session, addr, addr_size, skipp));
}
开发者ID:rain10154,项目名称:wiredtiger,代码行数:25,代码来源:bt_compact.c
示例20: __wt_bt_write
/*
* __wt_bt_write --
* Write a buffer into a block, returning the block's addr/size and
* checksum.
*/
int
__wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf,
uint8_t *addr, size_t *addr_sizep, bool checkpoint, bool compressed)
{
WT_BM *bm;
WT_BTREE *btree;
WT_ITEM *ip;
WT_DECL_ITEM(tmp);
WT_DECL_RET;
WT_PAGE_HEADER *dsk;
size_t dst_len, len, result_len, size, src_len;
int compression_failed; /* Extension API, so not a bool. */
uint8_t *dst, *src;
bool data_cksum;
btree = S2BT(session);
bm = btree->bm;
/* Checkpoint calls are different than standard calls. */
WT_ASSERT(session,
(!checkpoint && addr != NULL && addr_sizep != NULL) ||
(checkpoint && addr == NULL && addr_sizep == NULL));
#ifdef HAVE_DIAGNOSTIC
/*
* We're passed a table's disk image. Decompress if necessary and
* verify the image. Always check the in-memory length for accuracy.
*/
dsk = buf->mem;
if (compressed) {
WT_ERR(__wt_scr_alloc(session, dsk->mem_size, &tmp));
memcpy(tmp->mem, buf->data, WT_BLOCK_COMPRESS_SKIP);
WT_ERR(btree->compressor->decompress(
btree->compressor, &session->iface,
(uint8_t *)buf->data + WT_BLOCK_COMPRESS_SKIP,
buf->size - WT_BLOCK_COMPRESS_SKIP,
(uint8_t *)tmp->data + WT_BLOCK_COMPRESS_SKIP,
tmp->memsize - WT_BLOCK_COMPRESS_SKIP,
&result_len));
WT_ASSERT(session,
dsk->mem_size == result_len + WT_BLOCK_COMPRESS_SKIP);
tmp->size = (uint32_t)result_len + WT_BLOCK_COMPRESS_SKIP;
ip = tmp;
} else {
WT_ASSERT(session, dsk->mem_size == buf->size);
ip = buf;
}
WT_ERR(__wt_verify_dsk(session, "[write-check]", ip));
__wt_scr_free(session, &tmp);
#endif
/*
* Optionally stream-compress the data, but don't compress blocks that
* are already as small as they're going to get.
*/
if (btree->compressor == NULL ||
btree->compressor->compress == NULL || compressed)
ip = buf;
else if (buf->size <= btree->allocsize) {
ip = buf;
WT_STAT_FAST_DATA_INCR(session, compress_write_too_small);
} else {
/* Skip the header bytes of the source data. */
src = (uint8_t *)buf->mem + WT_BLOCK_COMPRESS_SKIP;
src_len = buf->size - WT_BLOCK_COMPRESS_SKIP;
/*
* Compute the size needed for the destination buffer. We only
* allocate enough memory for a copy of the original by default,
* if any compressed version is bigger than the original, we
* won't use it. However, some compression engines (snappy is
* one example), may need more memory because they don't stop
* just because there's no more memory into which to compress.
*/
if (btree->compressor->pre_size == NULL)
len = src_len;
else
WT_ERR(btree->compressor->pre_size(btree->compressor,
&session->iface, src, src_len, &len));
size = len + WT_BLOCK_COMPRESS_SKIP;
WT_ERR(bm->write_size(bm, session, &size));
WT_ERR(__wt_scr_alloc(session, size, &tmp));
/* Skip the header bytes of the destination data. */
dst = (uint8_t *)tmp->mem + WT_BLOCK_COMPRESS_SKIP;
dst_len = len;
compression_failed = 0;
WT_ERR(btree->compressor->compress(btree->compressor,
&session->iface,
src, src_len,
dst, dst_len,
&result_len, &compression_failed));
//.........这里部分代码省略.........
开发者ID:DavidAlphaFox,项目名称:mongodb,代码行数:101,代码来源:bt_io.c
注:本文中的WT_BM类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论