use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method addResourceFeatures.
private void addResourceFeatures(Connection connection, MyInstance inst, Long uid) throws SQLException {
try (PreparedStatement ps = connection.prepareStatement("INSERT INTO " + "features_table (methodName, ldataRef, f1,f3, f4, f5, " + "f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")) {
Method requestMethod = inst.getMethod();
if (requestMethod != null) {
ps.setString(1, requestMethod.code);
} else {
ps.setString(1, null);
}
ps.setLong(2, uid);
double[] features = inst.toDoubleArray();
for (int i = 0; i < features.length; i++) {
int index = i + 3;
if (i == 1) {
ps.setDouble(index, 0);
} else {
ps.setDouble(index, features[i]);
}
}
ps.executeUpdate();
connection.commit();
}
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class LDClustering method addLobStateFeatures.
private void addLobStateFeatures(Connection connection, MyInstance inst, Long uid) throws SQLException {
try (PreparedStatement ps = connection.prepareStatement("INSERT INTO " + "features_table (methodName, ldataRef, f1, f2, f3, f4, f5, " + "f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16) " + "VALUES (?, ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")) {
Method requestMethod = inst.getMethod();
if (requestMethod != null) {
ps.setString(1, requestMethod.code);
} else {
ps.setString(1, null);
}
ps.setLong(2, uid);
double[] features = inst.toDoubleArray();
if (type.equals(method)) {
for (int i = 0; i < features.length; i++) {
int index = i + 3;
if (i == 1) {
ps.setDouble(index, features[i]);
} else {
ps.setDouble(index, 0.0);
}
}
} else {
for (int i = 0; i < features.length; i++) {
int index = i + 3;
ps.setDouble(index, features[i]);
}
}
ps.executeUpdate();
connection.commit();
}
}
use of io.milton.http.Request.Method in project lobcder by skoulouzis.
the class RandomPredictor method getNextState.
@Override
public Vertex getNextState(Vertex currentState) {
String resource;
Method method;
try {
switch(type) {
case state:
resource = getRandomResource();
method = getRandomMethod();
break;
case resource:
resource = getRandomResource();
method = null;
break;
case method:
resource = null;
method = getRandomMethod();
break;
default:
resource = getRandomResource();
method = getRandomMethod();
break;
}
return new Vertex(method, resource);
} catch (SQLException ex) {
Logger.getLogger(RandomPredictor.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
Aggregations