Try an sql based approach for more performance

This commit is contained in:
Jan Philipp Timme 2016-12-12 12:06:38 +01:00
parent 045f526d79
commit 4f46226ba9
Signed by untrusted user: JPT
GPG Key ID: 5F2C85EC6F3754B7
2 changed files with 16 additions and 3 deletions

View File

@ -1,7 +1,10 @@
package de.hsh.inform.orientdb_project;
import java.util.List;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
import de.hsh.inform.orientdb_project.model.TcpConnectionModel;
import de.hsh.inform.orientdb_project.orientdb.OrientDbHelperService;
import de.hsh.inform.orientdb_project.repository.TcpConnectionRepository;
import de.hsh.inform.orientdb_project.util.ConfigPropertiesReader;
@ -18,7 +21,10 @@ public class Main {
OrientGraphNoTx ogf = odhs.getOrientGraphNoTx();
TcpConnectionRepository tcr = new TcpConnectionRepository(ogf);
tcr.findByActiveWhen(901713642);
List<TcpConnectionModel> result = tcr.findByActiveWhen(901713642);
for(TcpConnectionModel m : result) {
System.out.println(m.toString());
}
// Done
odhs.close();

View File

@ -3,8 +3,9 @@ package de.hsh.inform.orientdb_project.repository;
import java.util.ArrayList;
import java.util.List;
import com.orientechnologies.orient.core.command.OCommandRequest;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.tinkerpop.blueprints.GraphQuery;
import com.tinkerpop.blueprints.Predicate;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
@ -19,6 +20,7 @@ public class TcpConnectionRepository {
}
public List<TcpConnectionModel> findByActiveWhen(long ts) {
/*
GraphQuery gq = this.ogf.query();
gq = gq.has("@class", "TcpConnection");
@ -36,7 +38,12 @@ public class TcpConnectionRepository {
}
}, ts);
return this.getListFromVertices(gq.vertices());
return this.getListFromVertices(gq.vertices());*/
String sql = "SELECT FROM TcpConnection WHERE startTs <= " + ts + " AND endTs >= " + ts + "";
@SuppressWarnings("unchecked") // We know.
Iterable<Vertex> vertices = (Iterable<Vertex>) this.ogf.command(new OCommandSQL(sql)).execute();
return this.getListFromVertices(vertices);
}
public List<TcpConnectionModel> getTotalDataVolumeBetweenHosts(String ipA, String ipB) {