From: <tho...@us...> - 2011-03-07 19:59:02
|
Revision: 4277 http://bigdata.svn.sourceforge.net/bigdata/?rev=4277&view=rev Author: thompsonbry Date: 2011-03-07 19:58:52 +0000 (Mon, 07 Mar 2011) Log Message: ----------- Bug fix for https://sourceforge.net/apps/trac/bigdata/ticket/252 (inline dateTime causes error with full tx). I modified the LexiconRelation to always use an unisolated index for mutable views. The lexicon relation uses an eventually consistent strategy to write on the TERM2ID and ID2TERM indices and does not rely on transactional isolation. AbstractRelation#getIndex/3 is used to automatically wrap the unisolated views of those indices with an UnisolatedReadWriteIndex class, which uses a RecurrentReadWriteLock to control access to the unisolated indices. I have added com.bigdata.rdf.sail.TextTxCreate. It verifies that a Sail can be created which supports transactional isolation both with and without inline date times. I have removed the sample code for CreateSailUsingInlineDateTimes in favor of this unit test. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTxCreate.java Removed Paths: ------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.properties Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -28,6 +28,19 @@ import com.bigdata.rdf.lexicon.LexiconRelation; import com.bigdata.rdf.model.BigdataURI; +/** + * Specialized interface for resolving (and creating if necessary) datatype + * URIs. This interface requires access to a mutable view of the database since + * unknown URIs will be registered. + * + * TODO This is not going to be efficient in scale-out since it does not batch + * the resolution of the URIs. It will be more efficient to pass in the set of + * URIs of interest and have them all be registered at once. + * {@link LexiconRelation#addTerms(com.bigdata.rdf.model.BigdataValue[], int, boolean)} + * already provides for this kind of batched resolution. + * + * @author mrpersonick + */ public interface IDatatypeURIResolver { /** Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -699,9 +699,10 @@ return textIndex; } - + /** - * Overridden to return the hard reference for the index. + * Overridden to use {@link #getTerm2IdIndex()} and + * {@link #getId2TermIndex()} as appropriate. */ @Override public IIndex getIndex(final IKeyOrder<? extends BigdataValue> keyOrder) { @@ -730,7 +731,24 @@ if (term2id == null) { - term2id = super.getIndex(LexiconKeyOrder.TERM2ID); + final long timestamp = getTimestamp(); + + if (TimestampUtility.isReadWriteTx(timestamp)) { + /* + * We always use the unisolated view of the lexicon + * indices for mutation and the lexicon indices do NOT + * set the [isolatable] flag even if the kb supports + * full tx isolation. This is because we use an + * eventually consistent strategy to write on the + * lexicon indices. + */ + term2id = AbstractRelation + .getIndex(getIndexManager(), + getFQN(LexiconKeyOrder.TERM2ID), + ITx.UNISOLATED); + } else { + term2id = super.getIndex(LexiconKeyOrder.TERM2ID); + } if (term2id == null) throw new IllegalStateException(); @@ -753,7 +771,24 @@ if (id2term == null) { - id2term = super.getIndex(LexiconKeyOrder.ID2TERM); + final long timestamp = getTimestamp(); + + if (TimestampUtility.isReadWriteTx(timestamp)) { + /* + * We always use the unisolated view of the lexicon + * indices for mutation and the lexicon indices do NOT + * set the [isolatable] flag even if the kb supports + * full tx isolation. This is because we use an + * eventually consistent strategy to write on the + * lexicon indices. + */ + id2term = AbstractRelation + .getIndex(getIndexManager(), + getFQN(LexiconKeyOrder.ID2TERM), + ITx.UNISOLATED); + } else { + id2term = super.getIndex(LexiconKeyOrder.ID2TERM); + } if (id2term == null) throw new IllegalStateException(); @@ -1075,7 +1110,7 @@ if (buri.getIV() == null) { // will set tid on buri as a side effect - TermId tid = getTermId(buri); + final TermId<?> tid = getTermId(buri); if (tid == null) { Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -922,7 +922,7 @@ String INLINE_DATE_TIMES = (AbstractTripleStore.class.getName() + ".inlineDateTimes").intern(); - String DEFAULT_INLINE_DATE_TIMES = "false"; + String DEFAULT_INLINE_DATE_TIMES = "true"; /** * The default timezone to be used to a) encode inline xsd:datetime Deleted: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -1,75 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2011. 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 -*/ -/* - * Created on Feb 17, 2011 - */ - -package com.bigdata.samples; - -import java.util.Properties; - -import com.bigdata.rdf.sail.BigdataSail; - -/** - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class CreateSailUsingInlineDateTimes extends SampleCode { - - static public void main(String[] args) { - - try { - - CreateSailUsingInlineDateTimes f = new CreateSailUsingInlineDateTimes(); - - final String resource = "CreateSailUsingInlineDateTimes.properties"; - - final Properties properties = f.loadProperties(resource); - - System.out.println("Read properties from resource: " + resource); - properties.list(System.out); - - final BigdataSail sail = new BigdataSail(properties); - - sail.initialize(); - - try { - - System.out.println("Sail is initialized."); - - } finally { - - sail.shutDown(); - - } - - } catch (Throwable t) { - - t.printStackTrace(System.err); - - } - - } - -} Deleted: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.properties =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.properties 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/samples/com/bigdata/samples/CreateSailUsingInlineDateTimes.properties 2011-03-07 19:58:52 UTC (rev 4277) @@ -1,18 +0,0 @@ -com.bigdata.journal.AbstractJournal.createTempFile=true -com.bigdata.journal.AbstractJournal.deleteOnClose=true -com.bigdata.journal.AbstractJournal.deleteOnExit=true -# to not fail testcases that count... (NOT recommended). -com.bigdata.rdf.sail.exactSize=true -# This is full tx support, which does not have nearly the throughput of an unisolated writer combined with concurrent readers. -com.bigdata.rdf.sail.isolatableIndices=true -com.bigdata.rdf.sail.truthMaintenance=false -# This option will be going away once we finish the query engine refactor. -com.bigdata.rdf.sail.allowSesameQueryEvaluation=true -# Auto-commit is NOT recommended. -com.bigdata.rdf.sail.allowAutoCommit=true -com.bigdata.rdf.store.AbstractTripleStore.axiomsClass=com.bigdata.rdf.axioms.NoAxioms -com.bigdata.rdf.store.AbstractTripleStore.quads=true -com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers=false -com.bigdata.rdf.store.AbstractTripleStore.vocabularyClass=com.bigdata.rdf.vocab.NoVocabulary -com.bigdata.rdf.store.AbstractTripleStore.justify=false -com.bigdata.rdf.store.AbstractTripleStore.inlineDateTimes=true Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -105,6 +105,8 @@ suite.addTestSuite(TestInlineValues.class); + suite.addTestSuite(TestTxCreate.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -84,7 +84,9 @@ suite.addTestSuite(TestDescribe.class); suite.addTestSuite(TestInlineValues.class); - + + suite.addTestSuite(TestTxCreate.class); + return suite; } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2011-03-07 15:04:34 UTC (rev 4276) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -81,6 +81,8 @@ suite.addTestSuite(TestInlineValues.class); + suite.addTestSuite(TestTxCreate.class); + return suite; } Added: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTxCreate.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTxCreate.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTxCreate.java 2011-03-07 19:58:52 UTC (rev 4277) @@ -0,0 +1,147 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. 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 +*/ +/* + * Created on Mar 7, 2011 + */ + +package com.bigdata.rdf.sail; + +import java.util.Properties; + +import org.openrdf.sail.SailException; + +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.internal.LexiconConfiguration; +import com.bigdata.rdf.store.AbstractTripleStore; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * Unit test for the creation of a Sail with isolatable indices. This unit test + * was developed in response to <a + * href="https://sourceforge.net/apps/trac/bigdata/ticket/252">issue #252</a>, + * which reported a problem when creating a Sail which supports fully isolated + * indices and also uses inline date times. The problem goes back to how the + * {@link LexiconConfiguration} gains access to the ID2TERM index when it is + * initialized. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class TestTxCreate extends ProxyBigdataSailTestCase { + + /** + * + */ + public TestTxCreate() { + } + + /** + * @param name + */ + public TestTxCreate(String name) { + super(name); + } + + /** + * Version of the test with data time inlining disabled. + * + * @throws SailException + */ + public void test_tx_create() throws SailException { + + final Properties properties = getProperties(); + + // truth maintenance is not compatible with full transactions. + properties.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + + properties.setProperty(AbstractTripleStore.Options.AXIOMS_CLASS, + NoAxioms.class.getName()); + + properties.setProperty(AbstractTripleStore.Options.VOCABULARY_CLASS, + NoVocabulary.class.getName()); + + properties.setProperty(BigdataSail.Options.ISOLATABLE_INDICES, "true"); + + properties.setProperty(AbstractTripleStore.Options.JUSTIFY, "false"); + + properties.setProperty(AbstractTripleStore.Options.INLINE_DATE_TIMES, + "false"); + + final BigdataSail sail = new BigdataSail(properties); + + try { + + sail.initialize(); + + log.info("Sail is initialized."); + + } finally { + + sail.__tearDownUnitTest(); + + } + + } + + /** + * Version of the test with data time inlining enabled. + * @throws SailException + */ + public void test_tx_create_withInlineDateTimes() throws SailException { + + final Properties properties = getProperties(); + + // truth maintenance is not compatible with full transactions. + properties.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + + properties.setProperty(AbstractTripleStore.Options.AXIOMS_CLASS, + NoAxioms.class.getName()); + + properties.setProperty(AbstractTripleStore.Options.VOCABULARY_CLASS, + NoVocabulary.class.getName()); + + properties.setProperty(AbstractTripleStore.Options.JUSTIFY, "false"); + + properties.setProperty(BigdataSail.Options.ISOLATABLE_INDICES, "true"); + + properties.setProperty(AbstractTripleStore.Options.INLINE_DATE_TIMES, + "true"); + + final BigdataSail sail = new BigdataSail(properties); + + try { + + sail.initialize(); + + log.info("Sail is initialized."); + + } finally { + + sail.__tearDownUnitTest(); + + } + + } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestTxCreate.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |