Search in sources :

Example 6 with DatasetPrefixesTDB

use of org.apache.jena.tdb.store.DatasetPrefixesTDB 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.getStoragePrefixes();
        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 7 with DatasetPrefixesTDB

use of org.apache.jena.tdb.store.DatasetPrefixesTDB in project jena by apache.

the class TestPrefixMappingTDB1 method multiple1.

@Test
public void multiple1() {
    DatasetPrefixesTDB prefixes = createTestingMem();
    PrefixMapping pmap1 = getPrefixMapping();
    PrefixMapping pmap2 = getPrefixMapping("http://graph/");
    pmap1.setNsPrefix("x", "http://foo/");
    assertNull(pmap2.getNsPrefixURI("x"));
    assertNotNull(pmap1.getNsPrefixURI("x"));
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 8 with DatasetPrefixesTDB

use of org.apache.jena.tdb.store.DatasetPrefixesTDB in project jena by apache.

the class TestPrefixMappingTDB1 method persistent1.

// Persistent.
@Test
public void persistent1() {
    String dir = ConfigTest.getTestingDir();
    FileOps.clearDirectory(dir);
    DatasetPrefixesTDB prefixes = createTesting(Location.create(dir), new DatasetControlMRSW());
    PrefixMapping pmap1 = getPrefixMapping();
    String x = pmap1.getNsPrefixURI("x");
    assertNull(x);
    prefixes.close();
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetControlMRSW(org.apache.jena.tdb.sys.DatasetControlMRSW) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) ConfigTest(org.apache.jena.tdb.ConfigTest)

Example 9 with DatasetPrefixesTDB

use of org.apache.jena.tdb.store.DatasetPrefixesTDB in project jena by apache.

the class TestPrefixMappingTDB1 method persistent2.

// Persistent.
@Test
public void persistent2() {
    String dir = ConfigTest.getTestingDir();
    FileOps.clearDirectory(dir);
    DatasetPrefixesTDB prefixes = createTesting(Location.create(dir), new DatasetControlMRSW());
    PrefixMapping pmap1 = getPrefixMapping();
    pmap1.setNsPrefix("x", "http://foo/");
    prefixes.close();
    prefixes = createTesting(Location.create(dir), new DatasetControlMRSW());
    PrefixMapping pmap2 = getPrefixMapping();
    String uri = pmap2.getNsPrefixURI("x");
    assertEquals("http://foo/", uri);
    prefixes.close();
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) DatasetControlMRSW(org.apache.jena.tdb.sys.DatasetControlMRSW) DatasetPrefixesTDB(org.apache.jena.tdb.store.DatasetPrefixesTDB) ConfigTest(org.apache.jena.tdb.ConfigTest)

Aggregations

DatasetPrefixesTDB (org.apache.jena.tdb.store.DatasetPrefixesTDB)9 PrefixMapping (org.apache.jena.shared.PrefixMapping)8 ConfigTest (org.apache.jena.tdb.ConfigTest)8 DatasetControlMRSW (org.apache.jena.tdb.sys.DatasetControlMRSW)4 HashSet (java.util.HashSet)1 TDBException (org.apache.jena.tdb.TDBException)1 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)1 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)1 NodeTupleTable (org.apache.jena.tdb.store.nodetupletable.NodeTupleTable)1