| 1 | /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
| 2 | // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: |
| 3 | #ident "$Id$" |
| 4 | /*====== |
| 5 | This file is part of PerconaFT. |
| 6 | |
| 7 | |
| 8 | Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. |
| 9 | |
| 10 | PerconaFT is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License, version 2, |
| 12 | as published by the Free Software Foundation. |
| 13 | |
| 14 | PerconaFT is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 21 | |
| 22 | ---------------------------------------- |
| 23 | |
| 24 | PerconaFT is free software: you can redistribute it and/or modify |
| 25 | it under the terms of the GNU Affero General Public License, version 3, |
| 26 | as published by the Free Software Foundation. |
| 27 | |
| 28 | PerconaFT is distributed in the hope that it will be useful, |
| 29 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | GNU Affero General Public License for more details. |
| 32 | |
| 33 | You should have received a copy of the GNU Affero General Public License |
| 34 | along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. |
| 35 | ======= */ |
| 36 | |
| 37 | #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." |
| 38 | |
| 39 | #pragma once |
| 40 | |
| 41 | // locking and unlocking functions to synchronize cursor position with |
| 42 | // XXX_multiple APIs |
| 43 | void toku_indexer_lock(DB_INDEXER* indexer); |
| 44 | |
| 45 | void toku_indexer_unlock(DB_INDEXER* indexer); |
| 46 | bool toku_indexer_may_insert(DB_INDEXER* indexer, const DBT* key); |
| 47 | void toku_indexer_update_estimate(DB_INDEXER* indexer); |
| 48 | |
| 49 | // The indexer populates multiple destination db's from the contents of one source db. |
| 50 | // While the indexes are being built by the indexer, the application may continue to |
| 51 | // change the contents of the source db. The changes will be reflected into the destination |
| 52 | // db's by the indexer. |
| 53 | // |
| 54 | // Each indexer references one source db. |
| 55 | // A source db may have multiple indexers referencing it. |
| 56 | // Each indexer references one or more destination db's. |
| 57 | // Each destination db references the one and only indexer that is building it. |
| 58 | // |
| 59 | // env must be set to the YDB environment |
| 60 | // txn must be set to the transaction under which the indexer will run |
| 61 | // *indexer is set to the address of the indexer object returned by the create function |
| 62 | // src_db is the source db |
| 63 | // N is the number of destination db's |
| 64 | // dest_dbs is an array of pointers to destination db's |
| 65 | // db_flags is currently unused |
| 66 | // indexer_flags is currently unused |
| 67 | // |
| 68 | // Returns 0 if the indexer has been created and sets *indexer to the indexer object. |
| 69 | // If an error occurred while creating the indexer object, a non-zero error number is returned. |
| 70 | // |
| 71 | // Clients must not operate on any of the dest_dbs concurrently with create_indexer(); |
| 72 | int toku_indexer_create_indexer(DB_ENV *env, |
| 73 | DB_TXN *txn, |
| 74 | DB_INDEXER **indexer, |
| 75 | DB *src_db, |
| 76 | int N, |
| 77 | DB *dest_dbs[/*N*/], |
| 78 | uint32_t db_flags[/*N*/], |
| 79 | uint32_t indexer_flags) __attribute__((__visibility__("default" ))); |
| 80 | |
| 81 | // Set the indexer poll function |
| 82 | int toku_indexer_set_poll_function(DB_INDEXER *indexer, |
| 83 | int (*poll_function)(void *, |
| 84 | float progress), |
| 85 | void *); |
| 86 | |
| 87 | // Set the indexer error callback |
| 88 | int toku_indexer_set_error_callback(DB_INDEXER *indexer, |
| 89 | void (*error_cb)(DB *db, int i, int err, |
| 90 | DBT *key, DBT *val, |
| 91 | void *), |
| 92 | void *); |
| 93 | |
| 94 | // Is the key right of the indexer's leaf entry cursor? |
| 95 | // Returns true if right of le_cursor |
| 96 | // Returns false if left or equal to le_cursor |
| 97 | bool toku_indexer_should_insert_key(DB_INDEXER *indexer, const DBT *key); |
| 98 | |
| 99 | // Get the indexer's source db |
| 100 | DB *toku_indexer_get_src_db(DB_INDEXER *indexer); |
| 101 | |
| 102 | // TEST set the indexer's test flags |
| 103 | extern "C" void toku_indexer_set_test_only_flags(DB_INDEXER *indexer, int flags) __attribute__((__visibility__("default" ))); |
| 104 | |
| 105 | #define INDEXER_TEST_ONLY_ERROR_CALLBACK 1 |
| 106 | |
| 107 | typedef enum { |
| 108 | INDEXER_CREATE = 0, // number of indexers successfully created |
| 109 | INDEXER_CREATE_FAIL, // number of calls to toku_indexer_create_indexer() that failed |
| 110 | INDEXER_BUILD, // number of calls to indexer->build() succeeded |
| 111 | INDEXER_BUILD_FAIL, // number of calls to indexer->build() failed |
| 112 | INDEXER_CLOSE, // number of calls to indexer->close() that succeeded |
| 113 | INDEXER_CLOSE_FAIL, // number of calls to indexer->close() that failed |
| 114 | INDEXER_ABORT, // number of calls to indexer->abort() |
| 115 | INDEXER_CURRENT, // number of indexers currently in existence |
| 116 | INDEXER_MAX, // max number of indexers that ever existed simultaneously |
| 117 | INDEXER_STATUS_NUM_ROWS |
| 118 | } indexer_status_entry; |
| 119 | |
| 120 | typedef struct { |
| 121 | bool initialized; |
| 122 | TOKU_ENGINE_STATUS_ROW_S status[INDEXER_STATUS_NUM_ROWS]; |
| 123 | } INDEXER_STATUS_S, *INDEXER_STATUS; |
| 124 | |
| 125 | void toku_indexer_get_status(INDEXER_STATUS s); |
| 126 | |