summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2016-03-11 12:21:51 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2016-03-11 12:21:51 +1100
commitccb81f359eb56649978621c6f1ddcfe7e68e1f48 (patch)
tree6273f6ad280656e4fb00ff2f38104aaa05e2d18d /src
parent1f9ccd49f1040161aaa94acda4ba7e7359d5978a (diff)
downloadmongo-ccb81f359eb56649978621c6f1ddcfe7e68e1f48.tar.gz
WT-2404 Make pack/unpack extension API consistent.
Diffstat (limited to 'src')
-rw-r--r--src/include/extern.h22
-rw-r--r--src/include/wiredtiger_ext.h33
-rw-r--r--src/packing/pack_stream.c50
3 files changed, 70 insertions, 35 deletions
diff --git a/src/include/extern.h b/src/include/extern.h
index 0774a14f382..e6b00189de1 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -558,17 +558,17 @@ extern int __wt_struct_size(WT_SESSION_IMPL *session, size_t *sizep, const char
extern int __wt_struct_pack(WT_SESSION_IMPL *session, void *buffer, size_t size, const char *fmt, ...);
extern int __wt_struct_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, ...);
extern int __wt_struct_repack(WT_SESSION_IMPL *session, const char *infmt, const char *outfmt, const WT_ITEM *inbuf, WT_ITEM *outbuf);
-extern int __wt_ext_pack_start(WT_SESSION *session, const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp);
-extern int __wt_ext_unpack_start(WT_SESSION *session, const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp);
-extern int __wt_ext_pack_close(WT_PACK_STREAM *ps, size_t *usedp);
-extern int __wt_ext_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
-extern int __wt_ext_pack_int(WT_PACK_STREAM *ps, int64_t i);
-extern int __wt_ext_pack_str(WT_PACK_STREAM *ps, const char *s);
-extern int __wt_ext_pack_uint(WT_PACK_STREAM *ps, uint64_t u);
-extern int __wt_ext_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item);
-extern int __wt_ext_unpack_int(WT_PACK_STREAM *ps, int64_t *ip);
-extern int __wt_ext_unpack_str(WT_PACK_STREAM *ps, const char **sp);
-extern int __wt_ext_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up);
+extern int __wt_ext_pack_start(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *format, void *buffer, size_t size, WT_PACK_STREAM **psp);
+extern int __wt_ext_unpack_start(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *format, const void *buffer, size_t size, WT_PACK_STREAM **psp);
+extern int __wt_ext_pack_close(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, size_t *usedp);
+extern int __wt_ext_pack_item(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item);
+extern int __wt_ext_pack_int(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t i);
+extern int __wt_ext_pack_str(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char *s);
+extern int __wt_ext_pack_uint(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t u);
+extern int __wt_ext_unpack_item(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item);
+extern int __wt_ext_unpack_int(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t *ip);
+extern int __wt_ext_unpack_str(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char **sp);
+extern int __wt_ext_unpack_uint(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t *up);
extern int __wt_ovfl_discard_add(WT_SESSION_IMPL *session, WT_PAGE *page, WT_CELL *cell);
extern void __wt_ovfl_discard_free(WT_SESSION_IMPL *session, WT_PAGE *page);
extern int __wt_ovfl_reuse_search(WT_SESSION_IMPL *session, WT_PAGE *page, uint8_t **addrp, size_t *addr_sizep, const void *value, size_t value_size);
diff --git a/src/include/wiredtiger_ext.h b/src/include/wiredtiger_ext.h
index 7271bf6ba9d..011d85fda02 100644
--- a/src/include/wiredtiger_ext.h
+++ b/src/include/wiredtiger_ext.h
@@ -323,7 +323,8 @@ struct __wt_extension_api {
* @param[out] psp the new packing stream handle
* @errors
*/
- int (*pack_start)(WT_SESSION *session, const char *format,
+ int (*pack_start)(WT_EXTENSION_API *wt_api,
+ WT_SESSION *session, const char *format,
void *buffer, size_t size, WT_PACK_STREAM **psp);
/*!
@@ -337,7 +338,8 @@ struct __wt_extension_api {
* @param[out] psp the new packing stream handle
* @errors
*/
- int (*unpack_start)(WT_SESSION *session, const char *format,
+ int (*unpack_start)(WT_EXTENSION_API *wt_api,
+ WT_SESSION *session, const char *format,
const void *buffer, size_t size, WT_PACK_STREAM **psp);
/*!
@@ -348,7 +350,8 @@ struct __wt_extension_api {
* stream
* @errors
*/
- int (*pack_close)(WT_PACK_STREAM *ps, size_t *usedp);
+ int (*pack_close)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, size_t *usedp);
/*!
* Pack an item into a packing stream.
@@ -357,7 +360,8 @@ struct __wt_extension_api {
* @param item an item to pack
* @errors
*/
- int (*pack_item)(WT_PACK_STREAM *ps, WT_ITEM *item);
+ int (*pack_item)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, WT_ITEM *item);
/*!
* Pack a signed integer into a packing stream.
@@ -366,7 +370,8 @@ struct __wt_extension_api {
* @param i a signed integer to pack
* @errors
*/
- int (*pack_int)(WT_PACK_STREAM *ps, int64_t i);
+ int (*pack_int)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, int64_t i);
/*!
* Pack a string into a packing stream.
@@ -375,7 +380,8 @@ struct __wt_extension_api {
* @param s a string to pack
* @errors
*/
- int (*pack_str)(WT_PACK_STREAM *ps, const char *s);
+ int (*pack_str)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, const char *s);
/*!
* Pack an unsigned integer into a packing stream.
@@ -384,7 +390,8 @@ struct __wt_extension_api {
* @param u an unsigned integer to pack
* @errors
*/
- int (*pack_uint)(WT_PACK_STREAM *ps, uint64_t u);
+ int (*pack_uint)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, uint64_t u);
/*!
* Unpack an item from a packing stream.
@@ -393,7 +400,8 @@ struct __wt_extension_api {
* @param item an item to unpack
* @errors
*/
- int (*unpack_item)(WT_PACK_STREAM *ps, WT_ITEM *item);
+ int (*unpack_item)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, WT_ITEM *item);
/*!
* Unpack a signed integer from a packing stream.
@@ -402,7 +410,8 @@ struct __wt_extension_api {
* @param[out] ip the unpacked signed integer
* @errors
*/
- int (*unpack_int)(WT_PACK_STREAM *ps, int64_t *ip);
+ int (*unpack_int)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, int64_t *ip);
/*!
* Unpack a string from a packing stream.
@@ -411,7 +420,8 @@ struct __wt_extension_api {
* @param[out] sp the unpacked string
* @errors
*/
- int (*unpack_str)(WT_PACK_STREAM *ps, const char **sp);
+ int (*unpack_str)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, const char **sp);
/*!
* Unpack an unsigned integer from a packing stream.
@@ -420,7 +430,8 @@ struct __wt_extension_api {
* @param[out] up the unpacked unsigned integer
* @errors
*/
- int (*unpack_uint)(WT_PACK_STREAM *ps, uint64_t *up);
+ int (*unpack_uint)(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, uint64_t *up);
/*!
* Return the current transaction ID.
diff --git a/src/packing/pack_stream.c b/src/packing/pack_stream.c
index 6ab44c123c8..5716c31a9c2 100644
--- a/src/packing/pack_stream.c
+++ b/src/packing/pack_stream.c
@@ -333,10 +333,16 @@ wiredtiger_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up)
* WT_EXTENSION.pack_start method.
*/
int
-__wt_ext_pack_start(WT_SESSION *session, const char *format,
+__wt_ext_pack_start(WT_EXTENSION_API *wt_api,
+ WT_SESSION *wt_session, const char *format,
void *buffer, size_t size, WT_PACK_STREAM **psp)
{
- return (wiredtiger_pack_start(session, format, buffer, size, psp));
+ WT_CONNECTION_IMPL *conn;
+
+ conn = (WT_CONNECTION_IMPL *)wt_api->conn;
+ if (wt_session == NULL)
+ wt_session = (WT_SESSION *)conn->default_session;
+ return (wiredtiger_pack_start(wt_session, format, buffer, size, psp));
}
/*
@@ -344,10 +350,16 @@ __wt_ext_pack_start(WT_SESSION *session, const char *format,
* WT_EXTENSION.unpack_start
*/
int
-__wt_ext_unpack_start(WT_SESSION *session, const char *format,
+__wt_ext_unpack_start(WT_EXTENSION_API *wt_api,
+ WT_SESSION *wt_session, const char *format,
const void *buffer, size_t size, WT_PACK_STREAM **psp)
{
- return (wiredtiger_unpack_start(session, format, buffer, size, psp));
+ WT_CONNECTION_IMPL *conn;
+
+ conn = (WT_CONNECTION_IMPL *)wt_api->conn;
+ if (wt_session == NULL)
+ wt_session = (WT_SESSION *)conn->default_session;
+ return (wiredtiger_unpack_start(wt_session, format, buffer, size, psp));
}
/*
@@ -355,8 +367,9 @@ __wt_ext_unpack_start(WT_SESSION *session, const char *format,
* WT_EXTENSION.pack_close
*/
int
-__wt_ext_pack_close(WT_PACK_STREAM *ps, size_t *usedp)
+__wt_ext_pack_close(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, size_t *usedp)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_pack_close(ps, usedp));
}
@@ -365,8 +378,9 @@ __wt_ext_pack_close(WT_PACK_STREAM *ps, size_t *usedp)
* WT_EXTENSION.pack_item
*/
int
-__wt_ext_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
+__wt_ext_pack_item(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, WT_ITEM *item)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_pack_item(ps, item));
}
@@ -375,8 +389,9 @@ __wt_ext_pack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
* WT_EXTENSION.pack_int
*/
int
-__wt_ext_pack_int(WT_PACK_STREAM *ps, int64_t i)
+__wt_ext_pack_int(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, int64_t i)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_pack_int(ps, i));
}
@@ -385,8 +400,9 @@ __wt_ext_pack_int(WT_PACK_STREAM *ps, int64_t i)
* WT_EXTENSION.pack_str
*/
int
-__wt_ext_pack_str(WT_PACK_STREAM *ps, const char *s)
+__wt_ext_pack_str(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, const char *s)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_pack_str(ps, s));
}
@@ -395,8 +411,9 @@ __wt_ext_pack_str(WT_PACK_STREAM *ps, const char *s)
* WT_EXTENSION.pack_uint
*/
int
-__wt_ext_pack_uint(WT_PACK_STREAM *ps, uint64_t u)
+__wt_ext_pack_uint(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t u)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_pack_uint(ps, u));
}
@@ -405,8 +422,10 @@ __wt_ext_pack_uint(WT_PACK_STREAM *ps, uint64_t u)
* WT_EXTENSION.unpack_item
*/
int
-__wt_ext_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
+__wt_ext_unpack_item(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, WT_ITEM *item)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_unpack_item(ps, item));
}
@@ -415,8 +434,10 @@ __wt_ext_unpack_item(WT_PACK_STREAM *ps, WT_ITEM *item)
* WT_EXTENSION.unpack_int
*/
int
-__wt_ext_unpack_int(WT_PACK_STREAM *ps, int64_t *ip)
+__wt_ext_unpack_int(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, int64_t *ip)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_unpack_int(ps, ip));
}
@@ -425,8 +446,10 @@ __wt_ext_unpack_int(WT_PACK_STREAM *ps, int64_t *ip)
* WT_EXTENSION.unpack_str
*/
int
-__wt_ext_unpack_str(WT_PACK_STREAM *ps, const char **sp)
+__wt_ext_unpack_str(WT_EXTENSION_API *wt_api,
+ WT_PACK_STREAM *ps, const char **sp)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_unpack_str(ps, sp));
}
@@ -435,7 +458,8 @@ __wt_ext_unpack_str(WT_PACK_STREAM *ps, const char **sp)
* WT_EXTENSION.unpack_uint
*/
int
-__wt_ext_unpack_uint(WT_PACK_STREAM *ps, uint64_t *up)
+__wt_ext_unpack_uint(WT_EXTENSION_API *wt_api, WT_PACK_STREAM *ps, uint64_t *up)
{
+ WT_UNUSED(wt_api);
return (wiredtiger_unpack_uint(ps, up));
}