Search in sources :

Example 16 with TDBException

use of org.apache.jena.tdb.TDBException in project jena by apache.

the class BPlusTreeParams method readMeta.

public static BPlusTreeParams readMeta(MetaFile mf) {
    try {
        int pOrder = mf.getPropertyAsInteger(ParamOrder);
        int pKeyLen = mf.getPropertyAsInteger(ParamKeyLength);
        int pRecLen = mf.getPropertyAsInteger(ParamValueLength);
        return new BPlusTreeParams(pOrder, pKeyLen, pRecLen);
    } catch (NumberFormatException ex) {
        Log.error(BPlusTreeParams.class, "Badly formed metadata for B+Tree");
        throw new TDBException("Failed to read metadata");
    }
}
Also used : TDBException(org.apache.jena.tdb.TDBException)

Example 17 with TDBException

use of org.apache.jena.tdb.TDBException in project jena by apache.

the class DumpOps method dump.

public static void dump(Dataset ds) {
    DatasetGraphTDB dsg = (DatasetGraphTDB) (ds.asDatasetGraph());
    NodeTupleTable nodeTupleTableTriples = dsg.getTripleTable().getNodeTupleTable();
    NodeTupleTable nodeTupleTableQuads = dsg.getQuadTable().getNodeTupleTable();
    if (nodeTupleTableTriples.getNodeTable() != nodeTupleTableQuads.getNodeTable())
        throw new TDBException("Different node tables for triples and quads");
    NodeTable nodeTable = nodeTupleTableTriples.getNodeTable();
    // V special.
    Set<NodeTable> dumpedNodeTables = new HashSet<>();
    if (true) {
        System.out.print("## Node Table\n");
        dumpNodeTable(nodeTupleTableTriples.getNodeTable(), dumpedNodeTables);
        dumpNodeTable(nodeTupleTableQuads.getNodeTable(), dumpedNodeTables);
    }
    if (false) {
        System.out.print("## Triple Table\n");
        dumpNodeTupleTable(nodeTupleTableTriples.getTupleTable());
        System.out.print("## Quad Table\n");
        dumpNodeTupleTable(nodeTupleTableQuads.getTupleTable());
    }
    // Indexes.
    if (true) {
        dumpTupleIndexes(nodeTupleTableTriples.getTupleTable().getIndexes());
        dumpTupleIndexes(nodeTupleTableQuads.getTupleTable().getIndexes());
    }
    // Prefixes
    if (true) {
        System.out.print("## Prefix Table\n");
        DatasetPrefixesTDB prefixes = dsg.getPrefixes();
        NodeTupleTable pntt = prefixes.getNodeTupleTable();
        if (!dumpedNodeTables.contains(pntt.getNodeTable())) {
            dumpNodeTable(pntt.getNodeTable(), dumpedNodeTables);
            dumpedNodeTables.add(pntt.getNodeTable());
        }
        dumpTupleIndexes(prefixes.getNodeTupleTable().getTupleTable().getIndexes());
    }
}
Also used : NodeTupleTable(org.apache.jena.tdb.store.nodetupletable.NodeTupleTable) TDBException(org.apache.jena.tdb.TDBException) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) NodeTable(org.apache.jena.tdb.store.nodetable.NodeTable) DatasetGraphTDB(org.apache.jena.tdb.store.DatasetGraphTDB) HashSet(java.util.HashSet)

Example 18 with TDBException

use of org.apache.jena.tdb.TDBException in project jena by apache.

the class BPTreeNodeMgr method createEmptyBPT.

/** Allocate root node space. The root is a node with a Records block.*/
public int createEmptyBPT() {
    // Must be inside already : startUpdate() ;
    // Create an empty records block.
    BPTreePage recordsPage = bpTree.getRecordsMgr().create();
    if (recordsPage.getId() != BPlusTreeParams.RootId)
        // [TxTDB:PATCH-UP]
        throw new TDBException("Root blocks must be at position zero (got " + recordsPage.getId() + ")");
    // Empty data block.
    // [TxTDB:PATCH-UP]
    recordsPage.write();
    recordsPage.release();
    BPTreeNode n = createNode(BPlusTreeParams.RootParent);
    // n.ptrs is currently invalid.  count was 0 so thinks it has a pointer.
    // Force to right layout.
    // No pointers
    n.ptrs.setSize(0);
    // Add the page below
    n.ptrs.add(recordsPage.getId());
    //n.ptrs.set(0, page.getId()) ; // This is the same as the size is one.
    n.isLeaf = true;
    // Count is count of records.
    n.setCount(0);
    int rootId = n.getId();
    n.write();
    n.release();
    // Must be inside already : finishUpdate() ;
    return rootId;
}
Also used : TDBException(org.apache.jena.tdb.TDBException)

Example 19 with TDBException

use of org.apache.jena.tdb.TDBException in project jena by apache.

the class SystemTDB method intValue.

private static int intValue(String name, int defaultValue) {
    if (name == null)
        return defaultValue;
    if (name.length() == 0)
        throw new TDBException("Empty string for value name");
    if (properties == null)
        return defaultValue;
    String x = properties.getProperty(name);
    if (x == null)
        return defaultValue;
    TDB.logInfo.info("Set: " + name + " = " + x);
    int v = Integer.parseInt(x);
    return v;
}
Also used : TDBException(org.apache.jena.tdb.TDBException)

Example 20 with TDBException

use of org.apache.jena.tdb.TDBException in project jena by apache.

the class NodeTableTrans method begin.

@Override
public void begin(Transaction txn) {
    if (this.txn.getTxnId() != txn.getTxnId())
        throw new TDBException(String.format("Different transactions: %s %s", this.txn.getLabel(), txn.getLabel()));
    if (passthrough)
        throw new TDBException("Already active");
    passthrough = false;
    allocOffset = base.allocOffset().getId();
    // base node table empty e.g. first use.
    journalObjFileStartOffset = journalObjFile.length();
    // always empty at the start of a transaction.
    if (journalObjFileStartOffset != 0)
        warn(log, "%s journalStartOffset not zero: %d/0x%02X", txn.getLabel(), journalObjFileStartOffset, journalObjFileStartOffset);
    allocOffset += journalObjFileStartOffset;
    this.nodeTableJournal = new NodeTableNative(nodeIndex, journalObjFile);
    this.nodeTableJournal = NodeTableCache.create(nodeTableJournal, CacheSize, CacheSize, 100);
    // This class knows about non-mappable inline values.   mapToJournal(NodeId)/mapFromJournal. 
    this.nodeTableJournal = NodeTableInline.create(nodeTableJournal);
}
Also used : NodeTableNative(org.apache.jena.tdb.store.nodetable.NodeTableNative) TDBException(org.apache.jena.tdb.TDBException)

Aggregations

TDBException (org.apache.jena.tdb.TDBException)21 NodeId (org.apache.jena.tdb.store.NodeId)5 Node (org.apache.jena.graph.Node)4 File (java.io.File)2 Record (org.apache.jena.tdb.base.record.Record)2 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)2 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 JsonArray (org.apache.jena.atlas.json.JsonArray)1 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 Triple (org.apache.jena.graph.Triple)1 RiotException (org.apache.jena.riot.RiotException)1 Token (org.apache.jena.riot.tokens.Token)1 Tokenizer (org.apache.jena.riot.tokens.Tokenizer)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1 Block (org.apache.jena.tdb.base.block.Block)1 FileSet (org.apache.jena.tdb.base.file.FileSet)1