Skip to content

Commit

Permalink
add conf entry jdbc.storage_engine to change storage engine (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhenghu authored and zhoney committed Jun 5, 2019
1 parent f3a3c35 commit 033c387
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,12 @@ public static synchronized MysqlOptions instance() {
disallowEmpty(),
"disable"
);

public static final ConfigOption<String> STORAGE_ENGINE =
new ConfigOption<>(
"jdbc.storage_engine",
"The storage engine of backend store database, like InnoDB/MyISAM/RocksDB for MySQL.",
disallowEmpty(),
"InnoDB"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -46,7 +47,7 @@ protected String buildTruncateTemplate() {
}

@Override
protected String engine() {
protected String engine(Session session) {
return Strings.EMPTY;
}

Expand Down

0 comments on commit 033c387

Please sign in to comment.