updated calculations, updated handling calculation storages, updated DB retrieval, added Distance object, added levenstein, almost everything in mysqldatahandler,

This commit is contained in:
jenzur
2019-03-03 13:17:07 +01:00
parent aca3d9f9c8
commit f64ce5c5a0
8 changed files with 676 additions and 544 deletions
@@ -14,6 +14,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -168,6 +169,47 @@ public class DataMapper {
}
}
public static LinkedHashMap<String, LinkedHashMap<String, Double>> getAllRelationScores() {
int count = getSementicsDBRows();
int counter2 = 0;
int hardCapRetrieveCount = 500000;
LinkedHashMap<String, LinkedHashMap<String, Double>> LHMSMX = new LinkedHashMap();
while (count > counter2) {
try (Connection l_cCon = DBCPDataSource.getConnection()) {
l_cCon.setAutoCommit(false);
String l_sSQL = "SELECT * FROM `WordMatrix` WHERE ID > " + counter2 + " AND ID < " + (counter2 + hardCapRetrieveCount);
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL, java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY)) {
l_pStatement.setFetchSize(Integer.MIN_VALUE);
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
int i = 0;
LinkedHashMap<String, Double> LHMLocal = new LinkedHashMap();
while (l_rsSearch.next() && i < hardCapRetrieveCount) {
String str1 = l_rsSearch.getString(1);
String str2 = l_rsSearch.getString(2);
Double score = l_rsSearch.getDouble(3);
LHMLocal.put(str2, score);
while (l_rsSearch.next() && i < hardCapRetrieveCount && str1.equals(l_rsSearch.getString(1))) {
str2 = l_rsSearch.getString(2);
score = l_rsSearch.getDouble(3);
LHMLocal.put(str2, score);
i++;
counter2++;
}
LHMSMX.put(str1, LHMLocal);
System.out.println("i: " + i + "\n" + "free memory: " + Runtime.getRuntime().freeMemory() + "\ncounter2: " + counter2 + "\n");
i++;
counter2++;
}
}
}
} catch (SQLException ex) {
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
}
}
return LHMSMX;
}
public static void CloseConnections(PreparedStatement ps, ResultSet rs, Connection con) {
if (rs != null) {
try {
@@ -191,4 +233,5 @@ public class DataMapper {
}
}
}
}