From fd43534b0e9c63aa9e00d856cc1f4cb5988de467 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 20 Jun 2023 02:54:07 -0500 Subject: [PATCH] Renamed lfsr_btree_update -> lfsr_btree_set --- lfs.c | 11 +++++------ tests/test_btree.toml | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lfs.c b/lfs.c index b0e9a457..b4886efc 100644 --- a/lfs.c +++ b/lfs.c @@ -4153,7 +4153,7 @@ static int lfsr_btree_push(lfs_t *lfs, lfsr_btree_t *btree, } } -static int lfsr_btree_update(lfs_t *lfs, lfsr_btree_t *btree, +static int lfsr_btree_set(lfs_t *lfs, lfsr_btree_t *btree, lfs_size_t bid, lfsr_tag_t tag, lfs_size_t weight, lfsr_data_t data) { LFS_ASSERT(bid < lfsr_btree_weight(btree)); LFS_ASSERT(lfsr_btree_weight(btree) > 0); @@ -5119,7 +5119,7 @@ static int lfsr_mtree_split_(lfs_t *lfs, lfsr_btree_t *mtree, return d; } - err = lfsr_btree_update(lfs, mtree, mid, LFSR_TAG_MDIR, 1, + err = lfsr_btree_set(lfs, mtree, mid, LFSR_TAG_MDIR, 1, LFSR_DATA_BUF(buf, d)); if (err) { return err; @@ -5137,7 +5137,7 @@ static int lfsr_mtree_split_(lfs_t *lfs, lfsr_btree_t *mtree, return d; } - err = lfsr_btree_update(lfs, mtree, mid, LFSR_TAG_MDIR, 1, + err = lfsr_btree_set(lfs, mtree, mid, LFSR_TAG_MDIR, 1, LFSR_DATA_BUF(buf, d)); if (err) { return err; @@ -5160,8 +5160,7 @@ static int lfsr_mtree_split_(lfs_t *lfs, lfsr_btree_t *mtree, return 0; } -// TODO static -int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, lfs_ssize_t *rid, +static int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, lfs_ssize_t *rid, const lfsr_attr_t *attrs, lfs_size_t attr_count) { LFS_ASSERT(mdir->mid != LFSR_MID_RM); @@ -5325,7 +5324,7 @@ int lfsr_mdir_commit(lfs_t *lfs, lfsr_mdir_t *mdir, lfs_ssize_t *rid, return d; } - err = lfsr_btree_update(lfs, &mtree_, mdir->mid, LFSR_TAG_MDIR, 1, + err = lfsr_btree_set(lfs, &mtree_, mdir->mid, LFSR_TAG_MDIR, 1, LFSR_DATA_BUF(buf, d)); if (err) { return err; diff --git a/tests/test_btree.toml b/tests/test_btree.toml index 3bc82203..faabc126 100644 --- a/tests/test_btree.toml +++ b/tests/test_btree.toml @@ -719,7 +719,7 @@ code = ''' lfsr_btree_push(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("a", 1)) => 0; // update the tree - lfsr_btree_update(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("A", 1)) => 0; printf("btree: w%d 0x%x.%x\n", btree.weight, @@ -762,9 +762,9 @@ code = ''' lfsr_btree_push(&lfs, &btree, 1, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("b", 1)) => 0; // update the tree - lfsr_btree_update(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("A", 1)) => 0; - lfsr_btree_update(&lfs, &btree, 1, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 1, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("B", 1)) => 0; printf("btree: w%d 0x%x.%x\n", btree.weight, @@ -815,11 +815,11 @@ code = ''' lfsr_btree_push(&lfs, &btree, 2, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("c", 1)) => 0; // update the tree - lfsr_btree_update(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 0, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("A", 1)) => 0; - lfsr_btree_update(&lfs, &btree, 1, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 1, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("B", 1)) => 0; - lfsr_btree_update(&lfs, &btree, 2, LFSR_TAG_INLINED, 1, + lfsr_btree_set(&lfs, &btree, 2, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF("C", 1)) => 0; printf("btree: w%d 0x%x.%x\n", btree.weight, @@ -887,7 +887,7 @@ code = ''' } // update the tree for (lfs_size_t i = 0; i < N; i++) { - int err = lfsr_btree_update(&lfs, &btree, i, LFSR_TAG_INLINED, 1, + int err = lfsr_btree_set(&lfs, &btree, i, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF(&uppers[i % 26], 1)); // ignore space issues if (err == LFS_ERR_NOSPC) { @@ -982,7 +982,7 @@ code = ''' lfs_size_t id = TEST_PRNG(&prng) % N; // update btree - int err = lfsr_btree_update(&lfs, &btree, id, LFSR_TAG_INLINED, 1, + int err = lfsr_btree_set(&lfs, &btree, id, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF(&uppers[i % 26], 1)); // ignore space issues if (err == LFS_ERR_NOSPC) { @@ -1065,7 +1065,7 @@ code = ''' } // update the tree for (lfs_size_t i = 0; i < N; i++) { - int err = lfsr_btree_update(&lfs, &btree, i*W+W-1, LFSR_TAG_INLINED, W, + int err = lfsr_btree_set(&lfs, &btree, i*W+W-1, LFSR_TAG_INLINED, W, LFSR_DATA_BUF(&uppers[i % 26], 1)); // ignore space issues if (err == LFS_ERR_NOSPC) { @@ -1187,7 +1187,7 @@ code = ''' } // update btree - int err = lfsr_btree_update(&lfs, &btree, + int err = lfsr_btree_set(&lfs, &btree, weighted_id+sim_weights[id]-1, LFSR_TAG_INLINED, weight, LFSR_DATA_BUF(&uppers[i % 26], 1)); // ignore space issues @@ -2575,7 +2575,7 @@ code = ''' } else if (op == 1) { // update btree - int err = lfsr_btree_update(&lfs, &btree, id, + int err = lfsr_btree_set(&lfs, &btree, id, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF(&alphas[i % 26], 1)); // ignore space issues @@ -2716,7 +2716,7 @@ code = ''' } else if (op == 1) { // update btree - int err = lfsr_btree_update(&lfs, &btree, + int err = lfsr_btree_set(&lfs, &btree, weighted_id+sim_weights[id]-1, LFSR_TAG_INLINED, weight, LFSR_DATA_BUF(&alphas[i % 26], 1)); // ignore space issues @@ -3623,7 +3623,7 @@ code = ''' } else if (op == 1) { // update btree - int err = lfsr_btree_update(&lfs, &btree, id, + int err = lfsr_btree_set(&lfs, &btree, id, LFSR_TAG_INLINED, 1, LFSR_DATA_BUF(&nums[i % 10], 1)); // ignore space issues @@ -3830,7 +3830,7 @@ code = ''' } else if (op == 1) { // update btree - int err = lfsr_btree_update(&lfs, &btree, + int err = lfsr_btree_set(&lfs, &btree, weighted_id+sim_weights[id]-1, LFSR_TAG_INLINED, weight, LFSR_DATA_BUF(&nums[i % 10], 1)); // ignore space issues