예제 #1
0
/*
 * __apply_idx --
 *	Apply an operation to all indices of a table.
 */
static int
__apply_idx(WT_CURSOR_TABLE *ctable, size_t func_off, bool skip_immutable) {
	WT_CURSOR **cp;
	WT_INDEX *idx;
	WT_SESSION_IMPL *session;
	int (*f)(WT_CURSOR *);
	u_int i;

	cp = ctable->idx_cursors;
	session = (WT_SESSION_IMPL *)ctable->iface.session;

	for (i = 0; i < ctable->table->nindices; i++, cp++) {
		idx = ctable->table->indices[i];
		if (skip_immutable && F_ISSET(idx, WT_INDEX_IMMUTABLE))
			continue;

		f = *(int (**)(WT_CURSOR *))((uint8_t *)*cp + func_off);
		WT_RET(__wt_apply_single_idx(session, idx, *cp, ctable, f));
		WT_RET((*cp)->reset(*cp));
	}

	return (0);
}
예제 #2
0
/*
 * __fill_index --
 *	Fill the index from the current contents of the table.
 */
static int
__fill_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx)
{
	WT_DECL_RET;
	WT_CURSOR *tcur, *icur;
	WT_SESSION *wt_session;

	wt_session = &session->iface;
	tcur = NULL;
	icur = NULL;
	WT_RET(__wt_schema_open_colgroups(session, table));

	/*
	 * If the column groups have not been completely created,
	 * there cannot be data inserted yet, and we're done.
	 */
	if (!table->cg_complete)
		return (0);

	WT_ERR(wt_session->open_cursor(wt_session,
	    idx->source, NULL, "bulk=unordered", &icur));
	WT_ERR(wt_session->open_cursor(wt_session,
	    table->name, NULL, "readonly", &tcur));

	while ((ret = tcur->next(tcur)) == 0)
		WT_ERR(__wt_apply_single_idx(session, idx,
		    icur, (WT_CURSOR_TABLE *)tcur, icur->insert));

	WT_ERR_NOTFOUND_OK(ret);
err:
	if (icur)
		WT_TRET(icur->close(icur));
	if (tcur)
		WT_TRET(tcur->close(tcur));
	return (ret);
}