Exemplo n.º 1
0
/*
 * __curdump_get_key --
 *	WT_CURSOR->get_key for dump cursors.
 */
static int
__curdump_get_key(WT_CURSOR *cursor, ...)
{
	WT_CURSOR *child;
	WT_CURSOR_DUMP *cdump;
	WT_DECL_RET;
	WT_ITEM item, *itemp;
	WT_SESSION_IMPL *session;
	uint64_t recno;
	va_list ap;

	cdump = (WT_CURSOR_DUMP *)cursor;
	child = cdump->child;
	CURSOR_API_CALL(cursor, session, get_key, NULL);

	if (WT_CURSOR_RECNO(cursor) && !F_ISSET(cursor, WT_CURSTD_RAW)) {
		WT_ERR(child->get_key(child, &recno));

		WT_ERR(__wt_buf_fmt(session, &cursor->key, "%" PRIu64, recno));
	} else {
		WT_ERR(child->get_key(child, &item));

		WT_ERR(__raw_to_dump(session, &item,
		    &cursor->key, F_ISSET(cursor, WT_CURSTD_DUMP_HEX) ? 1 : 0));
	}

	va_start(ap, cursor);
	if (F_ISSET(cursor, WT_CURSTD_RAW)) {
		itemp = va_arg(ap, WT_ITEM *);
		itemp->data = cursor->key.data;
		itemp->size = cursor->key.size;
	} else
Exemplo n.º 2
0
/*
 * __curdump_get_key --
 *	WT_CURSOR->get_key for dump cursors.
 */
static int
__curdump_get_key(WT_CURSOR *cursor, ...)
{
	WT_CURSOR *child;
	WT_CURSOR_DUMP *cdump;
	WT_CURSOR_JSON *json;
	WT_DECL_RET;
	WT_ITEM item, *itemp;
	WT_SESSION_IMPL *session;
	size_t size;
	uint64_t recno;
	const char *fmt;
	const void *buffer;
	va_list ap;

	cdump = (WT_CURSOR_DUMP *)cursor;
	child = cdump->child;

	va_start(ap, cursor);
	CURSOR_API_CALL(cursor, session, get_key, NULL);

	if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) {
		json = (WT_CURSOR_JSON *)cursor->json_private;
		WT_ASSERT(session, json != NULL);
		if (WT_CURSOR_RECNO(cursor)) {
			WT_ERR(child->get_key(child, &recno));
			buffer = &recno;
			size = sizeof(recno);
			fmt = "R";
		} else {
			WT_ERR(__wt_cursor_get_raw_key(child, &item));
			buffer = item.data;
			size = item.size;
			if (F_ISSET(cursor, WT_CURSTD_RAW))
				fmt = "u";
			else
				fmt = cursor->key_format;
		}
		ret = __wt_json_alloc_unpack(
		    session, buffer, size, fmt, json, true, ap);
	} else {
		if (WT_CURSOR_RECNO(cursor) &&
		    !F_ISSET(cursor, WT_CURSTD_RAW)) {
			WT_ERR(child->get_key(child, &recno));

			WT_ERR(__wt_buf_fmt(session, &cursor->key, "%"
			    PRIu64, recno));
		} else {
			WT_ERR(child->get_key(child, &item));

			WT_ERR(__raw_to_dump(session, &item, &cursor->key,
			    F_ISSET(cursor, WT_CURSTD_DUMP_HEX)));
		}

		if (F_ISSET(cursor, WT_CURSTD_RAW)) {
			itemp = va_arg(ap, WT_ITEM *);
			itemp->data = cursor->key.data;
			itemp->size = cursor->key.size;
		} else
			*va_arg(ap, const char **) = cursor->key.data;
	}