Search in sources :

Example 21 with Record

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

the class AbstractTestRangeIndex method tree_iter_0_01.

// Root
@Test
public void tree_iter_0_01() {
    int[] keys = { 1, 2, 3, 4, 5 };
    RangeIndex rIndex = makeRangeIndex(5);
    add(rIndex, keys);
    Iterator<Record> iter = rIndex.iterator(r(2), r(4));
    while (iter.hasNext()) iter.next();
    List<Integer> x = toIntList(rIndex.iterator(r(2), r(4)));
    List<Integer> expected = toIntList(2, 3);
    assertEquals(expected, x);
}
Also used : RecordLib.intToRecord(org.apache.jena.dboe.test.RecordLib.intToRecord) Record(org.apache.jena.dboe.base.record.Record) RangeIndex(org.apache.jena.dboe.index.RangeIndex) Test(org.junit.Test) IndexTestLib.randTest(org.apache.jena.dboe.index.test.IndexTestLib.randTest)

Example 22 with Record

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

the class IndexTestLib method testIndexContents.

public static void testIndexContents(Index index, int... records) {
    List<Integer> x = toIntList(index.iterator());
    // Make a unique list of expected records. Remove duplicates
    List<Integer> y = unique(asList(records));
    assertEquals("Expected records size and tree size different", y.size(), index.size());
    assertEquals("Expected records size and iteration over all keys are of different sizes", y.size(), x.size());
    if (index instanceof RangeIndex) {
        // Check sorted order
        for (int i = 0; i < x.size() - 2; i++) {
            if (x.get(i) > x.get(i + 1)) {
                fail("check failed: " + strings(records));
                return;
            }
        }
    }
    // Check each expected record is in the tree
    for (int k : y) {
        Record rec = intToRecord(k);
        Record r2 = index.find(rec);
        assertNotNull(r2);
    }
}
Also used : RecordLib.intToRecord(org.apache.jena.dboe.test.RecordLib.intToRecord) Record(org.apache.jena.dboe.base.record.Record) RangeIndex(org.apache.jena.dboe.index.RangeIndex)

Example 23 with Record

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

the class IndexLogger method find.

@Override
public Record find(Record record) {
    log.info("Find: {}", record);
    Record r2 = super.find(record);
    log.info("Find: " + record + " ==> " + r2);
    return r2;
}
Also used : Record(org.apache.jena.dboe.base.record.Record)

Example 24 with Record

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

the class AbstractTestIndex method index_find_2.

@Test
public void index_find_2() {
    int[] keys = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    Index index = test(keys);
    Record r = intToRecord(20, RecordLib.TestRecordLength);
    r = index.find(r);
    assertNull(r);
}
Also used : Index(org.apache.jena.dboe.index.Index) RecordLib.intToRecord(org.apache.jena.dboe.test.RecordLib.intToRecord) Record(org.apache.jena.dboe.base.record.Record) Test(org.junit.Test)

Example 25 with Record

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

the class AbstractTestIndex method index_find_1.

@Test
public void index_find_1() {
    int[] keys = { 1 };
    Index index = test(keys);
    Record r = intToRecord(1, RecordLib.TestRecordLength);
    r = index.find(r);
    assertNotNull(r);
}
Also used : Index(org.apache.jena.dboe.index.Index) RecordLib.intToRecord(org.apache.jena.dboe.test.RecordLib.intToRecord) Record(org.apache.jena.dboe.base.record.Record) Test(org.junit.Test)

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