Search in sources :

Example 16 with RecordBuffer

use of org.apache.jena.tdb.base.buffer.RecordBuffer in project jena by apache.

the class TestRecordBuffer method recBuffer05.

// Shift at middle
@Test
public void recBuffer05() {
    RecordBuffer rb = make(4, 5);
    contains(rb, 2, 4, 6, 8);
    rb.shiftUp(2);
    rb.set(2, r(0));
    contains(rb, 2, 4, 0, 6, 8);
    rb.shiftDown(2);
    contains(rb, 2, 4, 6, 8);
}
Also used : RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 17 with RecordBuffer

use of org.apache.jena.tdb.base.buffer.RecordBuffer in project jena by apache.

the class TestRecordBuffer method recBuffer01.

@Test
public void recBuffer01() {
    RecordBuffer rb = make(4, 4);
    contains(rb, 2, 4, 6, 8);
}
Also used : RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 18 with RecordBuffer

use of org.apache.jena.tdb.base.buffer.RecordBuffer in project jena by apache.

the class RecordBufferPageBase method reset.

protected void reset(Block block, int count) {
    ByteBuffer bb = block.getByteBuffer();
    bb.clear();
    bb.position(headerLength);
    bb = bb.slice();
    this.recBuff = new RecordBuffer(bb, factory, count);
}
Also used : RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer) ByteBuffer(java.nio.ByteBuffer)

Example 19 with RecordBuffer

use of org.apache.jena.tdb.base.buffer.RecordBuffer in project jena by apache.

the class BPlusTreeTools method bpt_scan_record_buffer.

/*public*/
private static void bpt_scan_record_buffer(RecordBufferPageMgr recordPageMgr, boolean verbose) {
    System.out.print("[Scan Records] start\n");
    int idx = 0;
    int n = 0;
    int total = 0;
    if (verbose)
        System.out.printf("recordPageMgr = %s\n", recordPageMgr);
    // Blocks in scan order
    try {
        while (idx >= 0) {
            if (verbose)
                System.out.printf("idx = %d\n", idx);
            RecordBufferPage page = recordPageMgr.getRead(idx);
            if (verbose)
                System.out.printf("%04d :: id=%04d -> link=%04d [count=%d, max=%d]\n", n, page.getId(), page.getLink(), page.getCount(), page.getMaxSize());
            RecordBuffer rb = page.getRecordBuffer();
            if (verbose)
                System.out.printf("     :: %d %d\n", rb.getSize(), rb.maxSize());
            total += rb.size();
            idx = page.getLink();
            n++;
            recordPageMgr.release(page);
        }
    } catch (Exception ex) {
        System.out.println("Exception: " + ex);
    }
    System.out.printf("[Scan Records] Count = %d in %d blocks (avg: %.2f)\n", total, n, ((float) total) / n);
}
Also used : RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer) IOException(java.io.IOException) RecordBufferPage(org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)

Example 20 with RecordBuffer

use of org.apache.jena.tdb.base.buffer.RecordBuffer in project jena by apache.

the class RecordBufferPagePacker method hasNext.

@Override
public boolean hasNext() {
    if (recordBufferPage == null) {
        if (records == null)
            return false;
        if (!records.hasNext()) {
            records = null;
            return false;
        }
        // At least one record to be processed.
        // No pending RecordBufferPage
        // ==> There will be a RecordBufferPage to yield.
        //            int id = rbMgr.allocateId() ;
        //            //System.out.println("Allocate : "+id) ;
        recordBufferPage = rbMgr.create();
        RecordBuffer rb = recordBufferPage.getRecordBuffer();
        while (!rb.isFull() && records.hasNext()) {
            Record r = records.next();
            rb.add(r);
        }
        if (!records.hasNext())
            records = null;
        return true;
    }
    return true;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RecordBuffer(org.apache.jena.tdb.base.buffer.RecordBuffer)

Aggregations

RecordBuffer (org.apache.jena.tdb.base.buffer.RecordBuffer)34 BaseTest (org.apache.jena.atlas.junit.BaseTest)26 Test (org.junit.Test)26 Record (org.apache.jena.tdb.base.record.Record)14 RecordLib.intToRecord (org.apache.jena.tdb.base.record.RecordLib.intToRecord)11 PtrBuffer (org.apache.jena.tdb.base.buffer.PtrBuffer)3 ByteBuffer (java.nio.ByteBuffer)2 IOException (java.io.IOException)1 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)1