Beispiel #1
0
def test_lsm_tree_large_inserts(test_folder):
    n = 30000
    tree = LSMTree(test_folder)
    for i in range(n):
        tree.insert(i), i
    for i in range(n):
        assert tree.query(i), i
    assert not tree.query(n)
Beispiel #2
0
def test_lsm_tree_random_inserts(test_folder):
    n = 3000
    arr = np.arange(n)
    np.random.shuffle(arr)
    tree = LSMTree(test_folder)
    for i in arr:
        tree.insert(i), i
    for i in arr:
        assert tree.query(i), i
    assert not tree.query(n)
Beispiel #3
0
def test_lsm_tree_large_random_inserts(test_folder):
    n = 100000
    arr = np.arange(n)
    rng = np.random.RandomState(42)
    rng.shuffle(arr)
    tree = LSMTree(test_folder)
    for i in arr:
        tree.insert(i), i
    for i in np.arange(n):
        assert tree.query(i), i
    assert not tree.query(n)
Beispiel #4
0
def get_wods(wods_type, block_size, n_blocks, n_input_data):
    path = f'./experiments/{wods_type}'
    shutil.rmtree(path, ignore_errors=True)
    params = {
        'block_size': block_size,
        'n_blocks': n_blocks,
        'n_input_data': n_input_data,
    }
    if wods_type == 'b_epsilon_tree':
        return BEpsilonTree(disk_filepath=path, **params, b=8)
    elif wods_type == 'b_tree':
        return BTree(disk_filepath=path, **params, b=8)
    elif wods_type == 'lsm_tree':
        return LSMTree(disk_filepath=path, enable_bloomfilter=False, growth_factor=16, **params)
    elif wods_type == 'lsm_bf_tree':
        return LSMTree(disk_filepath=path, enable_bloomfilter=True, growth_factor=16, **params)
    elif wods_type == 'basic_cola':
        return BasicCola(disk_filepath=path, growth_factor=16, **params)
    elif wods_type == 'fractional_cola':
        return FractionalCola(disk_filepath=path, growth_factor=16, **params)
    elif wods_type == 'basic_bloom_cola':
        return BasicBloomCola(disk_filepath=path, growth_factor=16, **params)
Beispiel #5
0
def test_level_metadata():
    metadata = LSMTree.LevelMetadata()
    metadata.insert(3, 3)
    metadata.insert(1, 1)
    metadata.insert(2, 2)
    metadata.insert(4, 4)
    metadata.insert(5, 5)
    assert len(metadata) == 5
    assert metadata.uuids == [1, 2, 3, 4, 5]
    assert metadata.first_indices == [1, 2, 3, 4, 5]
    metadata.clear(2, 4)
    assert len(metadata) == 3
    assert metadata.uuids == [1, 2, 5]
    assert metadata.first_indices == [1, 2, 5]
    metadata.insert(3, 3)
    assert len(metadata) == 4
    assert metadata.uuids == [1, 2, 3, 5]
    assert metadata.first_indices == [1, 2, 3, 5]
    metadata.clear()
    assert len(metadata) == 0
    assert metadata.uuids == []
    assert metadata.first_indices == []
Beispiel #6
0
def test_lsm_tree_reverse_inserts(test_folder):
    n = 1000000
    tree = LSMTree(test_folder)
    for i in reversed(range(n)):
        tree.insert(i), i
    assert not tree.query(n)