From: <tho...@us...> - 2011-03-04 15:24:27
|
Revision: 4273 http://bigdata.svn.sourceforge.net/bigdata/?rev=4273&view=rev Author: thompsonbry Date: 2011-03-04 15:24:20 +0000 (Fri, 04 Mar 2011) Log Message: ----------- Working on reducing heap pressure under sustained concurrent query by improving sharing of data structures across views of the triple store backed by the same commit point. => Modified BigdataSail#createLTS() to locate the LTS even when it is created new such that the correct properties are materialized from the GRS and made visible to the LTS. This makes it possible to access the pre-materialized Vocabulary and Axioms objects. => Added AbstractResource#getBareProperties(), which does NOT wrap the Properties object. Wrapping the Properties object protects it against inadvertent modification, but doing so makes it impossible to access non-String property values using Hastable#get(name) since they are inside of the protected default Properties object. getBareProperties() can be used in those cases where you need to access non-String property values. The caller is responsible for avoiding mutation to the returned Properties object. => Replaced the LocalTriple(Properties) constructor, which was only used by the unit tests, with a static getInstance(properties) method. As of this change, getInstance() correctly reports the properties materialized from the GRS rather than those passed in by the caller. => Modified AbstractTripleStore#getVocabulary() to return the pre-materialized the object using getBareProperties() rather than re-materializing it from the GRS. => Modified AbstractTripleStore#getAxioms() to return the pre-materialized the object using getBareProperties() rather than re-materializing it from the GRS. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/AbstractResource.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/locator/DefaultResourceLocator.java 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/LocalTripleStore.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestVocabulary.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestTruthMaintenance.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalQuadStore.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutStatementIdentifiers.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/AbstractResource.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/AbstractResource.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/AbstractResource.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -513,15 +513,35 @@ } /** - * Return an object wrapping the properties specified to the ctor. + * Wrap and return the properties specified to the ctor. Wrapping the + * {@link Properties} object prevents inadvertent side-effects. */ public final Properties getProperties() { - + return new Properties(properties); } /** + * Return the {@link Properties} object without wrapping it. This method can + * be used in those cases where you need to access non-String property + * values. The caller is responsible for avoiding mutation to the returned + * Properties object. + * <p> + * Note: This explicitly does NOT wrap the properties. Doing so makes it + * impossible to access the default properties using Hashtable#get(), which + * in turn means that we can not access non-String objects which have been + * materialized from the GRS in the {@link Properties}. This does introduce + * some potential for side-effects between read-only instances of the same + * resource view which share the same properties object. + */ + protected final Properties getBareProperties() { + + return properties; + + } + + /** * Return the object used to locate indices, relations, and relation * containers and to execute operations on those resources. * <p> @@ -748,4 +768,21 @@ } +// /** +// * Sets the property on the underlying properties object but DOES NOT set +// * the property on the global row store (GRS). This method may be used when +// * a resource is newly created in order to cache objects which are persisted +// * on the GRS. +// * +// * @param name +// * The property name. +// * @param value +// * The property value. +// */ +// protected void setProperty(final String name, final Object value) { +// +// properties.put(name, value); +// +// } + } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/locator/DefaultResourceLocator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/locator/DefaultResourceLocator.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/relation/locator/DefaultResourceLocator.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -693,7 +693,7 @@ * @param properties * Configuration properties for the relation. * - * @return A new instance of the identifed resource. + * @return A new instance of the identified resource. */ protected T newInstance(final Class<? extends T> cls, final IIndexManager indexManager, final String namespace, 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-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -471,7 +471,8 @@ * @see LexiconRelation * @see KeyBuilder.Options */ - String LEXICON = AbstractTripleStore.class.getName() + ".lexicon"; + String LEXICON = (AbstractTripleStore.class.getName() + ".lexicon") + .intern(); String DEFAULT_LEXICON = "true"; @@ -494,7 +495,8 @@ * this option in order to spend less time writing the forward lexicon * index (and it will also take up less space). */ - String STORE_BLANK_NODES = AbstractTripleStore.class.getName() + ".storeBlankNodes"; + String STORE_BLANK_NODES = (AbstractTripleStore.class.getName() + ".storeBlankNodes") + .intern(); String DEFAULT_STORE_BLANK_NODES = "false"; @@ -556,9 +558,8 @@ * partitions for the statement indices, then SQRT(50) =~ 7 would be a * good choice. */ - String TERMID_BITS_TO_REVERSE = AbstractTripleStore.class - .getName() - + ".termIdBitsToReverse"; + String TERMID_BITS_TO_REVERSE = (AbstractTripleStore.class.getName() + ".termIdBitsToReverse") + .intern(); String DEFAULT_TERMID_BITS_TO_REVERSE = "6"; @@ -569,7 +570,8 @@ * * @see #TEXT_INDEXER_CLASS */ - String TEXT_INDEX = AbstractTripleStore.class.getName() + ".textIndex"; + String TEXT_INDEX = (AbstractTripleStore.class.getName() + ".textIndex") + .intern(); String DEFAULT_TEXT_INDEX = "true"; @@ -578,9 +580,8 @@ * full text index that may be used to lookup datatype literals by * tokens found in the text of those literals. */ - String TEXT_INDEX_DATATYPE_LITERALS = AbstractTripleStore.class - .getName() - + ".textIndex.datatypeLiterals"; + String TEXT_INDEX_DATATYPE_LITERALS = (AbstractTripleStore.class + .getName() + ".textIndex.datatypeLiterals").intern(); String DEFAULT_TEXT_INDEX_DATATYPE_LITERALS = "true"; @@ -589,8 +590,8 @@ * cache provides fast lookup of frequently used RDF {@link Value}s by * their term identifier. */ - String TERM_CACHE_CAPACITY = AbstractTripleStore.class.getName() - + ".termCache.capacity"; + String TERM_CACHE_CAPACITY = (AbstractTripleStore.class.getName() + + ".termCache.capacity").intern(); String DEFAULT_TERM_CACHE_CAPACITY = "500";//"50000"; @@ -609,7 +610,8 @@ * @see NoVocabulary * @see RDFSVocabulary */ - String VOCABULARY_CLASS = AbstractTripleStore.class.getName() + ".vocabularyClass"; + String VOCABULARY_CLASS = (AbstractTripleStore.class.getName() + ".vocabularyClass") + .intern(); String DEFAULT_VOCABULARY_CLASS = RDFSVocabulary.class.getName(); @@ -621,8 +623,9 @@ * {@link BaseAxioms}. This option is ignored if the lexicon is * disabled. Use {@link NoAxioms} to disable inference. */ - String AXIOMS_CLASS = AbstractTripleStore.class.getName() + ".axiomsClass"; - + String AXIOMS_CLASS = (AbstractTripleStore.class.getName() + ".axiomsClass") + .intern(); + String DEFAULT_AXIOMS_CLASS = OwlAxioms.class.getName(); /** @@ -653,7 +656,8 @@ * at query time. Both {@link FastClosure} and {@link FullClosure} are * aware of this and handle it correctly (e.g., as configured). */ - String CLOSURE_CLASS = AbstractTripleStore.class.getName() + ".closureClass"; + String CLOSURE_CLASS = (AbstractTripleStore.class.getName() + ".closureClass") + .intern(); String DEFAULT_CLOSURE_CLASS = FastClosure.class.getName(); @@ -673,7 +677,8 @@ * use the {@link #BLOOM_FILTER}. Otherwise it may be turned off to * realize some (minimal) performance gain. */ - String ONE_ACCESS_PATH = AbstractTripleStore.class.getName() + ".oneAccessPath"; + String ONE_ACCESS_PATH = (AbstractTripleStore.class.getName() + ".oneAccessPath") + .intern(); String DEFAULT_ONE_ACCESS_PATH = "false"; @@ -709,8 +714,9 @@ * which of them would benefit from the SPO bloom filter (TM, * backchainers, SIDs fixed point, etc). */ - String BLOOM_FILTER = AbstractTripleStore.class.getName() + ".bloomFilter"; - + String BLOOM_FILTER = (AbstractTripleStore.class.getName() + ".bloomFilter") + .intern(); + String DEFAULT_BLOOM_FILTER = "true"; /** @@ -727,7 +733,8 @@ * justifications are maintained in a distinct index and are only used * when retracting assertions. */ - String JUSTIFY = AbstractTripleStore.class.getName() + ".justify"; + String JUSTIFY = (AbstractTripleStore.class.getName() + ".justify") + .intern(); String DEFAULT_JUSTIFY = "true"; @@ -776,8 +783,8 @@ * <p> * There are examples for using the provenance mode online. */ - String STATEMENT_IDENTIFIERS = AbstractTripleStore.class.getName() - + ".statementIdentifiers"; + String STATEMENT_IDENTIFIERS = (AbstractTripleStore.class.getName() + ".statementIdentifiers") + .intern(); String DEFAULT_STATEMENT_IDENTIFIERS = "false"; @@ -787,7 +794,8 @@ * {@link #STATEMENT_IDENTIFIERS} option determines whether or not the * provenance mode is enabled. */ - String QUADS = AbstractTripleStore.class.getName() + ".quads"; + String QUADS = (AbstractTripleStore.class.getName() + ".quads") + .intern(); String DEFAULT_QUADS = "false"; @@ -802,8 +810,8 @@ * = <code>false</code></li> * </ul> */ - String TRIPLES_MODE = AbstractTripleStore.class.getName() - + ".triplesMode"; + String TRIPLES_MODE = (AbstractTripleStore.class.getName() + ".triplesMode") + .intern(); String DEFAULT_TRIPLES_MODE = "false"; @@ -818,8 +826,8 @@ * = <code>true</code></li> * </ul> */ - String TRIPLES_MODE_WITH_PROVENANCE = AbstractTripleStore.class.getName() - + ".triplesModeWithProvenance"; + String TRIPLES_MODE_WITH_PROVENANCE = (AbstractTripleStore.class + .getName() + ".triplesModeWithProvenance").intern(); String DEFAULT_TRIPLES_MODE_WITH_PROVENANCE = "false"; @@ -837,8 +845,8 @@ * = <code>com.bigdata.rdf.store.AbstractTripleStore.NoAxioms</code></li> * </ul> */ - String QUADS_MODE = AbstractTripleStore.class.getName() - + ".quadsMode"; + String QUADS_MODE = (AbstractTripleStore.class.getName() + ".quadsMode") + .intern(); String DEFAULT_QUADS_MODE = "false"; @@ -853,8 +861,8 @@ * * @see #DEFAULT_VALUE_FACTORY_CLASS */ - String VALUE_FACTORY_CLASS = AbstractTripleStore.class.getName() - + ".valueFactoryClass"; + String VALUE_FACTORY_CLASS = (AbstractTripleStore.class.getName() + ".valueFactoryClass") + .intern(); String DEFAULT_VALUE_FACTORY_CLASS = BigdataValueFactoryImpl.class .getName(); @@ -872,8 +880,8 @@ * * @see #DEFAULT_TEXT_INDEXER_CLASS */ - String TEXT_INDEXER_CLASS = AbstractTripleStore.class.getName() - + ".textIndexerClass"; + String TEXT_INDEXER_CLASS = (AbstractTripleStore.class.getName() + ".textIndexerClass") + .intern(); String DEFAULT_TEXT_INDEXER_CLASS = BigdataRDFFullTextIndex.class .getName(); @@ -883,8 +891,8 @@ * statement indices rather than using the lexicon to map them to term * identifiers and back. */ - String INLINE_LITERALS = AbstractTripleStore.class.getName() - + ".inlineLiterals"; + String INLINE_LITERALS = (AbstractTripleStore.class.getName() + ".inlineLiterals") + .intern(); String DEFAULT_INLINE_LITERALS = "true"; @@ -895,8 +903,8 @@ * <p> * See {@link Options#STORE_BLANK_NODES}. */ - String INLINE_BNODES = AbstractTripleStore.class.getName() - + ".inlineBNodes"; + String INLINE_BNODES = (AbstractTripleStore.class.getName() + + ".inlineBNodes").intern(); String DEFAULT_INLINE_BNODES = "false"; @@ -911,8 +919,8 @@ * * @see #INLINE_DATE_TIMES_TIMEZONE */ - String INLINE_DATE_TIMES = AbstractTripleStore.class.getName() - + ".inlineDateTimes"; + String INLINE_DATE_TIMES = (AbstractTripleStore.class.getName() + + ".inlineDateTimes").intern(); String DEFAULT_INLINE_DATE_TIMES = "false"; @@ -925,8 +933,8 @@ * * @see #INLINE_DATE_TIMES */ - String INLINE_DATE_TIMES_TIMEZONE = AbstractTripleStore.class.getName() - + ".inlineDateTimesTimezone"; + String INLINE_DATE_TIMES_TIMEZONE = (AbstractTripleStore.class.getName() + + ".inlineDateTimesTimezone").intern(); /** * @see #INLINE_DATE_TIMES_TIMEZONE @@ -944,8 +952,8 @@ * * @see #DEFAULT_EXTENSION_FACTORY_CLASS */ - String EXTENSION_FACTORY_CLASS = AbstractTripleStore.class.getName() - + ".extensionFactoryClass"; + String EXTENSION_FACTORY_CLASS = (AbstractTripleStore.class.getName() + ".extensionFactoryClass") + .intern(); String DEFAULT_EXTENSION_FACTORY_CLASS = DefaultExtensionFactory.class .getName(); @@ -972,8 +980,8 @@ * * @see XXXCShardSplitHandler */ - String CONSTRAIN_XXXC_SHARDS = AbstractTripleStore.class.getName() - + ".constrainXXXCShards"; + String CONSTRAIN_XXXC_SHARDS = (AbstractTripleStore.class.getName() + ".constrainXXXCShards") + .intern(); String DEFAULT_CONSTRAIN_XXXC_SHARDS = "true"; @@ -1326,7 +1334,6 @@ // set property that will let the contained relations locate their container. tmp.setProperty(RelationSchema.CONTAINER, getNamespace()); - if (Boolean.valueOf(tmp.getProperty(Options.TEXT_INDEX, Options.DEFAULT_TEXT_INDEX))) { @@ -1437,9 +1444,11 @@ // axioms. map.put(TripleStoreSchema.AXIOMS, axioms); +// setProperty(TripleStoreSchema.AXIOMS,axioms); // vocabulary. map.put(TripleStoreSchema.VOCABULARY, vocab); +// setProperty(TripleStoreSchema.VOCABULARY,vocab); if (lexiconRelation.isTextIndex()) { /* @@ -1548,14 +1557,19 @@ if (axioms == null) { /* - * Extract the de-serialized axiom model from the global row - * store. + * The vocabulary is stored in properties for the triple + * store instance in the global row store. However, we + * pre-materialize those properties so we can directly + * retrieve the vocabulary from the materialized properties. */ - - axioms = (Axioms) getIndexManager().getGlobalRowStore() - .get(RelationSchema.INSTANCE, getNamespace(), - TripleStoreSchema.AXIOMS); + axioms = (Axioms) getBareProperties().get( + TripleStoreSchema.AXIOMS); + +// axioms = (Axioms) getIndexManager().getGlobalRowStore() +// .get(RelationSchema.INSTANCE, getNamespace(), +// TripleStoreSchema.AXIOMS); + if (axioms == null) throw new RuntimeException("No axioms defined? : " + this); @@ -1599,13 +1613,18 @@ if (vocab == null) { /* - * Extract the de-serialized vocabulary from the global row - * store. + * The vocabulary is stored in properties for the triple + * store instance in the global row store. However, we + * pre-materialize those properties so we can directly + * retrieve the vocabulary from the materialized properties. */ - vocab = (Vocabulary) getIndexManager().getGlobalRowStore().get( - RelationSchema.INSTANCE, getNamespace(), + vocab = (Vocabulary) getBareProperties().get( TripleStoreSchema.VOCABULARY); + +// vocab = (Vocabulary) getIndexManager().getGlobalRowStore().get( +// RelationSchema.INSTANCE, getNamespace(), +// TripleStoreSchema.VOCABULARY); if (vocab == null) throw new RuntimeException("No vocabulary defined? : " Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/LocalTripleStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/LocalTripleStore.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/LocalTripleStore.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -33,7 +33,6 @@ import com.bigdata.journal.IIndexManager; import com.bigdata.journal.ITx; import com.bigdata.journal.Journal; -import com.bigdata.rdf.spo.SPORelation; import com.bigdata.relation.locator.DefaultResourceLocator; /** @@ -154,47 +153,131 @@ store = (Journal) indexManager; } - + /** * Create or re-open a triple store using a local embedded database. + * <p> + * Note: This is only used by the test suites. */ - /* public */LocalTripleStore(final Properties properties) { + /* public */static LocalTripleStore getInstance(final Properties properties) { - /* - * FIXME This should pass up the existing properties for the KB instance - * when the KB instance is pre-existing. Really though, you should first - * obtain the Journal and then attempt to locate the KB and create it if - * it does not exist. - */ - this(new Journal(properties), "kb"/* namespace */, ITx.UNISOLATED, - properties); - - /* - * FIXME Modify this to use a row scan for the contained relations. - * There is one other place where the same test is being used. The - * reason for this test is that getSPORelation() tries to _locate_ the - * relation, but that will fail if it does not exist. By using the ctor - * and exists() we can test for pre-existence. However, the best route - * is to perform a row scan when the container is created and then we - * can just materialize the existing relations and create them if they - * are not found. - */ - if (!new SPORelation(getIndexManager(), getNamespace() + "." - + SPORelation.NAME_SPO_RELATION, getTimestamp(), getProperties()).exists()) { + final String namespace = "kb"; + + // create/re-open journal. + final Journal journal = new Journal(properties); + + try { + + // Check for pre-existing instance. + { + final LocalTripleStore lts = (LocalTripleStore) journal + .getResourceLocator().locate(namespace, ITx.UNISOLATED); + + if (lts != null) { + + return lts; + + } + + } + + // Create a new instance. + { + + final LocalTripleStore lts = new LocalTripleStore( + journal, namespace, ITx.UNISOLATED, properties); + +// if (Boolean.parseBoolean(properties.getProperty( +// BigdataSail.Options.ISOLATABLE_INDICES, +// BigdataSail.Options.DEFAULT_ISOLATABLE_INDICES))) { +// +// final long txCreate = txService.newTx(ITx.UNISOLATED); +// +// final AbstractTripleStore txCreateView = new LocalTripleStore( +// journal, namespace, Long.valueOf(txCreate), properties); +// +// // create the kb instance within the tx. +// txCreateView.create(); +// +// // commit the tx. +// txService.commit(txCreate); +// +// } else { + + lts.create(); + +// } + + } + /* - * If we could not find the SPO relation then presume that this is a - * new KB and create it now. + * Now that we have created the instance locate the triple store + * resource and return it. */ - - create(); + { - } else { - - init(); - - } + final LocalTripleStore lts = (LocalTripleStore) journal + .getResourceLocator().locate(namespace, ITx.UNISOLATED); + if (lts == null) { + + /* + * This should only occur if there is a concurrent destroy, + * which is highly unlikely to say the least. + */ + throw new RuntimeException("Concurrent create/destroy: " + + namespace); + + } + + return lts; + + } + + } catch (Throwable ex) { + + journal.shutdownNow(); + + throw new RuntimeException(ex); + + } + +// /* +// * FIXME This should pass up the existing properties for the KB instance +// * when the KB instance is pre-existing. Really though, you should first +// * obtain the Journal and then attempt to locate the KB and create it if +// * it does not exist. +// */ +// this(new Journal(properties), "kb"/* namespace */, ITx.UNISOLATED, +// properties); +// +// /* +// * FIXME Modify this to use a row scan for the contained relations. +// * There is one other place where the same test is being used. The +// * reason for this test is that getSPORelation() tries to _locate_ the +// * relation, but that will fail if it does not exist. By using the ctor +// * and exists() we can test for pre-existence. However, the best route +// * is to perform a row scan when the container is created and then we +// * can just materialize the existing relations and create them if they +// * are not found. +// */ +// if (!new SPORelation(getIndexManager(), getNamespace() + "." +// + SPORelation.NAME_SPO_RELATION, getTimestamp(), getProperties()).exists()) { +// +// /* +// * If we could not find the SPO relation then presume that this is a +// * new KB and create it now. +// */ +// +// create(); +// +// } else { +// +// init(); +// +// } + } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestVocabulary.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestVocabulary.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestVocabulary.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -160,7 +160,7 @@ public void test_RdfsVocabulary() { - Properties properties = getProperties(); + final Properties properties = getProperties(); // override the default. properties.setProperty(Options.VOCABULARY_CLASS, RDFSVocabulary.class Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestTruthMaintenance.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestTruthMaintenance.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/rules/TestTruthMaintenance.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -723,7 +723,7 @@ // add two { - StatementBuffer assertionBuffer = new StatementBuffer(tm + final StatementBuffer assertionBuffer = new StatementBuffer(tm .newTempTripleStore(), store, 100/* capacity */); assertionBuffer.add(a, sco, b ); @@ -746,7 +746,7 @@ // retract one { - StatementBuffer retractionBuffer = new StatementBuffer(tm + final StatementBuffer retractionBuffer = new StatementBuffer(tm .newTempTripleStore(), store, 100/* capacity */); retractionBuffer.add(b, sco, c); @@ -759,7 +759,7 @@ if (log.isInfoEnabled()) log.info("\ndump after retraction and re-closure:\n" - + store.dumpStore(true,true,false)); + + store.dumpStore(true, true, false)); } @@ -770,17 +770,18 @@ */ { - TempTripleStore controlStore = new TempTripleStore(store + final TempTripleStore controlStore = new TempTripleStore(store .getProperties()); // Note: maintains closure on the controlStore. - TruthMaintenance tmControlStore = new TruthMaintenance( + final TruthMaintenance tmControlStore = new TruthMaintenance( controlStore.getInferenceEngine()); try { - StatementBuffer assertionBuffer = new StatementBuffer( - tmControlStore.newTempTripleStore(), controlStore, 100/* capacity */); + final StatementBuffer assertionBuffer = new StatementBuffer( + tmControlStore.newTempTripleStore(), controlStore, + 100/* capacity */); assertionBuffer.add(a, sco, b); // assertionBuffer.add(c, sco, d ); Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalQuadStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalQuadStore.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalQuadStore.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -114,7 +114,7 @@ protected AbstractTripleStore getStore(final Properties properties) { - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } @@ -157,7 +157,7 @@ // Set the file property explicitly. properties.setProperty(Options.FILE, file.toString()); - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStore.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -121,7 +121,7 @@ protected AbstractTripleStore getStore(final Properties properties) { - return new LocalTripleStore( properties ); + return LocalTripleStore.getInstance( properties ); } @@ -164,7 +164,7 @@ // Set the file property explicitly. properties.setProperty(Options.FILE, file.toString()); - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -126,7 +126,7 @@ protected AbstractTripleStore getStore(final Properties properties) { - return new LocalTripleStore( properties ); + return LocalTripleStore.getInstance( properties ); } @@ -169,7 +169,7 @@ // Set the file property explicitly. properties.setProperty(Options.FILE, file.toString()); - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutStatementIdentifiers.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutStatementIdentifiers.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutStatementIdentifiers.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -116,7 +116,7 @@ protected AbstractTripleStore getStore(Properties properties) { - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } @@ -159,7 +159,7 @@ // Set the file property explicitly. properties.setProperty(Options.FILE, file.toString()); - return new LocalTripleStore(properties); + return LocalTripleStore.getInstance(properties); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-03-04 11:06:25 UTC (rev 4272) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-03-04 15:24:20 UTC (rev 4273) @@ -93,7 +93,6 @@ import org.openrdf.query.algebra.TupleExpr; import org.openrdf.query.algebra.ValueConstant; import org.openrdf.query.algebra.Var; -import org.openrdf.query.algebra.evaluation.EvaluationStrategy; import org.openrdf.query.algebra.evaluation.impl.BindingAssigner; import org.openrdf.query.algebra.evaluation.impl.CompareOptimizer; import org.openrdf.query.algebra.evaluation.impl.ConjunctiveConstraintSplitter; @@ -674,8 +673,21 @@ closeOnShutdown = true; } - - private static LocalTripleStore createLTS(Properties properties) { + + /** + * If the {@link LocalTripleStore} with the appropriate namespace exists, + * then return it. Otherwise, create the {@link LocalTripleStore}. When the + * properties indicate that full transactional isolation should be + * supported, a new {@link LocalTripleStore} will be created within a + * transaction in order to ensure that it uses isolatable indices. Otherwise + * it is created using the {@link ITx#UNISOLATED} connection. + * + * @param properties + * The properties. + * + * @return The {@link LocalTripleStore}. + */ + private static LocalTripleStore createLTS(final Properties properties) { final Journal journal = new Journal(properties); @@ -689,23 +701,38 @@ // throws an exception if there are inconsistent properties checkProperties(properties); - final LocalTripleStore lts = new LocalTripleStore( - journal, namespace, ITx.UNISOLATED, properties); - try { - final long tx0 = txService.newTx(ITx.READ_COMMITTED); +// final boolean create; +// final long tx0 = txService.newTx(ITx.READ_COMMITTED); +// try { +// // verify kb does not exist (can not be located). +// create = journal.getResourceLocator().locate(namespace, tx0) == null; +// } finally { +// txService.abort(tx0); +// } + + // Check for pre-existing instance. + { - // verify kb does not exist (can not be located). - final boolean create = - journal.getResourceLocator().locate(namespace, tx0) == null; + final LocalTripleStore lts = (LocalTripleStore) journal + .getResourceLocator().locate(namespace, ITx.UNISOLATED); - txService.abort(tx0); + if (lts != null) { + + return lts; + + } + + } -// if (!new SPORelation(journal, namespace + "." -// + SPORelation.NAME_SPO_RELATION, ITx.UNISOLATED, properties).exists()) { - if (create) { + // Create a new instance. +// if (create) + { + final LocalTripleStore lts = new LocalTripleStore( + journal, namespace, ITx.UNISOLATED, properties); + if (Boolean.parseBoolean(properties.getProperty( BigdataSail.Options.ISOLATABLE_INDICES, BigdataSail.Options.DEFAULT_ISOLATABLE_INDICES))) { @@ -728,6 +755,31 @@ } } + + /* + * Now that we have created the instance, either using a tx or the + * unisolated connection, locate the triple store resource and + * return it. + */ + { + + final LocalTripleStore lts = (LocalTripleStore) journal + .getResourceLocator().locate(namespace, ITx.UNISOLATED); + + if (lts == null) { + + /* + * This should only occur if there is a concurrent destroy, + * which is highly unlikely to say the least. + */ + throw new RuntimeException("Concurrent create/destroy: " + + namespace); + + } + + return lts; + + } } catch (IOException ex) { @@ -735,8 +787,6 @@ } - return lts; - } private static void checkProperties(Properties properties) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |