Search in sources :

Example 26 with Record

use of org.apache.jena.dboe.base.record.Record in project jena by apache.

the class TestRecordBuffer method make.

private static RecordBuffer make(int n, int len) {
    RecordBuffer rb = new RecordBuffer(recordFactory, len);
    for (int i = 0; i < n; i++) {
        Record r = RecordLib.intToRecord(2 * i + 2);
        rb.add(r);
    }
    return rb;
}
Also used : RecordLib.intToRecord(org.apache.jena.dboe.test.RecordLib.intToRecord) Record(org.apache.jena.dboe.base.record.Record)

Example 27 with Record

use of org.apache.jena.dboe.base.record.Record in project jena by apache.

the class BPlusTreeRewriterUtils method printIndexBlocks.

static Iterator<Pair<Integer, Record>> printIndexBlocks(Iterator<Pair<Integer, Record>> iter2, BPTreeNodeMgr bptNodeMgr) {
    divider();
    List<Pair<Integer, Record>> pairs = Iter.toList(iter2);
    System.out.printf(">>Packed index blocks\n");
    for (Pair<Integer, Record> pair : pairs) {
        System.out.printf("  %s\n", pair);
        BPTreeNode bpNode = bptNodeMgr.getRead(pair.car(), BPlusTreeParams.RootParent);
        bpNode.setIsLeaf(true);
        System.out.printf("BPTreeNode: %d\n", bpNode.getId());
        System.out.println(bpNode);
        bptNodeMgr.release(bpNode);
    }
    System.out.printf("<<Packed index blocks\n");
    return pairs.iterator();
}
Also used : BPTreeNode(org.apache.jena.dboe.trans.bplustree.BPTreeNode) Record(org.apache.jena.dboe.base.record.Record) Pair(org.apache.jena.atlas.lib.Pair)

Example 28 with Record

use of org.apache.jena.dboe.base.record.Record in project jena by apache.

the class BPlusTreeRewriterUtils method printDataBlocks.

private static Iterator<Pair<Integer, Record>> printDataBlocks(Iterator<Pair<Integer, Record>> iter, RecordBufferPageMgr recordPageMgr) {
    divider();
    List<Pair<Integer, Record>> pairs = Iter.toList(iter);
    System.out.printf(">>Packed data blocks\n");
    for (Pair<Integer, Record> pair : pairs) {
        System.out.printf("  %s\n", pair);
        RecordBufferPage rbp = recordPageMgr.getRead(pair.car());
        // System.out.printf("RecordBufferPage[id=%d,link=%d] %d\n",
        // rbp.getId(), rbp.getLink(), rbp.getCount() );
        System.out.println(rbp);
        recordPageMgr.release(rbp);
    }
    System.out.printf("<<Packed data blocks\n");
    System.out.printf("Blocks: %d\n", pairs.size());
    return pairs.iterator();
}
Also used : Record(org.apache.jena.dboe.base.record.Record) Pair(org.apache.jena.atlas.lib.Pair) RecordBufferPage(org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)

Example 29 with Record

use of org.apache.jena.dboe.base.record.Record in project jena by apache.

the class BPlusTreeRewriterUtils method summarizeIndexBlocks.

static Iterator<Pair<Integer, Record>> summarizeIndexBlocks(Iterator<Pair<Integer, Record>> iter2, BPTreeNodeMgr bptNodeMgr) {
    divider();
    List<Pair<Integer, Record>> pairs = Iter.toList(iter2);
    for (Pair<Integer, Record> pair : pairs) {
        BPTreeNode bpNode = bptNodeMgr.getRead(pair.car(), BPlusTreeParams.RootParent);
        String hr = "null";
        if (!bpNode.getRecordBuffer().isEmpty())
            hr = bpNode.getRecordBuffer().getHigh().toString();
        System.out.printf("%s -- BPTreeNode: %d (%d) -> [%s]\n", pair, bpNode.getId(), bpNode.getCount(), hr);
        bptNodeMgr.release(bpNode);
    }
    return pairs.iterator();
}
Also used : BPTreeNode(org.apache.jena.dboe.trans.bplustree.BPTreeNode) Record(org.apache.jena.dboe.base.record.Record) Pair(org.apache.jena.atlas.lib.Pair)

Example 30 with Record

use of org.apache.jena.dboe.base.record.Record in project jena by apache.

the class TestBPlusTreeRewriterNonTxn method runOneTest.

public static void runOneTest(int order, int N, RecordFactory recordFactory, boolean debug) {
    BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
    BPlusTreeRewriter.debug = debug;
    // ---- Test data
    List<Record> originaldata = TestBPlusTreeRewriterNonTxn.createData(N, recordFactory);
    if (debug)
        System.out.println("Test data: " + originaldata);
    FileSet destination = FileSet.mem();
    // ---- Rewrite
    BufferChannel rootState = FileFactory.createBufferChannel(destination, Names.extBptState);
    // Write leaves to ...
    BlockMgr blkMgr1 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
    // Write nodes to ...
    BlockMgr blkMgr2 = BlockMgrFactory.create(destination, Names.extBptTree, bptParams.getCalcBlockSize(), 10, 10);
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(originaldata.iterator(), bptParams, recordFactory, rootState, blkMgr1, blkMgr2);
    if (debug) {
        BPlusTreeRewriterUtils.divider();
        bpt2.dump();
    }
    // ---- Checking
    bpt2.check();
    scanComparision(originaldata, bpt2);
    findComparison(originaldata, bpt2);
    sizeComparison(originaldata, bpt2);
}
Also used : BPlusTreeParams(org.apache.jena.dboe.trans.bplustree.BPlusTreeParams) FileSet(org.apache.jena.dboe.base.file.FileSet) BlockMgr(org.apache.jena.dboe.base.block.BlockMgr) BufferChannel(org.apache.jena.dboe.base.file.BufferChannel) Record(org.apache.jena.dboe.base.record.Record) BPlusTree(org.apache.jena.dboe.trans.bplustree.BPlusTree)

Aggregations

Record (org.apache.jena.dboe.base.record.Record)71 RecordLib.intToRecord (org.apache.jena.dboe.test.RecordLib.intToRecord)6 Pair (org.apache.jena.atlas.lib.Pair)5 NoSuchElementException (java.util.NoSuchElementException)3 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)3 FileSet (org.apache.jena.dboe.base.file.FileSet)3 RecordBufferPage (org.apache.jena.dboe.base.recordbuffer.RecordBufferPage)3 BPTreeNode (org.apache.jena.dboe.trans.bplustree.BPTreeNode)3 BPlusTree (org.apache.jena.dboe.trans.bplustree.BPlusTree)3 BPlusTreeParams (org.apache.jena.dboe.trans.bplustree.BPlusTreeParams)3 NodeId (org.apache.jena.tdb2.store.NodeId)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 StorageException (org.apache.jena.dboe.base.StorageException)2 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)2 RecordBuffer (org.apache.jena.dboe.base.buffer.RecordBuffer)2 RecordFactory (org.apache.jena.dboe.base.record.RecordFactory)2 Index (org.apache.jena.dboe.index.Index)2 RangeIndex (org.apache.jena.dboe.index.RangeIndex)2 TDBException (org.apache.jena.tdb2.TDBException)2