Search in sources :

Example 1 with IndexMap

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

the class JournalControl method recoverNodeDat.

/** Recover a node data file (".dat").
     *  Node data files are append-only so recovering, then not using the data is safe.
     *  Node data file is a precursor for full recovery that works from the master journal.
     */
private static void recoverNodeDat(DatasetGraphTDB dsg, FileRef fileRef) {
    // See DatasetBuilderTxn - same name generation code.
    RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
    NodeTable baseNodeTable = dsg.getConfig().nodeTables.get(fileRef);
    String objFilename = fileRef.getFilename() + "-" + Names.extJournal;
    objFilename = dsg.getLocation().absolute(objFilename);
    File jrnlFile = new File(objFilename);
    if (jrnlFile.exists() && jrnlFile.length() > 0) {
        syslog.info("Recovering node data: " + fileRef.getFilename());
        ObjectFile dataJrnl = FileFactory.createObjectFileDisk(objFilename);
        NodeTableTrans ntt = new NodeTableTrans(null, objFilename, baseNodeTable, new IndexMap(recordFactory), dataJrnl);
        ntt.append();
        ntt.close();
        dataJrnl.close();
        baseNodeTable.sync();
    }
    if (jrnlFile.exists())
        FileOps.delete(objFilename);
}
Also used : RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) IndexMap(org.apache.jena.tdb.index.IndexMap) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) BufferChannelFile(org.apache.jena.tdb.base.file.BufferChannelFile) File(java.io.File) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable)

Example 2 with IndexMap

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

the class AbstractTestNodeTableTrans method create.

private NodeTableTrans create(Transaction txn, NodeTable base) {
    RecordFactory recordFactory = new RecordFactory(SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId);
    Index idx = new IndexMap(recordFactory);
    ObjectFile objectFile = createObjectFile();
    NodeTableTrans ntt = new NodeTableTrans(txn, "test", base, idx, objectFile);
    return ntt;
}
Also used : NodeTableTrans(org.apache.jena.tdb.transaction.NodeTableTrans) RecordFactory(org.apache.jena.tdb.base.record.RecordFactory) IndexMap(org.apache.jena.tdb.index.IndexMap) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) Index(org.apache.jena.tdb.index.Index)

Aggregations

ObjectFile (org.apache.jena.tdb.base.objectfile.ObjectFile)2 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)2 IndexMap (org.apache.jena.tdb.index.IndexMap)2 File (java.io.File)1 BufferChannelFile (org.apache.jena.tdb.base.file.BufferChannelFile)1 Index (org.apache.jena.tdb.index.Index)1 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)1 NodeTableTrans (org.apache.jena.tdb.transaction.NodeTableTrans)1