Commit 77dc60e7 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#3061 doc updates per code review refs[t:3061]

git-svn-id: file:///svn/toku/tokudb@25912 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3ba245cd
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
#ifndef TOKU_INDEXER_INTERNAL_H #ifndef TOKU_INDEXER_INTERNAL_H
#define TOKU_INDEXER_INTERNAL_H #define TOKU_INDEXER_INTERNAL_H
// the indexer_commit_keys is a set of keys described by a DBT in the keys array. // the indexer_commit_keys is an ordered set of keys described by a DBT in the keys array.
// the array is a resizeable array with max size "max_keys" and current size "current_keys". // the array is a resizeable array with max size "max_keys" and current size "current_keys".
// the ordered set is used by the hotindex undo function to collect the commit keys.
struct indexer_commit_keys { struct indexer_commit_keys {
int max_keys; // max number of keys int max_keys; // max number of keys
int current_keys; // number of valid keys int current_keys; // number of valid keys
......
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
#include "indexer-internal.h" #include "indexer-internal.h"
// initialize the commit keys collection // initialize the commit keys
static void static void
indexer_commit_keys_init(struct indexer_commit_keys *keys) { indexer_commit_keys_init(struct indexer_commit_keys *keys) {
keys->max_keys = keys->current_keys = 0; keys->max_keys = keys->current_keys = 0;
keys->keys = NULL; keys->keys = NULL;
} }
// destroy the commit keys collection // destroy the commit keys
static void static void
indexer_commit_keys_destroy(struct indexer_commit_keys *keys) { indexer_commit_keys_destroy(struct indexer_commit_keys *keys) {
for (int i = 0; i < keys->max_keys; i++) for (int i = 0; i < keys->max_keys; i++)
...@@ -40,17 +40,17 @@ indexer_commit_keys_destroy(struct indexer_commit_keys *keys) { ...@@ -40,17 +40,17 @@ indexer_commit_keys_destroy(struct indexer_commit_keys *keys) {
toku_free(keys->keys); toku_free(keys->keys);
} }
// return the number of keys in the collection // return the number of keys in the ordered set
static int static int
indexer_commit_keys_valid(struct indexer_commit_keys *keys) { indexer_commit_keys_valid(struct indexer_commit_keys *keys) {
return keys->current_keys; return keys->current_keys;
} }
// add a key to the commit keys collection // add a key to the commit keys
static void static void
indexer_commit_keys_add(struct indexer_commit_keys *keys, size_t length, void *ptr) { indexer_commit_keys_add(struct indexer_commit_keys *keys, size_t length, void *ptr) {
if (keys->current_keys >= keys->max_keys) { if (keys->current_keys >= keys->max_keys) {
int new_max_keys = keys->max_keys == 0 ? 8 : keys->max_keys * 2; int new_max_keys = keys->max_keys == 0 ? 256 : keys->max_keys * 2;
keys->keys = (DBT *) toku_realloc(keys->keys, new_max_keys * sizeof (DBT)); keys->keys = (DBT *) toku_realloc(keys->keys, new_max_keys * sizeof (DBT));
resource_assert(keys->keys); resource_assert(keys->keys);
for (int i = keys->current_keys; i < new_max_keys; i++) { for (int i = keys->current_keys; i < new_max_keys; i++) {
...@@ -64,7 +64,7 @@ indexer_commit_keys_add(struct indexer_commit_keys *keys, size_t length, void *p ...@@ -64,7 +64,7 @@ indexer_commit_keys_add(struct indexer_commit_keys *keys, size_t length, void *p
keys->current_keys++; keys->current_keys++;
} }
// set the collection to empty // set the ordered set to empty
static void static void
indexer_commit_keys_set_empty(struct indexer_commit_keys *keys) { indexer_commit_keys_set_empty(struct indexer_commit_keys *keys) {
keys->current_keys = 0; keys->current_keys = 0;
...@@ -290,6 +290,8 @@ indexer_undo_do(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) { ...@@ -290,6 +290,8 @@ indexer_undo_do(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule) {
} }
// the committed XIDS always = [this_xid] // the committed XIDS always = [this_xid]
// Note that this could be sped up by adding a new xids constructor that constructs the stack with
// exactly one xid.
static int static int
indexer_set_xid(DB_INDEXER *UU(indexer), TXNID this_xid, XIDS *xids_result) { indexer_set_xid(DB_INDEXER *UU(indexer), TXNID this_xid, XIDS *xids_result) {
int result = 0; int result = 0;
...@@ -398,6 +400,9 @@ indexer_lock_key(DB_INDEXER *indexer, DB *hotdb, DBT *key, TXNID outermost_live_ ...@@ -398,6 +400,9 @@ indexer_lock_key(DB_INDEXER *indexer, DB *hotdb, DBT *key, TXNID outermost_live_
return result; return result;
} }
// find the index of a non-placeholder transaction record that is previous to the transaction record
// found at xrindex. return TRUE if one is found and return its index in prev_xrindex. otherwise,
// return FALSE.
static BOOL static BOOL
indexer_find_prev_xr(DB_INDEXER *UU(indexer), ULEHANDLE ule, uint64_t xrindex, uint64_t *prev_xrindex) { indexer_find_prev_xr(DB_INDEXER *UU(indexer), ULEHANDLE ule, uint64_t xrindex, uint64_t *prev_xrindex) {
invariant(xrindex < ule_num_uxrs(ule)); invariant(xrindex < ule_num_uxrs(ule));
...@@ -414,6 +419,8 @@ indexer_find_prev_xr(DB_INDEXER *UU(indexer), ULEHANDLE ule, uint64_t xrindex, u ...@@ -414,6 +419,8 @@ indexer_find_prev_xr(DB_INDEXER *UU(indexer), ULEHANDLE ule, uint64_t xrindex, u
return prev_found; return prev_found;
} }
// get the innermost live txn from the xids stack. the xid on the top of the xids stack must be live
// when calling this function. the indexer_append_xid only appends live xid's onto the stack.
static TOKUTXN static TOKUTXN
indexer_get_innermost_live_txn(DB_INDEXER *indexer, XIDS xids) { indexer_get_innermost_live_txn(DB_INDEXER *indexer, XIDS xids) {
DB_ENV *env = indexer->i->env; DB_ENV *env = indexer->i->env;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment