diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-02-17 17:25:57 +0000 |
|---|---|---|
| committer | <> | 2015-03-17 16:26:24 +0000 |
| commit | 780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch) | |
| tree | 598f8b9fa431b228d29897e798de4ac0c1d3d970 /src/btree/bt_compress.c | |
| parent | 7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff) | |
| download | berkeleydb-master.tar.gz | |
Diffstat (limited to 'src/btree/bt_compress.c')
| -rw-r--r-- | src/btree/bt_compress.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/src/btree/bt_compress.c b/src/btree/bt_compress.c index 3f293461..479e7248 100644 --- a/src/btree/bt_compress.c +++ b/src/btree/bt_compress.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2015 Oracle and/or its affiliates. All rights reserved. */ #include "db_config.h" @@ -352,16 +352,20 @@ __bam_compress_marshal_data(dbp, data, destbuf) * __bam_compress_dupcmp -- * Duplicate comparison function for compressed BTrees. * - * PUBLIC: int __bam_compress_dupcmp __P((DB *, const DBT *, const DBT *)); + * PUBLIC: int __bam_compress_dupcmp __P((DB *, const DBT *, const DBT *, + * PUBLIC: size_t *)); */ int -__bam_compress_dupcmp(db, a, b) +__bam_compress_dupcmp(db, a, b, locp) DB *db; const DBT *a; const DBT *b; + size_t *locp; { DBT dcmp_a, dcmp_b; + COMPQUIET(locp, NULL); + /* Decompress the initial data in a */ CMP_UNMARSHAL_DATA(a, &dcmp_a); dcmp_a.ulen = 0; @@ -380,7 +384,7 @@ __bam_compress_dupcmp(db, a, b) /* Call the user's duplicate compare function */ return ((BTREE *)db->bt_internal)-> - compress_dup_compare(db, &dcmp_a, &dcmp_b); + compress_dup_compare(db, &dcmp_a, &dcmp_b, NULL); } /* @@ -636,7 +640,7 @@ __bamc_next_decompress(dbc) db = dbc->dbp; if (cp->compcursor >= cp->compend) - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); cp->prevKey = cp->currentKey; cp->prevData = cp->currentData; @@ -1251,7 +1255,7 @@ __bamc_compress_merge_delete(dbc, stream, countp) * chunk, but don't delete any more * entries. */ - bulk_ret = DB_NOTFOUND; + bulk_ret = DBC_ERR(dbc, DB_NOTFOUND); moreStream = 0; iSmallEnough = 0; } else @@ -1318,7 +1322,7 @@ __bamc_compress_merge_delete(dbc, stream, countp) CMP_FREE_DBT(env, &nextk); CMP_FREE_DBT(env, &nextc); - return (ret != 0 ? ret : bulk_ret); + return (ret != 0 ? ret : DBC_ERR(dbc, bulk_ret)); } /* @@ -1389,7 +1393,7 @@ __bamc_compress_merge_delete_dups(dbc, stream, countp) * in the database */ if (ifound == 0) { - bulk_ret = DB_NOTFOUND; + bulk_ret = DBC_ERR(dbc, DB_NOTFOUND); } else ++chunk_count; break; @@ -1463,7 +1467,7 @@ __bamc_compress_merge_delete_dups(dbc, stream, countp) * current chunk, but don't delete * any more entries. */ - bulk_ret = DB_NOTFOUND; + bulk_ret = DBC_ERR(dbc, DB_NOTFOUND); moreStream = 0; iSmallEnough = 0; } else @@ -1541,7 +1545,7 @@ __bamc_compress_merge_delete_dups(dbc, stream, countp) CMP_FREE_DBT(env, &pdestdata); CMP_FREE_DBT(env, &nextk); - return (ret != 0 ? ret : bulk_ret); + return (ret != 0 ? ret : DBC_ERR(dbc, bulk_ret)); } /******************************************************************************/ @@ -1641,8 +1645,8 @@ __bamc_compress_get_prev_dup(dbc, flags) if ((ret = __bamc_compress_get_prev(dbc, flags)) != 0) return (ret); - if (t->bt_compare(dbp, cp->currentKey, &cp->del_key) != 0) - return (DB_NOTFOUND); + if (t->bt_compare(dbp, cp->currentKey, &cp->del_key, NULL) != 0) + return (DBC_ERR(dbc, DB_NOTFOUND)); return (0); } @@ -1684,7 +1688,7 @@ __bamc_compress_get_prev_nodup(dbc, flags) do if ((ret = __bamc_compress_get_prev(dbc, flags)) != 0) return (ret); - while (t->bt_compare(dbp, cp->currentKey, &cp->del_key) == 0); + while (t->bt_compare(dbp, cp->currentKey, &cp->del_key, NULL) == 0); return (0); } @@ -1702,7 +1706,7 @@ __bamc_compress_get_next(dbc, flags) if (F_ISSET(cp, C_COMPRESS_DELETED)) { if (cp->currentKey == 0) - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); F_CLR(cp, C_COMPRESS_DELETED); return (0); } else if (cp->currentKey) { @@ -1722,7 +1726,7 @@ __bamc_compress_get_next(dbc, flags) * to the right place */ __bamc_compress_reset(dbc); - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); } else if (ret != 0) return (ret); @@ -1753,17 +1757,18 @@ __bamc_compress_get_next_dup(dbc, key, flags) * deleted entry. */ if (cp->currentKey == 0) - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); F_CLR(cp, C_COMPRESS_DELETED); - return (t->bt_compare(dbp, - cp->currentKey, &cp->del_key) == 0 ? 0 : DB_NOTFOUND); + return (t->bt_compare(dbp, cp->currentKey, + &cp->del_key, NULL) == 0 ? 0 : DB_NOTFOUND); } else if (cp->currentKey == 0) return (EINVAL); /* Check that the next entry has the same key as the previous entry */ ret = __bamc_next_decompress(dbc); - if (ret == 0 && t->bt_compare(dbp, cp->currentKey, cp->prevKey) != 0) - return (DB_NOTFOUND); + if (ret == 0 && t->bt_compare(dbp, + cp->currentKey, cp->prevKey, NULL) != 0) + return (DBC_ERR(dbc, DB_NOTFOUND)); if (ret != DB_NOTFOUND) return (ret); @@ -1783,7 +1788,7 @@ __bamc_compress_get_next_dup(dbc, key, flags) * will end up pointing to the right place */ __bamc_compress_reset(dbc); - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); } else if (ret != 0) return (ret); @@ -1791,8 +1796,8 @@ __bamc_compress_get_next_dup(dbc, key, flags) return (ret); /* Check the keys are the same */ - if (t->bt_compare(dbp, cp->currentKey, key) != 0) - return (DB_NOTFOUND); + if (t->bt_compare(dbp, cp->currentKey, key, NULL) != 0) + return (DBC_ERR(dbc, DB_NOTFOUND)); return (0); } @@ -1828,7 +1833,7 @@ __bamc_compress_get_next_nodup(dbc, flags) do if ((ret = __bamc_compress_get_next(dbc, flags)) != 0) return (ret); - while (t->bt_compare(dbp, cp->currentKey, &cp->del_key) == 0); + while (t->bt_compare(dbp, cp->currentKey, &cp->del_key, NULL) == 0); return (ret); } @@ -1888,14 +1893,14 @@ __bamc_compress_get_set(dbc, key, data, method, flags) if (ret == 0 && __db_compare_both(dbp, cp->currentKey, 0, key, 0) != 0) { /* We didn't find the key */ - ret = DB_NOTFOUND; + ret = DBC_ERR(dbc, DB_NOTFOUND); } break; case DB_GET_BOTH: if (ret == 0 && (cmp != 0 || (!F_ISSET(dbp, DB_AM_DUPSORT) && - __bam_defcmp(dbp, cp->currentData, data) != 0))) { + __bam_defcmp(dbp, cp->currentData, data, NULL) != 0))) { /* We didn't find the key/data pair */ - ret = DB_NOTFOUND; + ret = DBC_ERR(dbc, DB_NOTFOUND); } break; default: @@ -1923,7 +1928,7 @@ __bamc_compress_get_bothc(dbc, data, flags) position */ if (__db_compare_both(dbp, cp->currentKey, cp->currentData, cp->currentKey, data) >= 0) - return (DB_NOTFOUND); + return (DBC_ERR(dbc, DB_NOTFOUND)); cmp = 0; /* Perform a linear search for the data in the current chunk */ @@ -1933,7 +1938,7 @@ __bamc_compress_get_bothc(dbc, data, flags) continue; if (ret == 0) - return (cmp == 0 ? 0 : DB_NOTFOUND); + return (cmp == 0 ? 0 : DBC_ERR(dbc, DB_NOTFOUND)); if (ret != DB_NOTFOUND) return (ret); @@ -2277,7 +2282,7 @@ __bamc_compress_iput(dbc, key, data, flags) switch (flags) { case DB_CURRENT: if (cp->currentKey == 0 || F_ISSET(cp, C_COMPRESS_DELETED)) { - ret = DB_NOTFOUND; + ret = DBC_ERR(dbc, DB_NOTFOUND); goto end; } @@ -2290,7 +2295,7 @@ __bamc_compress_iput(dbc, key, data, flags) if (F_ISSET(dbp, DB_AM_DUPSORT) && ((BTREE *)dbp->bt_internal)->compress_dup_compare( - dbp, cp->currentData, data) != 0) { + dbp, cp->currentData, data, NULL) != 0) { __db_errx(env, DB_STR("1032", "Existing data sorts differently from put data")); ret = EINVAL; @@ -2464,7 +2469,7 @@ __bamc_compress_idel(dbc, flags) if (F_ISSET(cp, C_COMPRESS_DELETED)) return DB_KEYEMPTY; if (cp->currentKey == 0) - return DB_NOTFOUND; + return (DBC_ERR(dbc, DB_NOTFOUND)); if ((ret = __bam_compress_set_dbt(dbp, &cp->del_key, cp->currentKey->data, cp->currentKey->size)) != 0) @@ -3015,7 +3020,8 @@ __bam_compress_count(dbc, nkeysp, ndatap) if (ret != 0) goto err; - if (t->bt_compare(dbp, cp_n->currentKey, cp_n->prevKey) != 0) + if (t->bt_compare(dbp, + cp_n->currentKey, cp_n->prevKey, NULL) != 0) nkeys += 1; } |
