Search in sources :

Example 6 with RecordFactory

use of org.apache.jena.tdb.base.record.RecordFactory 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 {
            cmdError("Wrong length: " + indexName);
            primary = null;
        }
        int keySubLen = SystemTDB.SizeOfNodeId;
        int keyUnitLen = indexName.length();
        int keyLength = keySubLen * keyUnitLen;
        int valueLength = 0;
        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)

Example 7 with RecordFactory

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

the class BPlusTreeTools method bpt_scan_record_buffer.

/*public*/
private static void bpt_scan_record_buffer(BlockMgr blkMgr, boolean verbose) {
    RecordFactory f = SystemTDB.indexRecordTripleFactory;
    RecordBufferPageMgr recordPageMgr = new RecordBufferPageMgr(f, blkMgr);
    bpt_scan_record_buffer(recordPageMgr, verbose);
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)

Example 8 with RecordFactory

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

the class TestExtHash method makeIndex.

@Override
protected Index makeIndex(int kLen, int vLen) {
    RecordFactory factory = new RecordFactory(kLen, vLen);
    BlockMgr mgr = BlockMgrFactory.createMem("EXT", 32);
    ExtHash eHash = new ExtHash(new PlainFileMem(), factory, mgr);
    return eHash;
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) BlockMgr(org.apache.jena.tdb.base.block.BlockMgr) ExtHash(org.apache.jena.tdb.index.ext.ExtHash) PlainFileMem(org.apache.jena.tdb.base.file.PlainFileMem)

Example 9 with RecordFactory

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

the class TestBPTreeRecords method beforeClass.

@BeforeClass
public static void beforeClass() {
    oldNullOut = SystemTDB.NullOut;
    SystemTDB.NullOut = true;
    oldCheckingNode = BPlusTreeParams.CheckingNode;
    BPlusTreeParams.CheckingNode = true;
    oldCheckingBTree = BPlusTreeParams.CheckingTree;
    BPlusTreeParams.CheckingTree = true;
    // Which is 6 int records
    blockSize = 4 * 8;
    recordFactory = new RecordFactory(4, 0);
    bufSizeRecord = RecordBufferPage.calcRecordSize(recordFactory, blockSize);
    blkMgrRecords = BlockMgrFactory.createMem("BPTreeRecords", blockSize);
    recordBufferPageMgr = new RecordBufferPageMgr(recordFactory, blkMgrRecords);
    // B+Tree order does not matter.
    bPlusTree = BPlusTree.attach(new BPlusTreeParams(3, recordFactory), null, blkMgrRecords);
}
Also used : BPlusTreeParams(org.apache.jena.tdb.index.bplustree.BPlusTreeParams) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) RecordBufferPageMgr(org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr) BeforeClass(org.junit.BeforeClass)

Example 10 with RecordFactory

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

the class CmdTestBPlusTreeRewriter method main.

public static void main(String... argv) {
    // Usage: maxOrder maxSize NumTests
    if (argv.length != 3) {
        System.err.println("Usage: " + Lib.classShortName(CmdTestBPlusTreeRewriter.class) + " maxOrder maxSize NumTests");
        System.exit(1);
    }
    SystemTDB.NullOut = true;
    boolean debug = false;
    int MaxOrder = -1;
    int MinOrder = 2;
    int MinSize = 0;
    int MaxSize = -1;
    int NumTest = -1;
    try {
        MaxOrder = Integer.parseInt(argv[0]);
    } catch (NumberFormatException ex) {
        System.err.println("Bad number for MaxOrder");
        System.exit(1);
    }
    try {
        MaxSize = Integer.parseInt(argv[1]);
    } catch (NumberFormatException ex) {
        System.err.println("Bad number for MaxSize");
        System.exit(1);
    }
    try {
        NumTest = Integer.parseInt(argv[2]);
    } catch (NumberFormatException ex) {
        System.err.println("Bad number for NumTest");
        System.exit(1);
    }
    //        int MaxOrder    = 10 ;
    //        int MinOrder    = 2 ;
    //        int MinSize     = 0 ;
    //        int MaxSize     = 1000 ;
    //        int NumTest     = 10000 ; //10*1000 ;
    int KeySize = 4;
    int ValueSize = 8;
    RecordFactory recordFactory = new RecordFactory(KeySize, ValueSize);
    int successes = 0;
    int failures = 0;
    int[] orders = null;
    int[] sizes = null;
    if (false) {
        // Specific test case.
        orders = new int[] { 2 };
        sizes = new int[] { 20 };
        NumTest = sizes.length;
        SystemTDB.NullOut = true;
        debug = true;
        BPlusTreeRewriter.debug = true;
    } else {
        orders = new int[NumTest];
        sizes = new int[NumTest];
        for (int i = 0; i < orders.length; i++) {
            int order = (MinOrder == MaxOrder) ? MinOrder : MinOrder + RandomLib.random.nextInt(MaxOrder - MinOrder);
            int size = (MinSize == MaxSize) ? MinSize : MinSize + RandomLib.random.nextInt(MaxSize - MinSize);
            orders[i] = order;
            sizes[i] = size;
        }
    }
    int numOnLine = 50;
    int testsPerTick = 500;
    int testCount = 1;
    for (testCount = 1; testCount <= orders.length; testCount++) {
        if (testCount % testsPerTick == 0)
            System.out.print(".");
        if (testCount % (testsPerTick * numOnLine) == 0)
            System.out.println();
        int idx = testCount - 1;
        int order = orders[idx];
        int size = sizes[idx];
        try {
            TestBPlusTreeRewriter.runOneTest(order, size, recordFactory, debug);
            successes++;
        } catch (RuntimeException ex) {
            System.err.printf("-- Fail: (order=%d, size=%d)\n", order, size);
            ex.printStackTrace(System.err);
            System.err.printf("--------------------------\n");
            failures++;
        }
    }
    if (testCount % (testsPerTick * numOnLine) != 0)
        System.out.println();
    System.err.flush();
    System.out.flush();
    System.out.printf("DONE : %,d tests : Success=%,d, Failures=%,d\n", NumTest, successes, failures);
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory)

Aggregations

RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)12 BlockMgr (org.apache.jena.tdb.base.block.BlockMgr)3 FileSet (org.apache.jena.tdb.base.file.FileSet)3 Record (org.apache.jena.tdb.base.record.Record)3 RangeIndex (org.apache.jena.tdb.index.RangeIndex)3 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)3 BPlusTreeParams (org.apache.jena.tdb.index.bplustree.BPlusTreeParams)3 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)3 Location (org.apache.jena.tdb.base.file.Location)2 ObjectFile (org.apache.jena.tdb.base.objectfile.ObjectFile)2 RecordBufferPageMgr (org.apache.jena.tdb.base.recordbuffer.RecordBufferPageMgr)2 IndexMap (org.apache.jena.tdb.index.IndexMap)2 TupleIndexRecord (org.apache.jena.tdb.store.tupletable.TupleIndexRecord)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 AtlasException (org.apache.jena.atlas.AtlasException)1 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 TDBException (org.apache.jena.tdb.TDBException)1 BufferChannelFile (org.apache.jena.tdb.base.file.BufferChannelFile)1