public long size() { return dsg.size() ; }
@Override public long size() { return get().size() ; } }
@Override public long size() { return get().size() ; }
/** * Return true if the datasets are isomorphic - same names for graphs, graphs isomorphic. */ public static boolean isomorphic(DatasetGraph dataset1, DatasetGraph dataset2) { long x1 = dataset1.size() ; long x2 = dataset2.size() ; if ( x1 >=0 && x1 != x2 ) return false ; boolean b = dataset1.getDefaultGraph().isIsomorphicWith(dataset2.getDefaultGraph()) ; if ( ! b ) return b ; for ( Iterator<Node> iter1 = dataset1.listGraphNodes() ; iter1.hasNext() ; ) { Node gn = iter1.next() ; Graph g1 = dataset1.getGraph(gn) ; Graph g2 = dataset2.getGraph(gn) ; if ( g2 == null ) return false ; if ( ! g1.isIsomorphicWith(g2) ) return false ; } return true ; }
/** * Return true if the datasets are isomorphic - same names for graphs, graphs isomorphic. */ public static boolean isomorphic(DatasetGraph dataset1, DatasetGraph dataset2) { long x1 = dataset1.size() ; long x2 = dataset2.size() ; if ( x1 >=0 && x1 != x2 ) return false ; boolean b = dataset1.getDefaultGraph().isIsomorphicWith(dataset2.getDefaultGraph()) ; if ( ! b ) return b ; for ( Iterator<Node> iter1 = dataset1.listGraphNodes() ; iter1.hasNext() ; ) { Node gn = iter1.next() ; Graph g1 = dataset1.getGraph(gn) ; Graph g2 = dataset2.getGraph(gn) ; if ( g2 == null ) return false ; if ( ! g1.isIsomorphicWith(g2) ) return false ; } return true ; }
static Table evalDS(OpDatasetNames opDSN, Evaluator evaluator) { Node graphNode = opDSN.getGraphNode() ; if ( graphNode.isURI() ) { if ( evaluator.getExecContext().getDataset().containsGraph(graphNode) ) { return new TableUnit() ; } else // WRONG { return new TableEmpty() ; } } if ( ! Var.isVar(graphNode) ) throw new ARQInternalErrorException("OpDatasetNames: Not a URI or variable: "+graphNode) ; DatasetGraph dsg = evaluator.getExecContext().getDataset() ; Iterator<Node> iter = dsg.listGraphNodes() ; List<Binding> list = new ArrayList<Binding>((int)dsg.size()) ; for ( ; iter.hasNext(); ) { Node gn = iter.next(); Binding b = BindingFactory.binding(Var.alloc(graphNode), gn) ; list.add(b) ; } QueryIterator qIter = new QueryIterPlainWrapper(list.iterator(), evaluator.getExecContext()) ; return TableFactory.create(qIter) ; }
static Table evalDS(OpDatasetNames opDSN, Evaluator evaluator) { Node graphNode = opDSN.getGraphNode() ; if ( graphNode.isURI() ) { if ( evaluator.getExecContext().getDataset().containsGraph(graphNode) ) { return new TableUnit() ; } else // WRONG { return new TableEmpty() ; } } if ( ! Var.isVar(graphNode) ) throw new ARQInternalErrorException("OpDatasetNames: Not a URI or variable: "+graphNode) ; DatasetGraph dsg = evaluator.getExecContext().getDataset() ; Iterator<Node> iter = dsg.listGraphNodes() ; List<Binding> list = new ArrayList<Binding>((int)dsg.size()) ; for ( ; iter.hasNext(); ) { Node gn = iter.next(); Binding b = BindingFactory.binding(Var.alloc(graphNode), gn) ; list.add(b) ; } QueryIterator qIter = new QueryIterPlainWrapper(list.iterator(), evaluator.getExecContext()) ; return TableFactory.create(qIter) ; }
@Test public void dataset5() { String graphName = "http://example/" ; Triple triple = SSE.parseTriple("(<x> <y> <z>)") ; Dataset ds = graphLocation.getDataset() ; Graph g2 = ds.asDatasetGraph().getGraph(Node.createURI(graphName)) ; // Graphs only exists if they have a triple in them g2.add(triple) ; assertTrue(ds.containsNamedModel(graphName)) ; Iterator<String> iter = ds.listNames() ; List<String> x = Iter.toList(iter) ; List<String> y = Arrays.asList(graphName) ; assertEquals(x,y) ; assertEquals(1, ds.asDatasetGraph().size()) ; } }
@Test public void dataset4() { String graphName = "http://example/" ; Triple triple = SSE.parseTriple("(<x> <y> <z>)") ; Node gn = Node.createURI(graphName) ; Dataset ds = graphLocation.getDataset() ; // ?? See TupleLib. ds.asDatasetGraph().deleteAny(gn, null, null, null) ; Graph g2 = ds.asDatasetGraph().getGraph(gn) ; // if ( true ) // { // PrintStream ps = System.err ; // ps.println("Dataset names: ") ; // Iter.print(ps, ds.listNames()) ; // } // Graphs only exists if they have a triple in them assertFalse(ds.containsNamedModel(graphName)) ; Iterator<String> iter = ds.listNames() ; assertFalse(iter.hasNext()) ; assertEquals(0, ds.asDatasetGraph().size()) ; }