Search in sources :

Example 86 with Record

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

the class TestBPTreeRecords method bpt_records_6.

@Test
public void bpt_records_6() {
    BPTreeRecords bpr = make();
    fill(bpr);
    // No match.
    assertNull(bpr.internalSearch(RecordLib.intToRecord(0x20)));
    Record r = RecordLib.intToRecord(0x32);
    Record r2 = search(bpr, r);
    assertTrue(Record.keyEQ(r, r2));
    r = bpr.getLowRecord();
    r2 = search(bpr, r);
    assertTrue(Record.keyEQ(r, r2));
    r = bpr.getHighRecord();
    r2 = search(bpr, r);
    assertTrue(Record.keyEQ(r, r2));
    bpr.release();
}
Also used : Record(org.apache.jena.tdb.base.record.Record) Test(org.junit.Test)

Example 87 with Record

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

the class TestBPlusTreeRewriter method scanComparision.

public static void scanComparision(List<Record> originaldata, BPlusTree bpt2) {
    // ** Scan comparison
    Iterator<Record> iter1 = originaldata.iterator();
    Iterator<Record> iter2 = bpt2.iterator();
    long count = 0;
    for (; iter1.hasNext(); ) {
        count++;
        Record r1 = iter1.next();
        if (!iter2.hasNext())
            error("Deviation: new B+Tree is smaller");
        Record r2 = iter2.next();
        if (!Record.equals(r1, r2))
            error("Deviation in iteration record %d: %s : %s", count, r1, r2);
    }
    if (iter2.hasNext())
        error("New B+Tree larger than original");
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 88 with Record

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

the class ExtHashTestBase method create.

public static ExtHash create(int... recs) {
    ExtHash extHash = make();
    for (int i : recs) {
        Record r = intToRecord(i);
        extHash.add(r);
        if (false)
            extHash.dump();
    }
    return extHash;
}
Also used : Record(org.apache.jena.tdb.base.record.Record)

Example 89 with Record

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

the class ProcIndexBuild method exec.

public static void exec(String locationStr, String indexName, String dataFile) {
    // Argument processing
    Location location = Location.create(locationStr);
    // InputStream input = System.in ;
    InputStream input = IO.openFile(dataFile);
    int keyLength = SystemTDB.SizeOfNodeId * indexName.length();
    int valueLength = 0;
    // The name is the order.
    String primary = indexName;
    // Scope for optimization:
    // Null column map => no churn.
    // Do record -> record copy, not Tuple, Tuple copy.
    String primaryOrder;
    int dftKeyLength;
    int dftValueLength;
    int tupleLength = indexName.length();
    if (tupleLength == 3) {
        primaryOrder = Names.primaryIndexTriples;
        dftKeyLength = SystemTDB.LenIndexTripleRecord;
        dftValueLength = 0;
    } else if (tupleLength == 4) {
        primaryOrder = Names.primaryIndexQuads;
        dftKeyLength = SystemTDB.LenIndexQuadRecord;
        dftValueLength = 0;
    } else {
        throw new AtlasException("Index name: " + indexName);
    }
    ColumnMap colMap = new ColumnMap(primaryOrder, indexName);
    // -1? Write only.
    // Also flush cache every so often => block writes (but not sequential so boring).
    int readCacheSize = 10;
    int writeCacheSize = 100;
    int blockSize = SystemTDB.BlockSize;
    RecordFactory recordFactory = new RecordFactory(dftKeyLength, dftValueLength);
    int order = BPlusTreeParams.calcOrder(blockSize, recordFactory);
    BPlusTreeParams bptParams = new BPlusTreeParams(order, recordFactory);
    int blockSizeNodes = blockSize;
    int blockSizeRecords = blockSize;
    FileSet destination = new FileSet(location, indexName);
    BlockMgr blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
    BlockMgr blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
    int rowBlock = 1000;
    Iterator<Record> iter = new RecordsFromInput(input, tupleLength, colMap, rowBlock);
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iter, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
    bpt2.close();
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) BPlusTreeParams(org.apache.jena.tdb.index.bplustree.BPlusTreeParams) FileSet(org.apache.jena.tdb.base.file.FileSet) InputStream(java.io.InputStream) AtlasException(org.apache.jena.atlas.AtlasException) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) Record(org.apache.jena.tdb.base.record.Record) BPlusTree(org.apache.jena.tdb.index.bplustree.BPlusTree) Location(org.apache.jena.tdb.base.file.Location)

Example 90 with Record

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

the class RecordsFromInput method next.

@Override
public Record next() {
    if (!hasNext())
        throw new NoSuchElementException();
    Record r = slot;
    slot = null;
    return r;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

Record (org.apache.jena.tdb.base.record.Record)95 Test (org.junit.Test)20 RecordLib.intToRecord (org.apache.jena.tdb.base.record.RecordLib.intToRecord)15 RecordBuffer (org.apache.jena.tdb.base.buffer.RecordBuffer)14 BaseTest (org.apache.jena.atlas.junit.BaseTest)10 RangeIndex (org.apache.jena.tdb.index.RangeIndex)8 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)6 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)6 NoSuchElementException (java.util.NoSuchElementException)5 FileSet (org.apache.jena.tdb.base.file.FileSet)5 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)5 NodeId (org.apache.jena.tdb.store.NodeId)5 Pair (org.apache.jena.atlas.lib.Pair)4 Location (org.apache.jena.tdb.base.file.Location)4 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)4 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)3 StorageException (org.apache.jena.tdb.base.StorageException)3 RecordBufferPage (org.apache.jena.tdb.base.recordbuffer.RecordBufferPage)3 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)3 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)3