clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enrid...@apache.org
Subject git commit: CLEREZZA-874 More accurate criteria to switch to alternative insert method for long literals
Date Sat, 08 Feb 2014 23:28:41 GMT
Updated Branches:
  refs/heads/master 83c1997c2 -> b84bb594b


CLEREZZA-874 More accurate criteria to switch to alternative insert method for long literals


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/b84bb594
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/b84bb594
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/b84bb594

Branch: refs/heads/master
Commit: b84bb594b269124fe230c59c8463356faceeb6eb
Parents: 83c1997
Author: enridaga <enridaga@apache.org>
Authored: Sat Feb 8 23:28:41 2014 +0000
Committer: enridaga <enridaga@apache.org>
Committed: Sat Feb 8 23:28:41 2014 +0000

----------------------------------------------------------------------
 .../rdf/virtuoso/storage/VirtuosoMGraph.java    | 31 ++++++++++----------
 .../java/rdf/virtuoso/storage/RdfIOTest.java    |  6 ++--
 .../virtuoso/storage/VirtuosoMGraphTest.java    |  6 ++--
 3 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/b84bb594/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
index e173043..a020047 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/main/java/rdf/virtuoso/storage/VirtuosoMGraph.java
@@ -65,8 +65,7 @@ import virtuoso.jdbc4.VirtuosoResultSet;
 public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 		LockableMGraph {
 	
-	// XXX This may be a configuration of the weighted provider
-	private static final int PLAN_B_LITERAL_SIZE = 50000;
+	private static final int PLAN_B_LITERAL_SIZE = 1900;
 
 	private static final int CHECKPOINT = 1000;
 	
@@ -425,6 +424,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 			st = connection.prepareStatement(sql);
 			st.setNString(1, b.toString());
 			st.execute();
+			connection.commit();
 		} catch (VirtuosoException ve) {
 			logger.error("ERROR while executing statement", ve);
 			e = ve;
@@ -463,17 +463,25 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	protected boolean performAdd(Triple triple) {
 		logger.debug("performAdd(Triple {})", triple);
 		
-		// XXX If the object is a very long literal we use plan B
+		// XXX 
+		// If the object is a very long literal we use plan B
+		// Reason:
+		// Virtuoso Error:
+		// SR449: Key is too long, index RDF_QUAD, ruling part is 1901 bytes that exceeds 1900
byte limit
 		if (triple.getObject() instanceof Literal) {
-			if (((Literal) triple.getObject()).getLexicalForm().length() > PLAN_B_LITERAL_SIZE)
{
+			int litsize = ((Literal) triple.getObject()).getLexicalForm().getBytes().length;
+			if(triple.getObject() instanceof TypedLiteral){
+				litsize += ((TypedLiteral) triple.getObject()).getDataType().getUnicodeString().getBytes().length;
+			}else{
+				litsize += 10; // lang annotation should not be longer then 10 bytes...
+			}
+			if ( litsize > PLAN_B_LITERAL_SIZE) {
 				return performAddPlanB(triple);
 			}
 		}
 
 		// String sql = getAddSQLStatement(triple);
 		String sql = INSERT;
-		// logger.info("Executing SQL: {}", sql);
-		// logger.info("--- {} ", sql);
 		writeLock.lock();
 		VirtuosoConnection connection = null;
 		Exception e = null;
@@ -539,13 +547,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 			// if datatype is XMLLiteral
 			String lf = tl.getLexicalForm();
 			if(tl.getDataType().getUnicodeString().equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")){
-				//lf = prepareString(lf, true).toString();
-			}
-
-			// XXX
-			if(object.toString().length() == 416){
-				logger.warn("416 Chars length");
-				lf += " XXXXXXXXXX  ";
+				lf = prepareString(lf, true).toString();
 			}
 			st.setString(i+1, lf);
 			st.setString(i+2, tl.getDataType().getUnicodeString());
@@ -652,7 +654,6 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	 */
 	private VirtuosoBNode nextVirtBnode(BNode bn) {
 		logger.debug("nextVirtBnode(BNode)");
-		// maxVirtBnodeIndex++;
 
 		String temp_graph = "<urn:x-virtuoso:bnode-tmp>";
 		String bno = new StringBuilder().append('<').append(bn).append('>')
@@ -854,7 +855,7 @@ public class VirtuosoMGraph extends AbstractMGraph implements MGraph,
 	private String toVirtPlainLiteral(PlainLiteral object) {
 		logger.debug("toVirtPlainLiteral(PlainLiteral {})", object);
 		Language lang = object.getLanguage();
-		String literal = object.getLexicalForm();// .replaceAll("\"", "\\\\\"");
+		String literal = object.getLexicalForm();
 		StringBuilder sb = new StringBuilder().append('"').append('"')
 				.append('"').append(prepareString(literal, false)).append('"')
 				.append('"').append('"');

http://git-wip-us.apache.org/repos/asf/clerezza/blob/b84bb594/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/RdfIOTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/RdfIOTest.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/RdfIOTest.java
index 2e6dc72..a80697a 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/RdfIOTest.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/RdfIOTest.java
@@ -116,16 +116,16 @@ public class RdfIOTest {
 	}
 
 	@Test
-	public void longString() throws ClassNotFoundException, SQLException {
+	public void longString() throws ClassNotFoundException, SQLException, InterruptedException
{
 		if (TestUtils.SKIP) {
 			log.warn("SKIPPED");
 			return;
 		}
 		log.info("Test a long xsd:string");
 		StringBuilder longStr = new StringBuilder();
-		int c = 1000;
+		int c = 1500;
 		while (c > 0) {
-			longStr.append(" another piece of string ");
+			longStr.append(" ");
 			c--;
 		}
 		int size = longStr.length();

http://git-wip-us.apache.org/repos/asf/clerezza/blob/b84bb594/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
----------------------------------------------------------------------
diff --git a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
index 32fa59f..6bdbbe3 100644
--- a/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
+++ b/clerezza-virtuoso/rdf.virtuoso.storage/src/test/java/rdf/virtuoso/storage/VirtuosoMGraphTest.java
@@ -448,10 +448,10 @@ public class VirtuosoMGraphTest {
 			log.warn("SKIPPED");
 			return;
 		}
-		log.info("not Clearing graph <{}> of size {}", TEST_GRAPH_NAME,
+		log.info("Clearing graph <{}> of size {}", TEST_GRAPH_NAME,
 				mgraph.size());
 		log.debug("Removing graph <{}>", TEST_GRAPH_NAME);
-//		Statement st = TestUtils.getConnection().createStatement();
-//		st.execute("SPARQL CLEAR GRAPH <" + TEST_GRAPH_NAME + ">");
+		Statement st = TestUtils.getConnection().createStatement();
+		st.execute("SPARQL CLEAR GRAPH <" + TEST_GRAPH_NAME + ">");
 	}
 }


Mime
View raw message