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..810f56b90f 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<>( + "mysql.engine", + "the storage engine to store graph data/schema, innodb or rocksdb.", + disallowEmpty(), + "InnoDB" + ); } diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java index 3c39ddbbc6..7f65616f76 100644 --- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java +++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlStore.java @@ -269,9 +269,8 @@ public String toString() { } protected void initTables() { - Session session = this.sessions.session(); for (MysqlTable table : this.tables()) { - table.init(session); + table.init(this.sessions); } } 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..d693ef2122 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 @@ -58,15 +58,22 @@ public abstract class MysqlTable // The template for insert and delete statements private String insertTemplate; private String deleteTemplate; + private MysqlSessions sessions; public MysqlTable(String table) { super(table); this.insertTemplate = null; this.deleteTemplate = null; + this.sessions = null; } public abstract TableDefine tableDefine(); + public void init(MysqlSessions sessions) { + this.sessions = sessions; + this.init(sessions.session()); + } + @Override public void init(Session session) { this.createTable(session, this.tableDefine()); @@ -117,7 +124,11 @@ protected void createTable(Session session, TableDefine tableDefine) { } protected String engine() { - return " ENGINE=InnoDB"; + StringBuilder sql = new StringBuilder(); + sql.append(" ENGINE="); + sql.append(this.sessions.config().get(MysqlOptions.STORAGE_ENGINE)); + LOG.debug("MySQL storage engine innodb/rocksdb: {}", sql.toString()); + return sql.toString(); } protected void dropTable(Session session) {