You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/12/18 22:16:04 UTC

svn commit: r1220543 - in /incubator/jena/Scratch/AFS/Jena-Dev/trunk/src: dev/DSG_Notify.java dsg/ dsg/DSG_Notify.java dsg/DatasetGraphSimpleMem.java dsg/TestDatasetGraphSimpleMem.java

Author: andy
Date: Sun Dec 18 21:16:03 2011
New Revision: 1220543

URL: http://svn.apache.org/viewvc?rev=1220543&view=rev
Log: (empty)

Added:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DSG_Notify.java
      - copied, changed from r1214656, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/DSG_Notify.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DatasetGraphSimpleMem.java
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/TestDatasetGraphSimpleMem.java
Removed:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/DSG_Notify.java

Copied: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DSG_Notify.java (from r1214656, incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/DSG_Notify.java)
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DSG_Notify.java?p2=incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DSG_Notify.java&p1=incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/DSG_Notify.java&r1=1214656&r2=1220543&rev=1220543&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/DSG_Notify.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DSG_Notify.java Sun Dec 18 21:16:03 2011
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package dev;
+package dsg;
 
 import org.openjena.atlas.event.Event ;
 import org.openjena.atlas.event.EventManager ;

Added: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DatasetGraphSimpleMem.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DatasetGraphSimpleMem.java?rev=1220543&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DatasetGraphSimpleMem.java (added)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/DatasetGraphSimpleMem.java Sun Dec 18 21:16:03 2011
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dsg;
+
+import java.util.ArrayList ;
+import java.util.Collection ;
+import java.util.Iterator ;
+
+import org.openjena.atlas.iterator.Iter ;
+
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
+import com.hp.hpl.jena.sparql.ARQException ;
+import com.hp.hpl.jena.sparql.core.DatasetGraphBase ;
+import com.hp.hpl.jena.sparql.core.Quad ;
+
+// GraphMemSimple2, DSG_Mem
+
+/** A Triples+Quads implementation of DatasetGraph for small-scale use such as testing. */
+public class DatasetGraphSimpleMem extends DatasetGraphBase //implements DatasetGraph 
+{
+    // See helpers in DatasetGraphBase
+    //  triples2quadsDftGraph
+    //  triples2quads
+    // See helpers in DatasetGraphQuad
+    //  projectGraphName
+    // 
+    
+    private MiniSet<Triple> triples = new MiniSet<Triple>() ;
+    private MiniSet<Quad> quads = new MiniSet<Quad>() ;
+    
+    class MiniSet<T> implements Iterable<T>
+    {
+        final Collection<T> store ; 
+        MiniSet(Collection<T> store) { this.store = store ; }
+        
+        MiniSet() { this.store = new ArrayList<T>() ; }
+        
+        void add(T t)
+        {
+            if ( !store.contains(t) ) 
+                store.add(t) ;
+        }
+        
+        void remove(T t)
+        {
+            store.remove(t) ; 
+        }
+
+        @Override
+        public Iterator<T> iterator()
+        {
+            return store.iterator() ;
+        }
+        
+        boolean isEmpty() { return store.isEmpty() ; }
+        
+        int size() { return store.size() ; }
+    }
+    
+    
+    public DatasetGraphSimpleMem() {}
+    
+    @Override
+    public Iterator<Node> listGraphNodes()
+    {
+        return null ;
+    }
+
+    @Override
+    public Iterator<Quad> find(Node g, Node s, Node p, Node o)
+    {
+        return Iter.concat(triples2quadsDftGraph(triples.iterator()),
+                           quads.iterator()) ;
+    }
+
+    private boolean isDefaultGraph(Quad quad)
+    {
+        return quad.isDefaultGraph() || quad.isTriple() ;  
+    }
+    
+    @Override
+    public void add(Quad quad)
+    { 
+        if ( ! quad.isConcrete() )
+            throw new ARQException("Not a concrete quad") ;
+        
+        if ( isDefaultGraph(quad) )
+        {
+            Triple triple = quad.asTriple() ;
+            
+            triples.add(triple) ;
+            return ;
+        }
+        quads.add(quad) ;
+    }
+    
+    @Override
+    public void delete(Quad quad)
+    { 
+        if ( ! quad.isConcrete() )
+            throw new ARQException("Not a concrete quad") ;
+        
+        if (isDefaultGraph(quad) )
+        {
+            Triple triple = quad.asTriple() ;
+            triples.remove(triple) ;
+            return ;
+        }
+        quads.remove(quad) ;
+    }
+    
+    @Override
+    public Iterator<Quad> findNG(Node g, Node s, Node p, Node o)
+    {
+        return quads.iterator() ;
+    }
+
+    @Override
+    public Graph getDefaultGraph()
+    {
+        return null ;
+    }
+
+    @Override
+    public Graph getGraph(Node graphNode)
+    {
+        return null ;
+    }
+}

Added: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/TestDatasetGraphSimpleMem.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/TestDatasetGraphSimpleMem.java?rev=1220543&view=auto
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/TestDatasetGraphSimpleMem.java (added)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dsg/TestDatasetGraphSimpleMem.java Sun Dec 18 21:16:03 2011
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package dsg;
+
+// Which is which?
+import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.sparql.core.DatasetGraphTests ;
+
+public class TestDatasetGraphSimpleMem extends DatasetGraphTests /* Theer are two of these :-( */
+{
+
+    @Override
+    protected DatasetGraph emptyDataset()
+    {
+        return new DatasetGraphSimpleMem() ;
+    }
+    
+    // Sort out.
+//    com.hp.hpl.jena.sparql.graph.TestDatasetGraphMem x ;
+//    com.hp.hpl.jena.sparql.core.TestDatasetGraphMem y ;
+    
+    
+}
+