| 
     
      
      
      From: <tho...@us...> - 2014-11-18 15:01:33
      
     
   | 
Revision: 8717
          http://sourceforge.net/p/bigdata/code/8717
Author:   thompsonbry
Date:     2014-11-18 15:01:18 +0000 (Tue, 18 Nov 2014)
Log Message:
-----------
RDR test suites.
Modified Paths:
--------------
    branches/BIGDATA_RELEASE_1_4_0/bigdata/src/releases/RELEASE_1_4_0.txt
    branches/BIGDATA_RELEASE_1_4_0/bigdata/src/resources/logging/log4j.properties
    branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java
    branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/reif/rdr-04.ttlx
    branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/WorkbenchServlet.java
    branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java
    branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java
Added Paths:
-----------
    branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestRDROperations.java
    branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/rdr_01.ttlx
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata/src/releases/RELEASE_1_4_0.txt
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata/src/releases/RELEASE_1_4_0.txt	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata/src/releases/RELEASE_1_4_0.txt	2014-11-18 15:01:18 UTC (rev 8717)
@@ -53,14 +53,17 @@
 
 - http://trac.bigdata.com/ticket/714  (Migrate to openrdf 2.7)
 - http://trac.bigdata.com/ticket/745  (BackgroundTupleResult overrides final method close)
+- http://trac.bigdata.com/ticket/751  (explicit bindings get ignored in subselect (duplicate of #714))
 - http://trac.bigdata.com/ticket/813  (Documentation on BigData Reasoning)
 - http://trac.bigdata.com/ticket/911  (workbench does not display errors well)
 - http://trac.bigdata.com/ticket/1035 (DISTINCT PREDICATEs query is slow)
 - http://trac.bigdata.com/ticket/1037 (SELECT COUNT(...) (DISTINCT|REDUCED) {single-triple-pattern} is slow)
+- http://trac.bigdata.com/ticket/1038 (RDR RDF parsers are not always discovered)
 - http://trac.bigdata.com/ticket/1044 (ORDER_BY ordering not preserved by projection operator)
 - http://trac.bigdata.com/ticket/1047 (NQuadsParser hangs when loading latest dbpedia dump.)
 - http://trac.bigdata.com/ticket/1052 (ASTComplexOptionalOptimizer did not account for Values clauses)
 - http://trac.bigdata.com/ticket/1054 (BigdataGraphFactory create method cannot be invoked from the gremlin command line due to a Boolean vs boolean type mismatch.)
+- http://trac.bigdata.com/ticket/1058 (update RDR documentation on wiki)
 - http://trac.bigdata.com/ticket/1061 (Server does not generate RDR aware JSON for RDF/SPARQL RESULTS)
 
 1.3.4:
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata/src/resources/logging/log4j.properties
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata/src/resources/logging/log4j.properties	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata/src/resources/logging/log4j.properties	2014-11-18 15:01:18 UTC (rev 8717)
@@ -10,13 +10,15 @@
 log4j.logger.com.bigdata.btree=WARN
 log4j.logger.com.bigdata.counters.History=ERROR
 log4j.logger.com.bigdata.counters.XMLUtility$MyHandler=ERROR
-log4j.logger.com.bigdata.counters.query.CounterSetQuery=INFO
-log4j.logger.com.bigdata.journal.CompactTask=INFO
+#log4j.logger.com.bigdata.counters.query.CounterSetQuery=INFO
+#log4j.logger.com.bigdata.journal.CompactTask=INFO
 log4j.logger.com.bigdata.relation.accesspath.BlockingBuffer=ERROR
 log4j.logger.com.bigdata.rdf.load=INFO
 log4j.logger.com.bigdata.rdf.store.DataLoader=INFO
 log4j.logger.com.bigdata.resources.AsynchronousOverflowTask=INFO
 
+#log4j.logger.com.bigdata.rdf.ServiceProviderHook=INFO
+
 #log4j.logger.com.bigdata.rdf.sparql=ALL
 #log4j.logger.com.bigdata.rdf.sail.sparql.BigdataExprBuilder=INFO
 #log4j.logger.com.bigdata.rdf.sail.TestProvenanceQuery=ALL
@@ -78,3 +80,36 @@
 log4j.appender.queryRunStateLog.BufferedIO=false
 log4j.appender.queryRunStateLog.layout=org.apache.log4j.PatternLayout
 log4j.appender.queryRunStateLog.layout.ConversionPattern=%m
