From: <tho...@us...> - 2014-01-17 14:01:48
|
Revision: 7812 http://bigdata.svn.sourceforge.net/bigdata/?rev=7812&view=rev Author: thompsonbry Date: 2014-01-17 14:01:40 +0000 (Fri, 17 Jan 2014) Log Message: ----------- Committing a singleton pattern optimization for the DatatypeFactory used by the DateTimeExtension. This passes local tests for the AST and SPARQL execution test suites. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/extensions/DateTimeExtension.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/extensions/DateTimeExtension.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/extensions/DateTimeExtension.java 2014-01-16 19:30:15 UTC (rev 7811) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/internal/impl/extensions/DateTimeExtension.java 2014-01-17 14:01:40 UTC (rev 7812) @@ -52,6 +52,7 @@ import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.util.InnerCause; /** * This implementation of {@link IExtension} implements inlining for literals @@ -87,16 +88,17 @@ } private void resolve(final IDatatypeURIResolver resolver, final URI uri) { + + if (log.isDebugEnabled()) { + log.debug("resolving: " + uri); + } - if (log.isDebugEnabled()) { - log.debug("resolving: " + uri); - } - final BigdataURI val = resolver.resolve(uri); datatypes.put(val.getIV(), val); } - + + @Override public Set<BigdataURI> getDatatypes() { return new LinkedHashSet<BigdataURI>(datatypes.values()); @@ -182,9 +184,10 @@ final BigdataURI dt = datatypes.get(iv.getExtensionIV()); - final XMLGregorianCalendar xmlGC = - DatatypeFactory.newInstance().newXMLGregorianCalendar(c); + final DatatypeFactory f = datatypeFactorySingleton; + final XMLGregorianCalendar xmlGC = f.newXMLGregorianCalendar(c); + String s = xmlGC.toString(); if (dt.equals(XSD.DATETIME)) { if (BSBMHACK) { @@ -219,12 +222,42 @@ return (V) vf.createLiteral(s, dt); - } catch (DatatypeConfigurationException ex) { + } catch (RuntimeException ex) { + + if (InnerCause.isInnerCause(ex, InterruptedException.class)) { + + throw ex; + + } throw new IllegalArgumentException("bad iv: " + iv, ex); } + + } + + /** Singleton. */ + private static final DatatypeFactory datatypeFactorySingleton; + + /** + * Singleton caching pattern for the Datatype factory reference. + */ + static { + + DatatypeFactory f = null; + try { + + f = DatatypeFactory.newInstance(); + + } catch (DatatypeConfigurationException ex) { + + log.error("Could not configure DatatypeFactory: " + ex, ex); + + } + + datatypeFactorySingleton = f; + } /** @@ -234,5 +267,5 @@ * @see http://sourceforge.net/apps/trac/bigdata/ticket/277 */ static private transient boolean BSBMHACK = Boolean.getBoolean("BSBM_HACK"); - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |