Implement indexes.

This commit is contained in:
Jan Philipp Timme 2017-01-04 11:24:46 +01:00
parent 516e34c6a0
commit abe1e29e75
Signed by untrusted user: JPT
GPG Key ID: 5F2C85EC6F3754B7
1 changed files with 17 additions and 12 deletions

View File

@ -5,7 +5,9 @@ import java.io.IOException;
import com.orientechnologies.orient.client.remote.OServerAdmin; import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.intent.OIntentMassiveInsert; import com.orientechnologies.orient.core.intent.OIntentMassiveInsert;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph.THREAD_MODE; import com.tinkerpop.blueprints.impls.orient.OrientConfigurableGraph.THREAD_MODE;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientEdgeType; import com.tinkerpop.blueprints.impls.orient.OrientEdgeType;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory; import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
@ -107,7 +109,7 @@ public class OrientDbHelperService {
public void setupSchema() { public void setupSchema() {
this.createClasses(); this.createClasses();
this.createClusters(); this.createIndexes();
this.importStaticData(); this.importStaticData();
} }
@ -121,18 +123,21 @@ public class OrientDbHelperService {
} }
} }
private void createClusters() { private void createIndexes() {
OServerAdmin admin = null; OrientGraphNoTx og = this.getOrientGraphFactory().getNoTx();
try { String[] createIndexQueries = {
admin = new OServerAdmin(getDbUri(false)); "CREATE INDEX EthernetFrameTime ON EthernetFrame (timestamp,microseconds) UNIQUE;",
admin.connect(this.user, this.pass); "CREATE INDEX IpPacketPath ON IpPacket (sourceIp, targetIp) NOTUNIQUE_HASH_INDEX;",
// TODO: Create clusters! "CREATE INDEX UdpPacketPath ON UdpPacket (sourcePort, targetPort) NOTUNIQUE_HASH_INDEX;",
} catch (IOException e) { "CREATE INDEX TcpPacketPath ON TcpPacket (sourcePort, targetPort) NOTUNIQUE_HASH_INDEX;",
System.err.println("Failed to create custom clusters!"); "CREATE INDEX TcpConnectionTimes ON TcpConnection (startTs, startMs, endTs, endMs) UNIQUE;",
e.printStackTrace(); "CREATE INDEX Host.ipAddress UNIQUE;",
} finally { "CREATE INDEX WellKnownPort.port UNIQUE;"
admin.close(); };
for(String createIndexQuery : createIndexQueries) {
og.command(new OCommandSQL(createIndexQuery)).execute();
} }
og.shutdown();
} }
private void createClasses() { private void createClasses() {