Search in sources :

Example 1 with RangeIndex

use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.

the class ProcRewriteIndex method exec.

public static void exec(Location srcLoc, Location dstLoc, String indexName) {
    FileSet destination = new FileSet(dstLoc, indexName);
    int readCacheSize = 0;
    int writeCacheSize = -1;
    int dftKeyLength;
    int dftValueLength;
    if (indexName.length() == 3) {
        dftKeyLength = SystemTDB.LenIndexTripleRecord;
        dftValueLength = 0;
    } else if (indexName.length() == 4) {
        dftKeyLength = SystemTDB.LenIndexQuadRecord;
        dftValueLength = 0;
    } else {
        System.err.printf("Can't determine record size for %s\n", indexName);
        return;
    }
    RecordFactory recordFactory = null;
    BPlusTreeParams bptParams = null;
    BlockMgr blkMgrNodes;
    BlockMgr blkMgrRecords;
    int blockSize = SystemTDB.BlockSize;
    RangeIndex rangeIndex = SetupIndex.makeRangeIndex(srcLoc, indexName, blockSize, dftKeyLength, dftValueLength, readCacheSize, writeCacheSize);
    BPlusTree bpt = (BPlusTree) rangeIndex;
    bptParams = bpt.getParams();
    recordFactory = bpt.getRecordFactory();
    int blockSizeNodes = blockSize;
    int blockSizeRecords = blockSize;
    blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExtTree, blockSizeNodes, readCacheSize, writeCacheSize);
    blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExtRecords, blockSizeRecords, readCacheSize, writeCacheSize);
    Iterator<Record> iterator = bpt.iterator();
    //            // Fakery.
    //            blkMgrNodes = BlockMgrFactory.create(destination, Names.bptExt1, blockSize, readCacheSize, writeCacheSize) ;
    //            blkMgrRecords = BlockMgrFactory.create(destination, Names.bptExt2, blockSize, readCacheSize, writeCacheSize) ;
    //            recordFactory = new RecordFactory(dftKeyLength, dftValueLength) ;
    //            bptParams = new BPlusTreeParams(3, recordFactory) ;
    //            List<Record> data = TestBPlusTreeRewriter.createData(10, recordFactory) ;
    //            iterator = data.iterator() ;
    //System.out.println("Rewrite: "+srcLoc+" "+indexName+" --> "+destination) ;
    BPlusTree bpt2 = BPlusTreeRewriter.packIntoBPlusTree(iterator, bptParams, recordFactory, blkMgrNodes, blkMgrRecords);
    if (bpt2 == null)
        return;
    //        
    //        Iterator<Record> iter = bpt2.iterator() ;
    //        for ( ; iter.hasNext() ; )
    //        {
    //            Record r = iter.next() ;
    //            System.out.println(r) ;
    //        }
    bpt2.close();
}
Also used : BPlusTreeParams(org.apache.jena.tdb.index.bplustree.BPlusTreeParams) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) FileSet(org.apache.jena.tdb.base.file.FileSet) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) Record(org.apache.jena.tdb.base.record.Record) RangeIndex(org.apache.jena.tdb.index.RangeIndex) BPlusTree(org.apache.jena.tdb.index.bplustree.BPlusTree)

Example 2 with RangeIndex

use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.

the class TestTransIterator method transIter_03.

@Test
public void transIter_03() {
    // Interleaved.
    int[] vals = { 1, 2, 3, 4, 5, 6, 7 };
    RangeIndex rIndex = build(2, vals);
    Iterator<Record> iter1 = rIndex.iterator();
    Iterator<Record> iter2 = rIndex.iterator();
    for (; iter1.hasNext(); ) {
        Record r1 = iter1.next();
        Record r2 = iter2.next();
    }
    assertFalse(iter2.hasNext());
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Test(org.junit.Test)

Example 3 with RangeIndex

use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.

the class IndexAssembler method open.

@Override
public TupleIndex open(Assembler a, Resource root, Mode mode) {
    exactlyOneProperty(root, pDescription);
    String desc = getAsStringValue(root, pDescription).toUpperCase(Locale.ENGLISH);
    exactlyOneProperty(root, pFile);
    String filename = getAsStringValue(root, pFile);
    // Need to get location from the enclosing PGraphAssembler
    if (location != null)
        filename = location.absolute(filename);
    String primary = null;
    RecordFactory rf = null;
    switch(desc.length()) {
        case 3:
            primary = Names.primaryIndexTriples;
            rf = SystemTDB.indexRecordTripleFactory;
            break;
        case 4:
            primary = Names.primaryIndexQuads;
            rf = SystemTDB.indexRecordQuadFactory;
            break;
        default:
            throw new TDBException("Bad length for index description: " + desc);
    }
    // Problems with spotting the index technology.
    // FileSet.fromFilename(filename) ;
    FileSet fileset = null;
    IndexParams idxParams = StoreParams.getDftStoreParams();
    RangeIndex rIndex = IndexFactory.buildRangeIndex(fileset, rf, idxParams);
    return new TupleIndexRecord(desc.length(), new ColumnMap(primary, desc), desc, rf, rIndex);
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) FileSet(org.apache.jena.tdb.base.file.FileSet) TDBException(org.apache.jena.tdb.TDBException) IndexParams(org.apache.jena.tdb.index.IndexParams) RangeIndex(org.apache.jena.tdb.index.RangeIndex)

Example 4 with RangeIndex

use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.

the class DatasetBuilderStd method buildTupleIndex.

// -------------
private TupleIndex buildTupleIndex(FileSet fileSet, ColumnMap colMap, String name, StoreParams params) {
    RecordFactory recordFactory = new RecordFactory(SystemTDB.SizeOfNodeId * colMap.length(), 0);
    RangeIndex rIdx = /*rangeIndexBuilder.*/
    buildRangeIndex(fileSet, recordFactory, params);
    TupleIndex tIdx = new TupleIndexRecord(colMap.length(), colMap, name, recordFactory, rIdx);
    return tIdx;
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) RangeIndex(org.apache.jena.tdb.index.RangeIndex) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 5 with RangeIndex

use of org.apache.jena.tdb.index.RangeIndex in project jena by apache.

the class DatasetBuilderStd method buildRangeIndex.

private RangeIndex buildRangeIndex(FileSet fileSet, RecordFactory recordFactory, IndexParams indexParams) {
    int blkSize = indexParams.getBlockSize();
    int order = BPlusTreeParams.calcOrder(blkSize, recordFactory.recordLength());
    RangeIndex rIndex = createBPTree(fileSet, order, blockMgrBuilder, blockMgrBuilder, recordFactory, indexParams);
    return rIndex;
}
Also used : RangeIndex(org.apache.jena.tdb.index.RangeIndex)

Aggregations

RangeIndex (org.apache.jena.tdb.index.RangeIndex)15 Record (org.apache.jena.tdb.base.record.Record)8 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)6 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)5 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)5 FileSet (org.apache.jena.tdb.base.file.FileSet)4 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)4 IndexParams (org.apache.jena.tdb.index.IndexParams)3 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)3 Test (org.junit.Test)3 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)2 Location (org.apache.jena.tdb.base.file.Location)2 Index (org.apache.jena.tdb.index.Index)2 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)2 NodeId (org.apache.jena.tdb.store.NodeId)2 TDBException (org.apache.jena.tdb.TDBException)1 ModLocation (tdb.cmdline.ModLocation)1