Search in sources :

Example 1 with TupleIndexRecord

use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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 2 with TupleIndexRecord

use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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 3 with TupleIndexRecord

use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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 4 with TupleIndexRecord

use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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 5 with TupleIndexRecord

use of org.apache.jena.tdb.store.tupletable.TupleIndexRecord 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)5 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)5 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)3 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)3 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)3 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 FileSet (org.apache.jena.tdb.base.file.FileSet)2 Record (org.apache.jena.tdb.base.record.Record)2 NodeId (org.apache.jena.tdb.store.NodeId)2 TDBException (org.apache.jena.tdb.TDBException)1 Location (org.apache.jena.tdb.base.file.Location)1 IndexParams (org.apache.jena.tdb.index.IndexParams)1 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)1 ModLocation (tdb.cmdline.ModLocation)1