diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlOptions.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlOptions.java index 240b7e7deb..7f5ddeffbd 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlOptions.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlOptions.java @@ -97,4 +97,12 @@ public static synchronized MysqlOptions instance() { disallowEmpty(), "disable" ); + + public static final ConfigOption STORAGE_ENGINE = + new ConfigOption<>( + "jdbc.storage_engine", + "The storage engine of backend store database, like InnoDB/MyISAM/RocksDB for MySQL.", + disallowEmpty(), + "InnoDB" + ); } diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java index 9f9feb8610..9411ed5f0e 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlSessions.java @@ -235,6 +235,10 @@ public Session() { } } + public HugeConfig config() { + return MysqlSessions.this.config(); + } + public void open() throws SQLException { if (this.conn != null && !this.conn.isClosed()) { return; diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java index d603ce250f..cd25f763ec 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java @@ -104,7 +104,7 @@ protected void createTable(Session session, TableDefine tableDefine) { } } sql.append("))"); - sql.append(this.engine()); + sql.append(this.engine(session)); sql.append(";"); LOG.debug("Create table: {}", sql); @@ -116,8 +116,9 @@ protected void createTable(Session session, TableDefine tableDefine) { } } - protected String engine() { - return " ENGINE=InnoDB"; + protected String engine(Session session) { + String engine = session.config().get(MysqlOptions.STORAGE_ENGINE); + return " ENGINE=" + engine; } protected void dropTable(Session session) { diff --git a/hugegraph-postgresql/src/main/java/com/baidu/hugegraph/backend/store/postgresql/PostgresqlTable.java b/hugegraph-postgresql/src/main/java/com/baidu/hugegraph/backend/store/postgresql/PostgresqlTable.java index 112036085c..6b118ad401 100644 --- a/hugegraph-postgresql/src/main/java/com/baidu/hugegraph/backend/store/postgresql/PostgresqlTable.java +++ b/hugegraph-postgresql/src/main/java/com/baidu/hugegraph/backend/store/postgresql/PostgresqlTable.java @@ -26,6 +26,7 @@ import com.baidu.hugegraph.backend.store.mysql.MysqlBackendEntry; import com.baidu.hugegraph.backend.store.mysql.MysqlTable; +import com.baidu.hugegraph.backend.store.mysql.MysqlSessions.Session; import com.baidu.hugegraph.type.define.HugeKeys; public abstract class PostgresqlTable extends MysqlTable { @@ -46,7 +47,7 @@ protected String buildTruncateTemplate() { } @Override - protected String engine() { + protected String engine(Session session) { return Strings.EMPTY; }