You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by ajs6f <gi...@git.apache.org> on 2017/10/12 14:20:43 UTC

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

GitHub user ajs6f opened a pull request:

    https://github.com/apache/jena/pull/287

    JENA-1391: adding isEmpty method to Dataset

    One of the asks from JENA-1391. Not by any means the whole ticket. :)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ajs6f/jena JENA-1391isEmpty

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/jena/pull/287.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #287
    
----
commit 58653f788f76d8ebb76b4d97a1f75d2f1027824a
Author: ajs6f <aj...@apache.org>
Date:   2017-10-12T14:18:41Z

    JENA-1391: adding isEmpty method to Dataset

----


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144321650
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,11 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of graphs. Be aware of the semantic looseness inherent in
    +     * <a href="https://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#h_note_4">the definition
    +     * of RDF Datasets</a>; whether a named graph exists if nothing is in it is implementation-specific.
    +     */
    +    boolean isEmpty();
    --- End diff --
    
    I didn't do that at first because it felt like a bit of a conflict against the rest of the API for `Dataset`, which discusses models/graphs and not tuples. But if you're okay with it, it doesn't bother me.


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144312642
  
    --- Diff: jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java ---
    @@ -108,4 +108,12 @@
             assertFalse(model1.isIsomorphicWith(ds.getNamedModel(graphName))) ;
             assertTrue(model2.isIsomorphicWith(ds.getNamedModel(graphName))) ;
         }
    +    
    +    @Test public void dataset_06()
    +    {
    +        String graphName = "http://example/" ;
    +        Dataset ds = createDataset() ;
    +        ds.addNamedModel(graphName, model1) ;
    +        assertFalse("Dataset should not be empty after a named graph has been added!", ds.isEmpty());
    +    }
    --- End diff --
    
    This is a test passes because `model1` is not empty - not because it is used as a named graphs.
    
    ```
            DatasetGraph dsg = DatasetGraphFactory.createTxnMem(); // or createGeneral
            Graph g = GraphFactory.createGraphMem();
            dsg.addGraph(NodeFactory.createURI("http;//example/g"), g);
            boolean b = dsg.isEmpty();
            System.out.println(b) ;
    ```
    prints "true".


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144359574
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,9 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of triples, whether in the default graph or in any named graph.
    --- End diff --
    
    @afs  Better?


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144321132
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,11 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of graphs. Be aware of the semantic looseness inherent in
    +     * <a href="https://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#h_note_4">the definition
    +     * of RDF Datasets</a>; whether a named graph exists if nothing is in it is implementation-specific.
    +     */
    +    boolean isEmpty();
    --- End diff --
    
    Sure we can.  Change the javadoc to "returns true if the dataset contains no statements in any model". That's what it does, and what the test does anyway, because the impl passes down to `DatasetGraph.isEmpty`. That is the useful operation.



---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144382225
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,9 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of triples, whether in the default graph or in any named graph.
    --- End diff --
    
    Yes!
    +1 to merging.


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144314175
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,11 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of graphs. Be aware of the semantic looseness inherent in
    +     * <a href="https://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#h_note_4">the definition
    +     * of RDF Datasets</a>; whether a named graph exists if nothing is in it is implementation-specific.
    +     */
    +    boolean isEmpty();
    --- End diff --
    
    Oh, fudge. Then we really can't have a default impl of this, can we?


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144314830
  
    --- Diff: jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java ---
    @@ -108,4 +108,12 @@
             assertFalse(model1.isIsomorphicWith(ds.getNamedModel(graphName))) ;
             assertTrue(model2.isIsomorphicWith(ds.getNamedModel(graphName))) ;
         }
    +    
    +    @Test public void dataset_06()
    +    {
    +        String graphName = "http://example/" ;
    +        Dataset ds = createDataset() ;
    +        ds.addNamedModel(graphName, model1) ;
    +        assertFalse("Dataset should not be empty after a named graph has been added!", ds.isEmpty());
    +    }
    --- End diff --
    
    See above-- so do we need a different impl of `isEmpty` for every kind of `DatasetGraph`?


---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by afs <gi...@git.apache.org>.
Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/287#discussion_r144312365
  
    --- Diff: jena-arq/src/main/java/org/apache/jena/query/Dataset.java ---
    @@ -113,4 +113,11 @@
          *  The dataset can not be used for query after this call.
          */
         public void close() ;
    +    
    +    /**
    +     * @return Whether this {@code Dataset} is empty of graphs. Be aware of the semantic looseness inherent in
    +     * <a href="https://www.w3.org/TR/2014/REC-rdf11-concepts-20140225/#h_note_4">the definition
    +     * of RDF Datasets</a>; whether a named graph exists if nothing is in it is implementation-specific.
    +     */
    +    boolean isEmpty();
    --- End diff --
    
    "is empty of graphs" 
    
    Firstly, there is always at least one graph (the default graph).
    
    Secondly, "isEmpty" on a DSG means no triples in any graph (default implement is `!contain(ANY,ANY,ANY,ANY)` which includes the default graph).



---

[GitHub] jena pull request #287: JENA-1391: adding isEmpty method to Dataset

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f closed the pull request at:

    https://github.com/apache/jena/pull/287


---