+
+## 
+# Solutions trace (tab delimited file).  Uncomment the next line to enable.
+#log4j.logger.com.bigdata.bop.engine.SolutionsLog=INFO,solutionsLog
+log4j.additivity.com.bigdata.bop.engine.SolutionsLog=false
+log4j.appender.solutionsLog=org.apache.log4j.ConsoleAppender
+#log4j.appender.solutionsLog=org.apache.log4j.FileAppender
+log4j.appender.solutionsLog.Threshold=ALL
+#log4j.appender.solutionsLog.File=solutions.csv
+#log4j.appender.solutionsLog.Append=true
+# I find that it is nicer to have this unbuffered since you can see what
+# is going on and to make sure that I have complete rule evaluation logs
+# on shutdown.
+#log4j.appender.solutionsLog.BufferedIO=false
+log4j.appender.solutionsLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.solutionsLog.layout.ConversionPattern=SOLUTION:\t%m
+
+## 
+# SPARQL query trace (plain text file).  Uncomment 2nd line to enable.
+log4j.logger.com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper=WARN
+#log4j.logger.com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper=INFO,sparqlLog
+log4j.additivity.com.bigdata.rdf.sparql.ast.eval.ASTEvalHelper=false
+log4j.appender.sparqlLog=org.apache.log4j.ConsoleAppender
+#log4j.appender.sparqlLog=org.apache.log4j.FileAppender
+log4j.appender.sparqlLog.Threshold=ALL
+#log4j.appender.sparqlLog.File=sparql.txt
+#log4j.appender.sparqlLog.Append=true
+# I find that it is nicer to have this unbuffered since you can see what
+# is going on and to make sure that I have complete rule evaluation logs
+# on shutdown.
+#log4j.appender.sparqlLog.BufferedIO=false
+log4j.appender.sparqlLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.sparqlLog.layout.ConversionPattern=#----------%d-----------tx=%X{tx}\n%m\n
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/java/com/bigdata/rdf/ServiceProviderHook.java	2014-11-18 15:01:18 UTC (rev 8717)
@@ -235,7 +235,7 @@
         	
         	final TupleQueryResultWriterRegistry r = TupleQueryResultWriterRegistry.getInstance();
 
-        	// add our custom RDR-enabled JSON writer
+        	// add our custom RDR-enabled JSON writer for SPARQL result sets.
         	r.add(new BigdataSPARQLResultsJSONWriterFactory());
         	
         }
@@ -244,7 +244,7 @@
             
             final TupleQueryResultParserRegistry r = TupleQueryResultParserRegistry.getInstance();
 
-            // add our custom RDR-enabled JSON parser
+            // add our custom RDR-enabled JSON parser for SPARQL result sets.
             r.add(new BigdataSPARQLResultsJSONParserFactory());
             
         }
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/reif/rdr-04.ttlx
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/reif/rdr-04.ttlx	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/reif/rdr-04.ttlx	2014-11-18 15:01:18 UTC (rev 8717)
@@ -1,5 +1,4 @@
 @prefix :          <http://example.com/> . 
-@prefix rdf:       <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . 
 
 :a1 :b :c .
 :a2 :b :c .
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/WorkbenchServlet.java
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/WorkbenchServlet.java	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/WorkbenchServlet.java	2014-11-18 15:01:18 UTC (rev 8717)
@@ -87,8 +87,9 @@
     private void doConvert(final HttpServletRequest req,
             final HttpServletResponse resp) throws IOException {
         
-    	    final String baseURI = req.getRequestURL().toString();
+    	final String baseURI = req.getRequestURL().toString();
     	
+    	// The content type of the request.
         final String contentType = req.getContentType();
 
         if (log.isInfoEnabled())
@@ -155,6 +156,10 @@
 	         */
 	        rdfParser.parse(req.getInputStream(), baseURI);
 	
+	        /*
+			 * Send back the graph using CONNEG to decide the MIME Type of the
+			 * response.
+			 */
 	        sendGraph(req, resp, g);
 	        
         } catch (Throwable t) {
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/AbstractTestNanoSparqlClient.java	2014-11-18 15:01:18 UTC (rev 8717)
@@ -26,7 +26,6 @@
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.LineNumberReader;
 import java.io.Reader;
@@ -392,32 +391,61 @@
 
     }
 
