Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/splinterdb_custom_ipv4_addr_sortcmp_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

#define IP4_MIN_KEY_SIZE ((1 * IPV4_NUM_FIELDS) + IPV4_NUM_DOTS)

// Application declares the limit of key-sizes it intends to use
#define IP4_MAX_KEY_SIZE ((3 * IPV4_NUM_FIELDS) + IPV4_NUM_DOTS)

// Max # of chars in a well-formed IP4 address, including null-terminator byte
Expand Down Expand Up @@ -133,7 +132,7 @@ main()

// Initialize data configuration, describing your key-value properties
data_config splinter_data_cfg;
default_data_config_init(IP4_MAX_KEY_SIZE, &splinter_data_cfg);
default_data_config_init(&splinter_data_cfg);

// -- ACTION IS HERE --
// Customize key-comparison with our implementation for IP4 addresses
Expand Down
5 changes: 1 addition & 4 deletions examples/splinterdb_intro_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#define DB_FILE_SIZE_MB 1024 // Size of SplinterDB device; Fixed when created
#define CACHE_SIZE_MB 64 // Size of cache; can be changed across boots

/* Application declares the limit of key-sizes it intends to use */
#define USER_MAX_KEY_SIZE ((int)100)

/*
* -------------------------------------------------------------------------------
* We, intentionally, do not check for errors or show error handling, as this is
Expand All @@ -32,7 +29,7 @@ main()

// Initialize data configuration, using default key-comparison handling.
data_config splinter_data_cfg;
default_data_config_init(USER_MAX_KEY_SIZE, &splinter_data_cfg);
default_data_config_init(&splinter_data_cfg);

// Basic configuration of a SplinterDB instance
splinterdb_config splinterdb_cfg;
Expand Down
5 changes: 1 addition & 4 deletions examples/splinterdb_iterators_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#define DB_FILE_SIZE_MB 1024 // Size of SplinterDB device; Fixed when created
#define CACHE_SIZE_MB 64 // Size of cache; can be changed across boots

/* Application declares the limit of key-sizes it intends to use */
#define USER_MAX_KEY_SIZE ((int)100)

