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");
}
}
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());
}
}
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;
}
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;
}
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);
}
Aggregations