Commit d461c45b authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

close[t:4436] removed row_size_supported in favor of a more straighforward ydb...

close[t:4436] removed row_size_supported in favor of a more straighforward ydb call to get the maximum permitted key and row sizes. updated the headers, updated the test, updated the ydb layer.


git-svn-id: file:///svn/toku/tokudb@39230 c7de825b-a66e-492c-adef-691d508d4ae1
parent d83ceaff
......@@ -546,7 +546,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -556,7 +556,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -558,7 +558,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -558,7 +558,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -561,7 +561,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -807,32 +807,30 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf(" uint64_t largest_unused_block; //Size of largest contiguous unused space\n");
printf("} *TOKU_DB_FRAGMENTATION, TOKU_DB_FRAGMENTATION_S;\n");
const char *extra[] = {
"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *)",
"int (*pre_acquire_table_lock)(DB*, DB_TXN*)",
"int (*pre_acquire_fileops_lock)(DB*, DB_TXN*)",
"int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*)",
"const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/",
"const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/",
"int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */",
"DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
"int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */",
"int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */",
"int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */",
"int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */",
"int (*hot_optimize)(DB*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra)",
"int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)",
"int (*get_readpagesize)(DB*,u_int32_t*)",
"int (*set_readpagesize)(DB*,u_int32_t)",
"int (*set_indexer)(DB*, DB_INDEXER*)",
"void (*get_indexer)(DB*, DB_INDEXER**)",
"int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)",
"int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags)",
"int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags)",
NULL
};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
const char *extra[]={"int (*key_range64)(DB*, DB_TXN *, DBT *, u_int64_t *less, u_int64_t *equal, u_int64_t *greater, int *is_exact)",
"int (*stat64)(DB *, DB_TXN *, DB_BTREE_STAT64 *)",
"int (*pre_acquire_table_lock)(DB*, DB_TXN*)",
"int (*pre_acquire_fileops_lock)(DB*, DB_TXN*)",
"int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*)",
"const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/",
"const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/",
"void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */",
"DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */",
"int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */",
"int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */",
"int (*flatten)(DB*, DB_TXN*) /* Flatten a dictionary, similar to (but faster than) a table scan */",
"int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */",
"int (*hot_optimize)(DB*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra)",
"int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)",
"int (*get_readpagesize)(DB*,u_int32_t*)",
"int (*set_readpagesize)(DB*,u_int32_t)",
"int (*set_indexer)(DB*, DB_INDEXER*)",
"void (*get_indexer)(DB*, DB_INDEXER**)",
"int (*verify_with_progress)(DB *, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, int verbose, int keep_going)",
"int (*update)(DB *, DB_TXN*, const DBT *key, const DBT *extra, u_int32_t flags)",
"int (*update_broadcast)(DB *, DB_TXN*, const DBT *extra, u_int32_t flags)",
NULL};
print_struct("db", 1, db_fields32, db_fields64, sizeof(db_fields32)/sizeof(db_fields32[0]), extra);
}
assert(sizeof(db_txn_active_fields32)==sizeof(db_txn_active_fields64));
......
......@@ -530,7 +530,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -530,7 +530,7 @@ struct __toku_db {
int (*pre_acquire_fileops_shared_lock)(DB*, DB_TXN*);
const DBT* (*dbt_pos_infty)(void) /* Return the special DBT that refers to positive infinity in the lock table.*/;
const DBT* (*dbt_neg_infty)(void)/* Return the special DBT that refers to negative infinity in the lock table.*/;
int (*row_size_supported) (DB *, uint32_t key_size, uint32_t val_size) /* Test whether a row with the given key size and value size is supported. */;
void (*get_max_row_size)(DB*, u_int32_t *max_key_size, u_int32_t *max_row_size) /* Test whether a row size is supported. */;
DESCRIPTOR descriptor /* saved row/dictionary descriptor for aiding in comparisons */;
int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, u_int32_t) /* change row/dictionary descriptor for a db. Available only while db is open */;
int (*getf_set)(DB*, DB_TXN*, u_int32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */;
......
......@@ -21,20 +21,14 @@ int test_main(int argc, char * const argv[])
// - does not test low bounds, so a 0 byte key is "okay"
// - assuming 32k keys and 32mb values are the max
r = db->row_size_supported(db, 0, 0);
assert(r == 0);
r = db->row_size_supported(db, 100000000, 100000000);
assert(r != 0);
r = db->row_size_supported(db, 100, 1);
assert(r == 0);
r = db->row_size_supported(db, 1, 100);
assert(r == 0);
r = db->row_size_supported(db, 4*1024, 4*1024*1024);
assert(r == 0);
r = db->row_size_supported(db, 32*1024, 32*1024*1024);
assert(r == 0);
r = db->row_size_supported(db, 32*1024 + 1, 32*1024*1024 + 1);
assert(r != 0);
uint32_t max_key, max_val;
db->get_max_row_size(db, &max_key, &max_val);
// assume it is a red flag for the key to be outside the 16-32kb range
assert(max_key >= 16*1024);
assert(max_key <= 32*1024);
// assume it is a red flag for the value to be outside the 16-32mb range
assert(max_val >= 16*1024*1024);
assert(max_val <= 32*1024*1024);
// clean things up
r = db->close(db, 0); CHK(r);
......
......@@ -5024,28 +5024,20 @@ db_put_check_size_constraints(DB *db, const DBT *key, const DBT *val) {
return r;
}
// Return 0 if supported.
// Return ERANGE if out of range.
static int
db_row_size_supported(DB *db, uint32_t key_size, uint32_t val_size) {
int r = 0;
DBT key, val;
toku_fill_dbt(&key, NULL, key_size);
toku_fill_dbt(&val, NULL, val_size);
r = db_put_check_size_constraints(db, &key, &val);
if (r != 0) {
r = ERANGE;
}
return r;
// Return the maximum key and val size in
// *key_size and *val_size respectively
static void
db_get_max_row_size(DB * UU(db), uint32_t * max_key_size, uint32_t * max_val_size) {
*max_key_size = 0;
*max_val_size = 0;
toku_brt_get_maximum_advised_key_value_lengths(max_key_size, max_val_size);
}
static int
locked_db_row_size_supported(DB *db, uint32_t key_size, uint32_t val_size) {
static void
locked_db_get_max_row_size(DB *db, uint32_t *max_key_size, uint32_t *max_val_size) {
toku_ydb_lock();
int r = db_row_size_supported(db, key_size, val_size);
db_get_max_row_size(db, max_key_size, max_val_size);
toku_ydb_unlock();
return r;
}
//Return 0 if insert is legal
......@@ -6540,7 +6532,7 @@ toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
SDB(pre_acquire_fileops_lock);
SDB(pre_acquire_fileops_shared_lock);
SDB(truncate);
SDB(row_size_supported);
SDB(get_max_row_size);
SDB(getf_set);
SDB(flatten);
SDB(optimize);
......
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