From 4f46226ba9daedc4d088daa200433710e61d101f Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Mon, 12 Dec 2016 12:06:38 +0100 Subject: [PATCH] Try an sql based approach for more performance --- .../java/de/hsh/inform/orientdb_project/Main.java | 8 +++++++- .../repository/TcpConnectionRepository.java | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hsh/inform/orientdb_project/Main.java b/src/main/java/de/hsh/inform/orientdb_project/Main.java index 405d629..782d3c2 100644 --- a/src/main/java/de/hsh/inform/orientdb_project/Main.java +++ b/src/main/java/de/hsh/inform/orientdb_project/Main.java @@ -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 result = tcr.findByActiveWhen(901713642); + for(TcpConnectionModel m : result) { + System.out.println(m.toString()); + } // Done odhs.close(); diff --git a/src/main/java/de/hsh/inform/orientdb_project/repository/TcpConnectionRepository.java b/src/main/java/de/hsh/inform/orientdb_project/repository/TcpConnectionRepository.java index c64a7df..beacefb 100644 --- a/src/main/java/de/hsh/inform/orientdb_project/repository/TcpConnectionRepository.java +++ b/src/main/java/de/hsh/inform/orientdb_project/repository/TcpConnectionRepository.java @@ -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 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 vertices = (Iterable) this.ogf.command(new OCommandSQL(sql)).execute(); + return this.getListFromVertices(vertices); } public List getTotalDataVolumeBetweenHosts(String ipA, String ipB) {