performance improvements for date literals
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2278b3de Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2278b3de Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2278b3de Branch: refs/heads/master Commit: 2278b3de48d71c2ca9261f27e11000e0a74eacb8 Parents: e30cd53 Author: Sebastian Schaffert <[email protected]> Authored: Mon Mar 31 17:06:23 2014 +0200 Committer: Sebastian Schaffert <[email protected]> Committed: Mon Mar 31 17:06:23 2014 +0200 ---------------------------------------------------------------------- .../org/apache/marmotta/commons/util/DateUtils.java | 13 +++++++++++-- .../kiwi/persistence/pgsql/create_base_tables.sql | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/2278b3de/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java ---------------------------------------------------------------------- diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java index 044cdb5..98dc942 100644 --- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java +++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/util/DateUtils.java @@ -20,7 +20,6 @@ package org.apache.marmotta.commons.util; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; - import java.text.DateFormat; import java.text.DateFormatSymbols; import java.text.ParseException; @@ -47,6 +46,9 @@ public class DateUtils { public static final SimpleDateFormat GMTFORMAT = createDateFormat("EEE, dd MMM yyyy HH:mm:ss z", "GMT"); + + private static DatatypeFactory datatypeFactory; + /** * Some parsers will have the date as a ISO-8601 string * already, and will set that into the Metadata object. @@ -93,6 +95,13 @@ public class DateUtils { } + private static DatatypeFactory getDatatypeFactory() throws DatatypeConfigurationException { + if(datatypeFactory == null) { + datatypeFactory = DatatypeFactory.newInstance(); + } + return datatypeFactory; + } + /** * Parses the given date string. This method is synchronized to prevent * concurrent access to the thread-unsafe date formats. @@ -146,7 +155,7 @@ public class DateUtils { c.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTime(date); try { - return DatatypeFactory.newInstance().newXMLGregorianCalendar(c).normalize(); + return getDatatypeFactory().newXMLGregorianCalendar(c).normalize(); } catch (DatatypeConfigurationException e) { return null; } http://git-wip-us.apache.org/repos/asf/marmotta/blob/2278b3de/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/create_base_tables.sql ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/create_base_tables.sql b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/create_base_tables.sql index c4d9d14..1936a6b 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/create_base_tables.sql +++ b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/create_base_tables.sql @@ -74,6 +74,7 @@ CREATE INDEX idx_reg_tx ON registry(txId); CREATE INDEX idx_node_content ON nodes USING hash(svalue); CREATE INDEX idx_node_dcontent ON nodes(dvalue) WHERE dvalue IS NOT NULL; CREATE INDEX idx_node_icontent ON nodes(ivalue) WHERE ivalue IS NOT NULL; +CREATE INDEX idx_node_tcontent ON nodes(tvalue) WHERE tvalue IS NOT NULL; CREATE INDEX idx_literal_lang ON nodes(lang); CREATE INDEX idx_triples_p ON triples(predicate) WHERE deleted = false;
