Search in sources :

Example 11 with RangeIndex

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

the class TestTransIterator method transIter_01.

@Test
public void transIter_01() {
    int[] vals = {};
    RangeIndex rIndex = build(2, vals);
    Iterator<Record> iter1 = rIndex.iterator();
    Iterator<Record> iter2 = rIndex.iterator();
    count(iter1, vals.length);
    count(iter2, vals.length);
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Test(org.junit.Test)

Example 12 with RangeIndex

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

the class TestTransIterator method transIter_02.

@Test
public void transIter_02() {
    int[] vals = { 1, 2, 3, 4, 5, 6, 7 };
    RangeIndex rIndex = build(2, vals);
    Iterator<Record> iter1 = rIndex.iterator();
    Iterator<Record> iter2 = rIndex.iterator();
    count(iter1, vals.length);
    count(iter2, vals.length);
}
Also used : Record(org.apache.jena.tdb.base.record.Record) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Test(org.junit.Test)

Example 13 with RangeIndex

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

the class SetupTDB method makeTupleIndex.

public static TupleIndex makeTupleIndex(Location location, String primary, String indexOrder, String indexName, int keyLength) {
    FileSet fs = new FileSet(location, indexName);
    int readCacheSize = params.getBlockReadCacheSize();
    int writeCacheSize = params.getBlockWriteCacheSize();
    // Value part is null (zero length)
    RangeIndex rIndex = SetupIndex.makeRangeIndex(location, indexName, params.getBlockSize(), keyLength, 0, readCacheSize, writeCacheSize);
    TupleIndex tupleIndex = new TupleIndexRecord(primary.length(), new ColumnMap(primary, indexOrder), indexOrder, rIndex.getRecordFactory(), rIndex);
    return tupleIndex;
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) FileSet(org.apache.jena.tdb.base.file.FileSet) RangeIndex(org.apache.jena.tdb.index.RangeIndex) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex)

Example 14 with RangeIndex

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

the class DebugTDB method dumpIndex.

public static void dumpIndex(TupleIndex idx) {
    Iterator<Tuple<NodeId>> iter = idx.all();
    while (iter.hasNext()) {
        Tuple<NodeId> tuple = iter.next();
        System.out.println(tuple);
    }
    if (false) {
        // Dump raw
        TupleIndexRecord tir = (TupleIndexRecord) idx;
        RangeIndex rIdx = tir.getRangeIndex();
        for (Record aRIdx : rIdx) {
            System.out.println(aRIdx);
        }
    }
}
Also used : TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) NodeId(org.apache.jena.tdb.store.NodeId) Record(org.apache.jena.tdb.base.record.Record) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Example 15 with RangeIndex

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

the class dumpbpt method exec.

@Override
protected void exec() {
    List<String> tripleIndexes = Arrays.asList(Names.tripleIndexes);
    List<String> quadIndexes = Arrays.asList(Names.quadIndexes);
    Location loc = modLocation.getLocation();
    // The name is the order.
    for (String indexName : super.getPositional()) {
        String primary;
        if (indexName.length() == 3) {
            primary = Names.primaryIndexTriples;
        } else if (indexName.length() == 4) {
            primary = Names.primaryIndexQuads;
        } else if (Objects.equals(indexName, Names.indexNode2Id)) {
            primary = Names.indexNode2Id;
        } else {
            cmdError("Wrong length: " + indexName);
            primary = null;
        }
        // prefix2id
        // prefixIdx : GPU
        int keySubLen = SystemTDB.SizeOfNodeId;
        int keyUnitLen = indexName.length();
        int keyLength = keySubLen * keyUnitLen;
        int valueLength = 0;
        // Node table indexes.
        if (Objects.equals(indexName, Names.indexNode2Id) || Objects.equals(indexName, Names.prefixNode2Id)) {
            keySubLen = SystemTDB.LenNodeHash;
            keyUnitLen = 1;
            keyLength = SystemTDB.LenNodeHash;
            valueLength = SystemTDB.SizeOfNodeId;
        }
        // Prefixes
        if (Objects.equals(indexName, Names.indexPrefix)) {
            primary = Names.primaryIndexPrefix;
        }
        RecordFactory rf = new RecordFactory(keyLength, valueLength);
        RangeIndex rIndex = IndexFactory.buildRangeIndex(loc, indexName, rf);
        BPlusTree bpt = (BPlusTree) rIndex;
        if (false) {
            System.out.println("---- Index structure");
            bpt.dump();
        }
        if (true) {
            System.out.println("---- Index contents");
            Iterator<Record> iter = bpt.iterator();
            if (!iter.hasNext())
                System.out.println("<<Empty>>");
            for (; iter.hasNext(); ) {
                Record r = iter.next();
                printRecord("", System.out, r, keyUnitLen);
            }
        }
        // Check.
        Iterator<Record> iterCheck = bpt.iterator();
        Record r1 = null;
        int i = 0;
        for (; iterCheck.hasNext(); ) {
            Record r2 = iterCheck.next();
            i++;
            if (r1 != null) {
                if (!Record.keyLT(r1, r2)) {
                    System.err.println("key error@ " + i);
                    printRecord("  ", System.err, r1, keyUnitLen);
                    printRecord("  ", System.err, r2, keyUnitLen);
                }
            }
            r1 = r2;
        }
        if (false) {
            // Dump in tuple order.
            TupleIndex tupleIndex = new TupleIndexRecord(primary.length(), new ColumnMap(primary, indexName), indexName, rIndex.getRecordFactory(), rIndex);
            if (true) {
                System.out.println("---- Tuple contents");
                Iterator<Tuple<NodeId>> iter2 = tupleIndex.all();
                if (!iter2.hasNext())
                    System.out.println("<<Empty>>");
                for (; iter2.hasNext(); ) {
                    Tuple<NodeId> row = iter2.next();
                    System.out.println(row);
                }
            }
        }
    }
}
Also used : ColumnMap(org.apache.jena.tdb.lib.ColumnMap) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) NodeId(org.apache.jena.tdb.store.NodeId) Record(org.apache.jena.tdb.base.record.Record) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) RangeIndex(org.apache.jena.tdb.index.RangeIndex) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) BPlusTree(org.apache.jena.tdb.index.bplustree.BPlusTree) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) Location(org.apache.jena.tdb.base.file.Location) ModLocation(tdb.cmdline.ModLocation)

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