@Test public void sys1() { assertNotNull(TDB.VERSION) ; assertNotNull(TDB.BUILD_DATE) ; } }
/** * @param modelLocation The directory with the Jena TDB model. Will be created * if not existent. * @return * @throws IllegalArgumentException if <code>null</code> is parsed; * if the parsed {@link File} exists but is not a directory; if the parsed * File does NOT exists AND can not be created. */ public static DatasetGraphTDB initTDBDataset(File modelLocation) { if(modelLocation == null){ throw new IllegalArgumentException("The parsed Jena TDB directory" + "MUST NOT be NULL!"); } if(modelLocation.exists() && !modelLocation.isDirectory()){ throw new IllegalArgumentException("The configured RDF model directory "+ modelLocation+"exists but is not a Directory"); } else if(!modelLocation.exists()){ if(!modelLocation.mkdirs()){ throw new IllegalArgumentException("Unable to create the configured RDF model directory "+ modelLocation+"!"); } } Location location = new Location(modelLocation.getAbsolutePath()); //TODO: change this to support transactions // TDBMaker.createDatasetGraphTransaction(location); // if we need transaction support! return TDBMaker.createDatasetGraphTDB(location); }
@Override protected NodeTable createEmptyNodeTable() { return SetupTDB.makeNodeTableBase(Location.mem(), Names.indexNode2Id, Names.indexId2Node) ; } }
@Test public void factory2() { DatasetGraphMakerTDB f = TDBMaker.getImplFactory() ; TDBMaker.clearDatasetCache() ; DatasetGraphTDB dg0 = TDBFactory.createDatasetGraph(Location.mem()) ; // Uncached. TDBMaker.setImplFactory(TDBMaker.uncachedFactory) ; DatasetGraphTDB dg1 = TDBFactory.createDatasetGraph(Location.mem()) ; DatasetGraphTDB dg2 = TDBFactory.createDatasetGraph(Location.mem()) ; assertNotSame(dg1, dg2) ; // Switch back to cached. TDBMaker.setImplFactory(f) ; DatasetGraphTDB dg3 = TDBFactory.createDatasetGraph(Location.mem()) ; assertNotSame(dg3, dg1) ; assertNotSame(dg3, dg2) ; assertSame(dg3, dg0) ; }
/** Create or connect a TDB dataset (graph-level) */ private static DatasetGraphTDB _createDatasetGraph(IndexBuilder indexBuilder, Location location, String[] graphIndexDesc, String[] quadIndexDesc) { ConcurrencyPolicy policy = new ConcurrencyPolicyMRSW() ; @SuppressWarnings("deprecation") NodeTable nodeTable = NodeTableFactory.create(indexBuilder, location) ; TripleTable triples = createTripleTable(indexBuilder, nodeTable, location, graphIndexDesc, policy) ; QuadTable quads = createQuadTable(indexBuilder, nodeTable, location, quadIndexDesc, policy) ; @SuppressWarnings("deprecation") DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.create(indexBuilder, location, policy) ; return new DatasetGraphTDB(triples, quads, prefixes, chooseOptimizer(location), location, null) ; }
@Override protected NodeTable createEmptyNodeTable() { return SetupTDB.makeNodeTable(Location.mem(), Names.indexNode2Id, 10, Names.indexId2Node, 10) ; } }
@After public void after() { graphLocation.release() ; TDBMaker.clearDatasetCache() ; }
private TripleTable createTripleTableMem() { DatasetGraphTDB ds = SetupTDB.buildDataset(Location.mem()) ; return ds.getTripleTable() ; } }
static List<Record> createData2(int ORDER, int N, RecordFactory recordFactory) { // Use a B+Tree - so original data can be unsorted. BPlusTree bpt = (BPlusTree)SetupTDB.createBPTree(FileSet.mem(), ORDER, -1, -1, -1, recordFactory) ; //BPlusTree bpt = BPlusTree.makeMem(ORDER, bptParams.getMinRec() , 4, 0) ; //BPlusTreeParams.checkAll() ; // 200 -> runt leaf problem. // Problem is that a node in a stripe is less than half full // -> illegal BPT. // -> specially rebalance if 2 or more blocks. // -> spot one bloc (= root) // PeekIterator. for ( int i = 0; i < N ; i++ ) { Record record = recordFactory.create() ; Bytes.setInt(i+1, record.getKey()) ; bpt.add(record) ; } return Iter.toList(bpt.iterator()) ; }
@SuppressWarnings("deprecation") @Test public void persistent2() { String dir = ConfigTest.getTestingDir() ; FileOps.clearDirectory(dir) ; DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.create(new Location(dir), new ConcurrencyPolicyMRSW()) ; PrefixMapping pmap1 = prefixes.getPrefixMapping() ; pmap1.setNsPrefix("x", "http://foo/") ; prefixes.close() ; prefixes = DatasetPrefixesTDB.create(new Location(dir), new ConcurrencyPolicyMRSW()) ; assertEquals("http://foo/", pmap1.getNsPrefixURI("x")) ; prefixes.close(); }
/** * @param modelLocation The directory with the Jena TDB model. Will be created * if not existent. * @return * @throws IllegalArgumentException if <code>null</code> is parsed; * if the parsed {@link File} exists but is not a directory; if the parsed * File does NOT exists AND can not be created. */ public static DatasetGraphTDB initTDBDataset(File modelLocation) { if(modelLocation == null){ throw new IllegalArgumentException("The parsed Jena TDB directory" + "MUST NOT be NULL!"); } if(modelLocation.exists() && !modelLocation.isDirectory()){ throw new IllegalArgumentException("The configured RDF model directory "+ modelLocation+"exists but is not a Directory"); } else if(!modelLocation.exists()){ if(!modelLocation.mkdirs()){ throw new IllegalArgumentException("Unable to create the configured RDF model directory "+ modelLocation+"!"); } } Location location = new Location(modelLocation.getAbsolutePath()); //TODO: change this to support transactions // TDBMaker.createDatasetGraphTransaction(location); // if we need transaction support! return TDBMaker.createDatasetGraphTDB(location); }
@SuppressWarnings("deprecation") @Test public void persistent1() { String dir = ConfigTest.getTestingDir() ; FileOps.clearDirectory(dir) ; DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.create(new Location(dir), new ConcurrencyPolicyMRSW()) ; PrefixMapping pmap1 = prefixes.getPrefixMapping() ; String x = pmap1.getNsPrefixURI("x") ; assertNull(x) ; prefixes.close(); }