adding calculation prequirements for accepting strings

This commit is contained in:
jenzur
2019-03-07 18:39:40 +01:00
parent 05683ce4be
commit 66dae4e113
4 changed files with 85 additions and 24 deletions
@@ -7,6 +7,7 @@ package DataLayer;
import FunctionLayer.SimilarityMatrix;
import FunctionLayer.CustomError;
import com.google.common.collect.MapMaker;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -50,8 +51,8 @@ public class DataMapper {
}
}
public static List<String> getAllStrings() throws CustomError {
List<String> str = new ArrayList();
public static ConcurrentMap<Integer, String> getAllStrings() throws CustomError {
ConcurrentMap<Integer, String> allStrings = new MapMaker().concurrencyLevel(2).makeMap();
Connection l_cCon = null;
PreparedStatement l_pStatement = null;
ResultSet l_rsSearch = null;
@@ -62,15 +63,17 @@ public class DataMapper {
java.sql.ResultSet.CONCUR_READ_ONLY);
l_pStatement.setFetchSize(Integer.MIN_VALUE);
l_rsSearch = l_pStatement.executeQuery();
int ij = 0;
while (l_rsSearch.next()) {
str.add(l_rsSearch.getString(1));
allStrings.put(ij, l_rsSearch.getString(1));
ij++;
}
} catch (SQLException ex) {
throw new CustomError("failed in DataMapper " + ex.getMessage());
} finally {
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
}
return str;
return allStrings;
}
public static void InsertMYSQLStrings(ConcurrentMap<Integer, String> str) throws CustomError {