|
From: <bir...@us...> - 2009-05-20 15:24:28
|
Revision: 118
http://mptstore.svn.sourceforge.net/mptstore/?rev=118&view=rev
Author: birkland
Date: 2009-05-20 15:24:06 +0000 (Wed, 20 May 2009)
Log Message:
-----------
Add initial mysql support, bump minor version
Modified Paths:
--------------
trunk/src/java/org/nsdl/mptstore/MPTStore.properties
Added Paths:
-----------
trunk/src/java/org/nsdl/mptstore/impl/mysql/
trunk/src/java/org/nsdl/mptstore/impl/mysql/MysqlDDLGenerator.java
trunk/src/java/org/nsdl/mptstore/impl/mysql/package.html
Modified: trunk/src/java/org/nsdl/mptstore/MPTStore.properties
===================================================================
--- trunk/src/java/org/nsdl/mptstore/MPTStore.properties 2009-05-20 15:23:10 UTC (rev 117)
+++ trunk/src/java/org/nsdl/mptstore/MPTStore.properties 2009-05-20 15:24:06 UTC (rev 118)
@@ -1,2 +1,2 @@
-mptstore.version = 0.9.3
+mptstore.version = 0.9.4
mptstore.buildDate = @buildDate@
Added: trunk/src/java/org/nsdl/mptstore/impl/mysql/MysqlDDLGenerator.java
===================================================================
--- trunk/src/java/org/nsdl/mptstore/impl/mysql/MysqlDDLGenerator.java (rev 0)
+++ trunk/src/java/org/nsdl/mptstore/impl/mysql/MysqlDDLGenerator.java 2009-05-20 15:24:06 UTC (rev 118)
@@ -0,0 +1,112 @@
+
+package org.nsdl.mptstore.impl.mysql;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.nsdl.mptstore.core.AbstractDDLGenerator;
+
+/** DDLGenerator that works with Mysql.
+ * <p>
+ * The map table DDL defines pKey as a <code>AUTO INCREMENT</code> value
+ * and p as a <code>VARCHAR(N)</code> value, with indexes on each column.
+ * The default length N is 255, but this can be modified by setting a system
+ * property or as a constructor argument.
+ * </p>
+ * <p>
+ * The relationship table DDL defines s and o
+ * as <code>VARCHAR(N)</code> values, with indexes on each column.
+ * The default length N is 255, but this can be modified by setting a system
+ * property or as a constructor argument.
+ * </p>
+ * <p>
+ * The following system properties, if set, modify the default behaviour:
+ * <dl>
+ * <dt>mptstore.mysql.length</dt>
+ * <dd>
+ * Use this to set the specified varchar length when creating map or
+ * predicate tables. Default is 255, but mysql versions greater than
+ * 5.0.3 can accept up to 65536.
+ * Example: <code>-Dmptstore.mysql.length=1024</code>
+ * </dd>
+ *
+ * <dt>mptstore.mysql.engine</dt>
+ * <dd>
+ * Use this to set the default storage engine for newly created tables.
+ * By default, this is unspecified, so mysql is free to choose based on
+ * its own policy.
+ * Example: <code>-Dmptstore.mysql.engine=innodb</code>
+ * </dd>
+ * </dl>
+ * </p>
+ *
+ * @author birkland
+ */
+public class MysqlDDLGenerator
+ extends AbstractDDLGenerator {
+
+ private static final String DEFAULT_VARCHAR_LENGTH = "255";
+
+ /** Property name for specifying default varchar length. */
+ public static final String PROP_TEXT_LENGTH = "mptstore.mysql.length";
+
+ /** Property name for specifying mysql storage engine. */
+ public static final String PROP_STORAGE_ENGINE = "mptstore.mysql.engine";
+
+ private final int _length;
+
+ /**
+ * Construct a MysqlDDLGenerator that uses the default maximum length (255)
+ * for varchar columns that store URIs and literals.
+ */
+ public MysqlDDLGenerator() {
+ _length =
+ new Integer(System.getProperty(PROP_TEXT_LENGTH,
+ DEFAULT_VARCHAR_LENGTH));
+ }
+
+ /**
+ * Construct a DerbyDDLGenerator that uses a given maximum length
+ * for varchar columns that store URIs and literals. For mysql versions
+ * newer than 5.0.3, the maximum is 65535.
+ *
+ * @param length default varchar length.
+ */
+ public MysqlDDLGenerator(final int length) {
+ _length = length;
+ }
+
+ /** {@inheritDoc} */
+ public List<String> getCreateMapTableDDL(final String table) {
+
+ List<String> cmds = new ArrayList<String>();
+ cmds.add("CREATE TABLE " + table + " (\n"
+ + " pKey INT UNIQUE NOT NULL AUTO_INCREMENT,\n"
+ + " p VARCHAR(" + _length + ") UNIQUE NOT NULL\n"
+ + ") " + getEngine());
+ return cmds;
+ }
+
+ /** {@inheritDoc} */
+ public List<String> getCreateSOTableDDL(final String table) {
+
+ List<String> cmds = new ArrayList<String>();
+
+ cmds.add("CREATE TABLE " + table + " (\n"
+ + " s VARCHAR(" + _length + ") NOT NULL,\n"
+ + " o VARCHAR(" + _length + ") NOT NULL,\n"
+ + " INDEX " + table + "_s (s),\n"
+ + " INDEX " + table + "_o (o)\n"
+ + ")" + getEngine());
+ return cmds;
+ }
+
+ private String getEngine() {
+ String engine = "";
+ if (System.getProperty(PROP_STORAGE_ENGINE) != null) {
+ engine = "ENGINE " + System.getProperty(PROP_STORAGE_ENGINE);
+ }
+
+ return engine;
+ }
+}
\ No newline at end of file
Added: trunk/src/java/org/nsdl/mptstore/impl/mysql/package.html
===================================================================
--- trunk/src/java/org/nsdl/mptstore/impl/mysql/package.html (rev 0)
+++ trunk/src/java/org/nsdl/mptstore/impl/mysql/package.html 2009-05-20 15:24:06 UTC (rev 118)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+Classes for using Mysql as the underlying database.
+
+</body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|