Search in sources :

Example 6 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 {
        FmtLog.error(ProcRewriteIndex.class, "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 7 with RangeIndex

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

the class DebugTDB method dumpNodeIndex.

// public static RangeIndex makeRangeIndex(Location location, String indexName,
// int dftKeyLength, int dftValueLength,
// int readCacheSize,int writeCacheSize)
public static void dumpNodeIndex(String dir) {
    Location location = Location.create(dir);
    Index nodeToId = SetupTDB.makeIndex(location, Names.indexNode2Id, SystemTDB.BlockSize, SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId, -1, -1);
    for (Record aNodeToId : nodeToId) {
        System.out.println(aNodeToId);
    }
}
Also used : Index(org.apache.jena.tdb.index.Index) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Record(org.apache.jena.tdb.base.record.Record) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) Location(org.apache.jena.tdb.base.file.Location)

Example 8 with RangeIndex

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

the class IndexTestLib method buildIndex.

// ---------- Utilities
//    public static RangeIndex buildRangeIndex(RangeIndexMaker maker, int[] keys)
//    {
//        RangeIndex index = maker.make() ;
//        IndexTestLib.add(index, keys) ;
//        return index ;
//    }
public static Index buildIndex(IndexMaker maker, int[] keys) {
    Index index = maker.makeIndex();
    IndexTestLib.add(index, keys);
    return index;
}
Also used : Index(org.apache.jena.tdb.index.Index) RangeIndex(org.apache.jena.tdb.index.RangeIndex)

Example 9 with RangeIndex

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

the class TestTupleIndexRecord method createIndex.

@Override
protected TupleIndexRecord createIndex(String description) {
    IndexParams indexParams = StoreParams.getDftStoreParams();
    RangeIndex rIdx = IndexFactory.buildRangeIndex(FileSet.mem(), factory, indexParams);
    ColumnMap cmap = new ColumnMap("SPO", description);
    TupleIndexRecord index = new TupleIndexRecord(3, cmap, description, factory, rIdx);
    return index;
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) IndexParams(org.apache.jena.tdb.index.IndexParams) RangeIndex(org.apache.jena.tdb.index.RangeIndex)

Example 10 with RangeIndex

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

the class TestTupleIndexRecordDirect method create.

static TupleIndexRecord create(String description) {
    IndexParams indexParams = StoreParams.getDftStoreParams();
    RangeIndex rIdx = IndexFactory.buildRangeIndex(FileSet.mem(), factory, indexParams);
    ColumnMap cmap = new ColumnMap("SPO", description);
    TupleIndexRecord index = new TupleIndexRecord(3, cmap, description, factory, rIdx);
    return index;
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) IndexParams(org.apache.jena.tdb.index.IndexParams) 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