-	protected String getStreamContents(final InputStream inputStream)
-            throws IOException {
+//	protected String getStreamContents(final InputStream inputStream)
+//            throws IOException {
+//
+//        final Reader rdr = new InputStreamReader(inputStream);
+//		
+//	    final StringBuffer sb = new StringBuffer();
+//		
+//	    final char[] buf = new char[512];
+//	    
+//		while (true) {
+//		
+//		    final int rdlen = rdr.read(buf);
+//			
+//		    if (rdlen == -1)
+//				break;
+//			
+//		    sb.append(buf, 0, rdlen);
+//		    
+//		}
+//		
+//		return sb.toString();
+//
+//	}
 
-        final Reader rdr = new InputStreamReader(inputStream);
-		
-	    final StringBuffer sb = new StringBuffer();
-		
-	    final char[] buf = new char[512];
-	    
-		while (true) {
-		
-		    final int rdlen = rdr.read(buf);
-			
-		    if (rdlen == -1)
-				break;
-			
-		    sb.append(buf, 0, rdlen);
-		    
-		}
-		
-		return sb.toString();
+	/**
+	 * Counts the #of results in a SPARQL result set.
+	 * 
+	 * @param result
+	 *            The connection from which to read the results.
+	 * 
+	 * @return The #of results.
+	 * 
+	 * @throws Exception
+	 *             If anything goes wrong.
+	 */
+	protected long countResults(final TupleQueryResult result) throws Exception {
 
+    	long count = 0;
+    	
+    	while(result.hasNext()) {
+    		
+    		result.next();
+    		
+    		count++;
+    		
+    	}
+    	
+    	result.close();
+    	
+    	return count;
+    	
 	}
 
 	/**
-	 * Counts the #of results in a SPARQL result set.
+	 * Counts the #of results in a GRAPH result set.
 	 * 
 	 * @param result
 	 *            The connection from which to read the results.
@@ -427,7 +455,7 @@
 	 * @throws Exception
 	 *             If anything goes wrong.
 	 */
-	protected long countResults(final TupleQueryResult result) throws Exception {
+	protected long countResults(final GraphQueryResult result) throws Exception {
 
     	long count = 0;
     	
@@ -914,6 +942,16 @@
 
     }
     
+    /**
+	 * Read a graph from a file.
+	 * 
+	 * @param file
+	 *            The file.
+	 * @return The contents as a {@link Graph}.
+	 * @throws RDFParseException
+	 * @throws RDFHandlerException
+	 * @throws IOException
+	 */
     protected static Graph readGraphFromFile(final File file) throws RDFParseException, RDFHandlerException, IOException {
         
         final RDFFormat format = RDFFormat.forFileName(file.getName());
Modified: branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java	2014-11-18 12:03:24 UTC (rev 8716)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestNanoSparqlServerWithProxyIndexManager.java	2014-11-18 15:01:18 UTC (rev 8717)
@@ -270,6 +270,7 @@
             break;
         case sids:
             // TODO SIDS mode UPDATE test suite.
+        	suite.addTestSuite(TestRDROperations.class);
             break;
         case quads:
             // QUADS mode UPDATE test suite. 
Added: branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestRDROperations.java
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestRDROperations.java	                        (rev 0)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/TestRDROperations.java	2014-11-18 15:01:18 UTC (rev 8717)
@@ -0,0 +1,219 @@
+/**
+Copyright (C) SYSTAP, LLC 2006-2007.  All rights reserved.
+
+Contact:
+     SYSTAP, LLC
+     4501 Tower Road
+     Greensboro, NC 27410
+     lic...@bi...
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+package com.bigdata.rdf.sail.webapp;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import junit.framework.Test;
+
+import com.bigdata.journal.IIndexManager;
+import com.bigdata.rdf.ServiceProviderHook;
+import com.bigdata.rdf.sail.webapp.client.IPreparedBooleanQuery;
+import com.bigdata.rdf.sail.webapp.client.IPreparedGraphQuery;
+import com.bigdata.rdf.sail.webapp.client.IPreparedTupleQuery;
+import com.bigdata.rdf.sail.webapp.client.RemoteRepository.AddOp;
+
+/**
+ * Test of RDR specific data interchange and query.
+ * 
+ * @author bryan
+ * 
+ * @param <S>
+ */
+public class TestRDROperations<S extends IIndexManager> extends
+		AbstractTestNanoSparqlClient<S> {
+
+	public TestRDROperations() {
+
+	}
+
+	public TestRDROperations(final String name) {
+
+		super(name);
+
+	}
+
+	public static Test suite() {
+
+		return ProxySuiteHelper.suiteWhenStandalone(TestRDROperations.class,
+				"test.*", TestMode.sids);
+
+	}
+
+    public void test_POST_INSERT_withBody_TURTLE_RDR() throws Exception {
+
+    	final long ntriples = 3L;
+    	
+		InputStream is = null;
+		try {
+			is = new FileInputStream(new File(packagePath + "rdr_01.ttlx"));
+			final AddOp add = new AddOp(is, ServiceProviderHook.TURTLE_RDR);
+			assertEquals(ntriples, m_repo.add(add));
+		} finally {
+			if (is != null) {
+				is.close();
+			}
+		}
+
+		/*
+		 * Verify normal ground triple is present.
+		 */
+		{
+
+			final String queryStr = "ASK {<x:a1> <x:b1> <x:c1>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertTrue(query.evaluate());
+			
+		}
+		
+		// false positive test (not found).
+		{
+
+			final String queryStr = "ASK {<x:a1> <x:b1> <x:c2>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertFalse(query.evaluate());
+			
+		}
+		
+		/*
+		 * Verify RDR ground triple is present.
+		 */
+		{
+
+			final String queryStr = "ASK {<x:a> <x:b> <x:c>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertTrue(query.evaluate());
+			
+		}
+		
+		// RDR false positive test (not found).
+		{
+
+			final String queryStr = "ASK {<x:a> <x:b> <x:c2>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertFalse(query.evaluate());
+			
+		}
+
+		
+		/*
+		 * Verify RDR triple is present.
+		 */
+		{
+
+			final String queryStr = "ASK {<<<x:a> <x:b> <x:c>>> <x:d> <x:e>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertTrue(query.evaluate());
+			
+		}
+		
+		// false positive test for RDR triple NOT present.
+		{
+
+			final String queryStr = "ASK {<<<x:a> <x:b> <x:c>>> <x:d> <x:e2>}";
+
+			final IPreparedBooleanQuery query = m_repo.prepareBooleanQuery(queryStr);
+			
+			assertFalse(query.evaluate());
+			
+		}
+		
+		/*
+		 * Verify the expected #of statements in the store using a SPARQL result
+		 * set.
+		 */
+		{
+
+			final String queryStr = "SELECT * where {?s ?p ?o}";
+
+			final IPreparedTupleQuery query = m_repo.prepareTupleQuery(queryStr);
+			
+			assertEquals(ntriples, countResults(query.evaluate()));
+			
+		}
+        
+		/* 
+		 * Verify the RDR data can be recovered using a CONSTRUCT query.
+		 */
+		{
+
+			final String queryStr = "CONSTRUCT where {?s ?p ?o}";
+
+			final IPreparedGraphQuery query = m_repo.prepareGraphQuery(queryStr);
+			
+			assertEquals(ntriples, countResults(query.evaluate()));
+			
+		}
+        
+		/* 
+		 * Verify the RDR data can be recovered using a DESCRIBE query.
+		 */
+		{
+
+			final String queryStr = "DESCRIBE * {?s ?p ?o}";
+
+			final IPreparedGraphQuery query = m_repo.prepareGraphQuery(queryStr);
+			
+			assertEquals(ntriples, countResults(query.evaluate()));
+			
+		}
+		
+    }
+
+	/**
+	 * FIXME We need to verify export for this case. It relies on access to a
+	 * Bigdata specific ValueFactoryImpl to handle the RDR mode statements.
+	 */
+	public void test_EXPORT_TURTLE_RDR() throws Exception {
+
+
+    	final long ntriples = 3L;
+    	
+		InputStream is = null;
+		try {
+			is = new FileInputStream(new File(packagePath + "rdr_01.ttlx"));
+			final AddOp add = new AddOp(is, ServiceProviderHook.TURTLE_RDR);
+			assertEquals(ntriples, m_repo.add(add));
+		} finally {
+			if (is != null) {
+				is.close();
+			}
+		}
+
+		fail("write export test for TURTLE-RDR");
+
+	}
+
+}
\ No newline at end of file
Added: branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/rdr_01.ttlx
===================================================================
--- branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/rdr_01.ttlx	                        (rev 0)
+++ branches/BIGDATA_RELEASE_1_4_0/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/rdr_01.ttlx	2014-11-18 15:01:18 UTC (rev 8717)
@@ -0,0 +1,3 @@
+<x:a1> <x:b1> <x:c1> .
+
+<<<x:a> <x:b> <x:c>>> <x:d> <x:e> .
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |