| 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 | #include <db.h> |
| 42 | |
| 43 | // TODO: John |
| 44 | // Document this API a little better so that DBT |
| 45 | // memory management can be morm widely understood. |
| 46 | |
| 47 | DBT *toku_init_dbt(DBT *); |
| 48 | |
| 49 | // returns: an initialized but empty dbt (for which toku_dbt_is_empty() is true) |
| 50 | DBT toku_empty_dbt(void); |
| 51 | |
| 52 | DBT *toku_init_dbt_flags(DBT *, uint32_t flags); |
| 53 | |
| 54 | void toku_destroy_dbt(DBT *); |
| 55 | |
| 56 | DBT *toku_fill_dbt(DBT *dbt, const void *k, uint32_t len); |
| 57 | |
| 58 | DBT *toku_memdup_dbt(DBT *dbt, const void *k, size_t len); |
| 59 | |
| 60 | DBT *toku_copyref_dbt(DBT *dst, const DBT src); |
| 61 | |
| 62 | DBT *toku_clone_dbt(DBT *dst, const DBT &src); |
| 63 | |
| 64 | int toku_dbt_set(uint32_t len, const void *val, DBT *d, struct simple_dbt *sdbt); |
| 65 | |
| 66 | int toku_dbt_set_value(DBT *, const void **val, uint32_t vallen, void **staticptrp, bool dbt1_disposable); |
| 67 | |
| 68 | void toku_sdbt_cleanup(struct simple_dbt *sdbt); |
| 69 | |
| 70 | // returns: special DBT pointer representing positive infinity |
| 71 | const DBT *toku_dbt_positive_infinity(void); |
| 72 | |
| 73 | // returns: special DBT pointer representing negative infinity |
| 74 | const DBT *toku_dbt_negative_infinity(void); |
| 75 | |
| 76 | // returns: true if the given dbt is either positive or negative infinity |
| 77 | bool toku_dbt_is_infinite(const DBT *dbt); |
| 78 | |
| 79 | // returns: true if the given dbt has no data (ie: dbt->data == nullptr) |
| 80 | bool toku_dbt_is_empty(const DBT *dbt); |
| 81 | |
| 82 | // effect: compares two potentially infinity-valued dbts |
| 83 | // requires: at least one is infinite (assert otherwise) |
| 84 | int toku_dbt_infinite_compare(const DBT *a, const DBT *b); |
| 85 | |
| 86 | // returns: true if the given dbts have the same data pointer and size |
| 87 | bool toku_dbt_equals(const DBT *a, const DBT *b); |
| 88 | |