// Declare a struct to build a key/value pair
typedef struct kv_pair {
char *kv_key;
Expand Down Expand Up @@ -63,7 +60,7 @@ main()

// Initialize data configuration, using default key-comparison handling.
data_config splinter_data_cfg;
default_data_config_init(USER_MAX_KEY_SIZE, &splinter_data_cfg);
default_data_config_init(&splinter_data_cfg);

// Basic configuration of a SplinterDB instance
splinterdb_config splinterdb_cfg;
Expand Down
10 changes: 5 additions & 5 deletions examples/splinterdb_wide_values_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#define DB_FILE_SIZE_MB 1024 // Size of SplinterDB device; Fixed when created
#define CACHE_SIZE_MB 64 // Size of cache; can be changed across boots

/* Application declares the limit of key-sizes it intends to use */
#define USER_MAX_KEY_SIZE ((int)100)
/* Largest key buffer used by this example. */
#define USER_KEY_BUF_SIZE ((int)100)

/* Avg value size and max value sizes we expect to deal with in this program */
#define USER_AVG_VALUE_SIZE ((int)128)
Expand All @@ -33,7 +33,7 @@ main()

// Initialize data configuration, using default key-comparison handling.
data_config splinter_data_cfg;
default_data_config_init(USER_MAX_KEY_SIZE, &splinter_data_cfg);
default_data_config_init(&splinter_data_cfg);

// Basic configuration of a SplinterDB instance
splinterdb_config splinterdb_cfg;
Expand All @@ -49,7 +49,7 @@ main()
printf("Created SplinterDB instance, dbname '%s'.\n\n", DB_FILE_NAME);

// -- ACTION IS HERE --
char key_buf[USER_MAX_KEY_SIZE];
char key_buf[USER_KEY_BUF_SIZE];
char val_buf[USER_MAX_VALUE_SIZE];

int nrows = 0;
Expand Down Expand Up @@ -88,7 +88,7 @@ main()
val_len <<= 1, nrows++)
{

char key_buf[USER_MAX_KEY_SIZE];
char key_buf[USER_KEY_BUF_SIZE];
snprintf(key_buf, sizeof(key_buf), "Key with val_len=%d", val_len);
size_t key_len = strlen(key_buf);

Expand Down
3 changes: 0 additions & 3 deletions include/splinterdb/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ typedef void (*message_to_str_fn)(const data_config *cfg,
* to do something differently, it has to provide these implementations.
*/
struct data_config {
// FIXME: Planned for deprecation.
uint64 max_key_size;

key_compare_fn key_compare;
key_hash_fn key_hash;
/* The merge functions may be NULL, in which case
Expand Down
3 changes: 1 addition & 2 deletions include/splinterdb/default_data_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ extern "C" {
#endif

void
default_data_config_init(const uint64 max_key_size, // IN
data_config *out_cfg // OUT
default_data_config_init(data_config *out_cfg // OUT
);

#ifdef __cplusplus
Expand Down
4 changes: 0 additions & 4 deletions src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,10 +1420,6 @@ core_insert(core_handle *spl,
ts = platform_get_timestamp();
}

if (core_max_key_size(spl) < key_length(tuple_key)) {
return STATUS_BAD_PARAM;
}

if (message_class(data) == MESSAGE_TYPE_DELETE) {
data = DELETE_MESSAGE;
}
Expand Down
6 changes: 0 additions & 6 deletions src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,6 @@ core_print_extent_counts(platform_log_handle *log_handle, core_handle *spl);
void
core_print_space_use(platform_log_handle *log_handle, core_handle *spl);

static inline uint64
core_max_key_size(core_handle *spl)
{
return spl->cfg.data_cfg->max_key_size;
}

static inline int
core_key_compare(core_handle *spl, key key1, key key2)
{
Expand Down
4 changes: 1 addition & 3 deletions src/default_data_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@ message_to_string(const data_config *cfg,
* with default values.
*/
void
default_data_config_init(const size_t max_key_size, // IN
data_config *out_cfg // OUT
default_data_config_init(data_config *out_cfg // OUT
)
{
data_config cfg = {
.max_key_size = max_key_size,
.key_compare = key_compare,
.key_hash = key_hash,
.merge_tuples = NULL,
Expand Down
1 change: 0 additions & 1 deletion src/splinterdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ splinterdb_config_set_defaults(splinterdb_config *cfg)
static platform_status
splinterdb_validate_app_data_config(const data_config *cfg)
{
platform_assert(cfg->max_key_size > 0);
platform_assert(cfg->key_compare != NULL);
platform_assert(cfg->key_hash != NULL);
platform_assert(cfg->key_to_string != NULL);
Expand Down
8 changes: 4 additions & 4 deletions tests/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ config_set_defaults(master_config *cfg)
.wait_for_gdb = FALSE,

.log_handle = NULL,
.max_key_size = TEST_CONFIG_DEFAULT_KEY_SIZE,
.key_size = TEST_CONFIG_DEFAULT_KEY_SIZE,
.message_size = TEST_CONFIG_DEFAULT_MESSAGE_SIZE,
.num_inserts = TEST_CONFIG_DEFAULT_NUM_INSERTS,
.seed = TEST_CONFIG_DEFAULT_SEED,
Expand Down Expand Up @@ -370,7 +370,7 @@ config_parse(master_config *cfg, const uint8 num_config, int argc, char *argv[])
}
}

config_set_uint64("key-size", cfg, max_key_size) {}
config_set_uint64("key-size", cfg, key_size) {}
config_set_uint64("data-size", cfg, message_size) {}

// Test-execution configuration parameters
Expand Down Expand Up @@ -412,9 +412,9 @@ config_parse(master_config *cfg, const uint8 num_config, int argc, char *argv[])
(MAX_PAGES_PER_EXTENT * cfg[cfg_idx].page_size));
return STATUS_BAD_PARAM;
}
if (cfg[cfg_idx].max_key_size < TEST_CONFIG_MIN_KEY_SIZE) {
if (cfg[cfg_idx].key_size < TEST_CONFIG_MIN_KEY_SIZE) {
platform_error_log("Configured key-size, %lu.\n",
cfg[cfg_idx].max_key_size);
cfg[cfg_idx].key_size);
return STATUS_BAD_PARAM;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ typedef struct master_config {
platform_log_handle *log_handle;

// data
uint64 max_key_size;
uint64 key_size;
uint64 message_size;

// Test-execution configuration parameters
Expand Down
47 changes: 18 additions & 29 deletions tests/functional/btree_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ typedef struct test_btree_config {
test_key_type type;
uint64 semiseq_freq;
uint64 period;
uint64 key_size;
test_message_generator *msggen;
} test_btree_config;

Expand Down Expand Up @@ -161,13 +162,13 @@ test_btree_tuple(test_memtable_context *ctxt,
uint64 thread_id)
{
test_btree_config *cfg = ctxt->cfg;
key_buffer_resize(keybuf, cfg->mt_cfg->btree_cfg->data_cfg->max_key_size);
key_buffer_resize(keybuf, cfg->key_size);
test_key(keybuf,
cfg->type,
seq,
thread_id,
cfg->semiseq_freq,
cfg->mt_cfg->btree_cfg->data_cfg->max_key_size,
cfg->key_size,
cfg->period);

if (data != NULL) {
Expand Down Expand Up @@ -1034,9 +1035,7 @@ test_btree_merge_basic(cache *cc,
for (uint64 pivot_no = 0; pivot_no < arity; pivot_no++) {
key_buffer_init(&pivot_key[pivot_no], hid);
pivot[pivot_no] = pivot_no * (max_key / arity + 1);
test_int_to_key(&pivot_key[pivot_no],
pivot[pivot_no],
btree_cfg->data_cfg->max_key_size);
test_int_to_key(&pivot_key[pivot_no], pivot[pivot_no], cfg->key_size);
}
key_buffer_init_from_key(&pivot_key[arity], hid, POSITIVE_INFINITY_KEY);

Expand Down Expand Up @@ -1188,20 +1187,8 @@ test_btree_count_in_range(cache *cc,

platform_status rc = STATUS_OK;
for (uint64 i = 0; i < iterations; i++) {
test_key(&bound_key[0],
TEST_RANDOM,
2 * i,
0,
0,
btree_cfg->data_cfg->max_key_size,
0);
test_key(&bound_key[1],
TEST_RANDOM,
2 * i + 1,
0,
0,
btree_cfg->data_cfg->max_key_size,
0);
test_key(&bound_key[0], TEST_RANDOM, 2 * i, 0, 0, cfg->key_size, 0);
test_key(&bound_key[1], TEST_RANDOM, 2 * i + 1, 0, 0, cfg->key_size, 0);

btree_pivot_stats stats;
key min_key = key_buffer_key(&bound_key[0]);
Expand Down Expand Up @@ -1326,10 +1313,10 @@ test_btree_rough_iterator(cache *cc,
key curr_key;
message dummy_data;
iterator_curr(&rough_merge_itor->super, &curr_key, &dummy_data);
if (key_length(curr_key) != btree_cfg->data_cfg->max_key_size) {
if (key_length(curr_key) != cfg->key_size) {
platform_default_log("Weird key length: %lu should be: %lu\n",
key_length(curr_key),
btree_cfg->data_cfg->max_key_size);
cfg->key_size);
}
if (message_length(dummy_data) != sizeof(btree_pivot_data)) {
platform_default_log("Weird data length: %lu should be == "
Expand Down Expand Up @@ -1428,9 +1415,7 @@ test_btree_merge_perf(cache *cc,
for (uint64 pivot_no = 0; pivot_no < arity; pivot_no++) {
key_buffer_init(&pivot_key[pivot_no], hid);
pivot[pivot_no] = pivot_no * (max_key / arity + 1);
test_int_to_key(&pivot_key[pivot_no],
pivot[pivot_no],
btree_cfg->data_cfg->max_key_size);
test_int_to_key(&pivot_key[pivot_no], pivot[pivot_no], cfg->key_size);
}
key_buffer_init_from_key(&pivot_key[arity], hid, POSITIVE_INFINITY_KEY);

Expand Down Expand Up @@ -1573,9 +1558,11 @@ btree_test(int argc, char *argv[])
platform_get_module_id(), 512 * MiB, use_shmem, &hid);
platform_assert_status_ok(rc);

uint64 num_bg_threads[NUM_TASK_TYPES] = {0}; // no bg threads
uint64 num_bg_threads[NUM_TASK_TYPES] = {0}; // no bg threads
test_workload_config workload_cfg;

rc = test_parse_args(&system_cfg,
&workload_cfg,
&seed,
&gen,
&num_bg_threads[TASK_TYPE_MEMTABLE],
Expand All @@ -1585,8 +1572,11 @@ btree_test(int argc, char *argv[])

memtable_config *mt_cfg = &system_cfg.splinter_cfg.mt_cfg;
mt_cfg->max_memtables = 128;
test_btree_config test_cfg = {
.mt_cfg = mt_cfg, .type = TEST_RANDOM, .semiseq_freq = 0, .msggen = &gen};
test_btree_config test_cfg = {.mt_cfg = mt_cfg,
.type = TEST_RANDOM,
.semiseq_freq = 0,
.key_size = workload_cfg.key_size,
.msggen = &gen};
if (!SUCCESS(rc)) {
platform_error_log("btree_test: failed to parse config: %s\n",
platform_status_to_string(rc));
Expand Down Expand Up @@ -1647,8 +1637,7 @@ btree_test(int argc, char *argv[])
uint64 max_tuples_per_memtable =
test_cfg.mt_cfg->max_extents_per_memtable
* cache_config_extent_size((cache_config *)&system_cfg.cache_cfg) / 3
/ (system_cfg.data_cfg->max_key_size
+ generator_average_message_size(&gen));
/ (workload_cfg.key_size + generator_average_message_size(&gen));
if (run_perf_test) {
uint64 total_inserts = 64 * max_tuples_per_memtable;

Expand Down
1 change: 1 addition & 0 deletions tests/functional/cache_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ cache_test(int argc, char *argv[])
core_config *splinter_cfg = TYPED_MALLOC(hid, splinter_cfg);

rc = test_parse_args(&system_cfg,
NULL,
&seed,
&gen,
&num_bg_threads[TASK_TYPE_MEMTABLE],
Expand Down
Loading
Loading