Search in sources :

Example 1 with AllocatorImpl

use of suite.file.impl.AllocatorImpl in project suite by stupidsing.

the class B_TreeBuilder method build.

private B_Tree<Key, Value> build(Comparator<Key> comparator, PageFile alf0, PageFile sbf0, PageFile pf0) {
    B_TreeImpl<Key, Value> b_tree = new B_TreeImpl<>(Object_.nullsFirst(comparator));
    Serializer<Bytes> als = serialize.bytes(pageSize);
    B_TreeSuperblockSerializer sbs = new B_TreeSuperblockSerializer(b_tree);
    Serializer<Bytes> pys = serialize.bytes(pageSize);
    B_TreePageSerializer ps = new B_TreePageSerializer(b_tree);
    SerializedPageFile<Bytes> alf = SerializedFileFactory.serialized(alf0, als);
    SerializedPageFile<B_TreeImpl<Key, Value>.Superblock> sbf = SerializedFileFactory.serialized(sbf0, sbs);
    SerializedPageFile<Bytes> pyf = SerializedFileFactory.serialized(pf0, pys);
    SerializedPageFile<B_TreeImpl<Key, Value>.Page> pf = SerializedFileFactory.serialized(pf0, ps);
    b_tree.setAllocator(new AllocatorImpl(alf));
    b_tree.setSuperblockPageFile(sbf);
    b_tree.setPayloadFile(pyf);
    b_tree.setPageFile(pf);
    b_tree.setBranchFactor(16);
    return b_tree;
}
Also used : Bytes(suite.primitive.Bytes) AllocatorImpl(suite.file.impl.AllocatorImpl)

Example 2 with AllocatorImpl

use of suite.file.impl.AllocatorImpl in project suite by stupidsing.

the class B_TreeBuilder method build.

public B_Tree<Key, Value> build(PageFile f, int nPages, Comparator<Key> cmp) {
    var nSuperblockPages = 1;
    var nAllocatorPages = nPages / pageSize;
    var p0 = 0;
    var p1 = p0 + nAllocatorPages;
    var p2 = p1 + nSuperblockPages;
    var p3 = p2 + nPages;
    var pfs = FileFactory.subPageFiles(f, p0, p1, p2, p3);
    return FixieArray.of(pfs).map((alf0, sbf0, pf0) -> {
        var b_tree = new B_TreeImpl<Key, Value>(Comparator.nullsFirst(cmp));
        var als = ser.bytes(pageSize);
        var sbs = superblockSerializer(b_tree);
        var pys = ser.bytes(pageSize);
        var ps = pageSerializer(b_tree);
        var alf = SerializedFileFactory.serialized(alf0, als);
        var sbf = SerializedFileFactory.serialized(sbf0, sbs);
        var pyf = SerializedFileFactory.serialized(pf0, pys);
        var pf = SerializedFileFactory.serialized(pf0, ps);
        b_tree.setAllocator(new AllocatorImpl(alf));
        b_tree.setSuperblockPageFile(sbf);
        b_tree.setPayloadFile(pyf);
        b_tree.setPageFile(pf);
        b_tree.setBranchFactor(16);
        return b_tree;
    });
}
Also used : AllocatorImpl(suite.file.impl.AllocatorImpl)

Aggregations

AllocatorImpl (suite.file.impl.AllocatorImpl)2 Bytes (suite.primitive.Bytes)1