id
stringlengths
36
36
text
stringlengths
1
1.25M
12cf6a93-99cc-4f0f-bdfb-47bfab21e647
private int[] getIndexes(String name) { int[] indexes = (int[]) indexMap.get(name); if (indexes == null) { throw new IllegalArgumentException("Parameter not found: " + name); } return indexes; }
66b6623e-6c4f-47e5-a5cd-ffc8a1c8e32c
public void setObject(String name, Object value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setObject(indexes[i], value); } }
0c9e4679-b842-4a3d-97cd-d71af01e2c80
public void setString(String name, String value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setString(indexes[i], value); } }
5c1ff0ee-9416-4596-965c-0105600a6d04
public void setInt(String name, int value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setInt(indexes[i], value); } }
91cc5e5f-c931-41df-bd6f-9020f90c3910
public void setLong(String name, long value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setLong(indexes[i], value); } }
3f9980d6-e5f0-4a47-8b99-9b8c5916826f
public void setFloat(String name, float value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setFloat(indexes[i], value); } }
27268f2e-4e2e-43ca-8d2c-32b573f1506f
public void setDouble(String name, double value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setDouble(indexes[i], value); } }
7582af8d-b080-4869-9708-6c1518a0da27
public void setBigDecimal(String name, BigDecimal value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setBigDecimal(indexes[i], value); } }
0165e45e-2a72-4aff-9c0a-f7410825d3c6
public void setBytes(String name, byte[] data) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setBytes(indexes[i], data); } }
e5040ebe-27ad-4995-bd56-4adb5e3d9aff
public void setTimestamp(String name, Timestamp value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setTimestamp(indexes[i], value); } }
9ed9abb7-3373-4792-b4f1-854696cfb345
public void setDate(String name, Date value) throws SQLException { int[] indexes = getIndexes(name); for (int i = 0; i < indexes.length; i++) { statement.setDate(indexes[i], new java.sql.Date(value.getTime())); } }
a45b81ee-088b-4e89-af46-b2559a34ec59
public PreparedStatement getStatement() { return statement; }
fe48595e-5102-4196-8489-5915ed89ad0c
public boolean execute() throws SQLException { return statement.execute(); }
b30a7ec6-014e-4bac-875a-c36ae96e9da5
public ResultSet executeQuery() throws SQLException { return statement.executeQuery(); }
ca488b62-bbaf-4288-8d7c-771b7f896baf
public int executeUpdate() throws SQLException { return statement.executeUpdate(); }
314c3744-09a1-4b33-9a90-eb8cfbfdb9b6
public void close() throws SQLException { statement.close(); }
ca8bc9ef-ea65-4267-9acb-b9511103999e
public void addBatch() throws SQLException { statement.addBatch(); }
ead35d7c-450b-455e-8184-d5890cef48c2
public int[] executeBatch() throws SQLException { return statement.executeBatch(); }
b04b8ffb-3c3e-461c-8f72-6cf070731f9e
public TransactionImpl(Connection connection) throws SQLException { this.connection = connection; this.connection.setAutoCommit(false); }
8dd7fb1a-d685-4562-ab39-8c28631c3357
@Override public void commit() throws SQLException { this.connection.commit(); JdbcUtil.close(this.connection); }
ffc259f0-4928-4043-8c9a-d15b2e4f044e
@Override public void rollback() throws SQLException { this.connection.rollback(); JdbcUtil.close(this.connection); }
dc3306f8-5153-4cd5-b339-19f6e6d4306a
@Override public Query query(String statement) throws SQLException { return new QueryImpl(connection, statement, false); }
70dd6e29-55bb-4e80-8a8e-ea2c4e07863e
@Override public Update update(String statement) throws SQLException { return new UpdateImpl(connection, statement, false); }
421b48c6-f0fe-4d68-b270-549fa35f0e4c
public UpdateImpl(Connection connection, String statement, boolean autoClose) throws SQLException { super(connection, statement); this.autoClose = autoClose; }
8932029a-76cb-4de4-992d-dd5882be973b
@Override public void execute() throws SQLException { namedParameterStatement.execute(); if (autoClose) { close(); } }
91456f9e-f375-4c18-968d-a1e775a29e9d
public Statement(Connection connection, String statement) throws SQLException { con = connection; namedParameterStatement = new NamedParameterStatement(connection, statement); }
ac252c8d-7d7f-456c-b9ca-b8ffb1c9d118
public T setString(String name, String value) { try { namedParameterStatement.setString(name, value); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
fc45f94d-9957-4bf0-aa4a-9c411653942e
public T setInteger(String name, Integer value) { try { namedParameterStatement.setInt(name, value); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
c63ea1ef-5b3c-4289-a501-b81172ee58d3
public T setLong(String name, Long value) { try { namedParameterStatement.setLong(name, value); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
f6f2d4f6-0776-441a-9637-c49fdadeff14
public T setDate(String name, Date value) { try { namedParameterStatement.setDate(name, value); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
7b5151fb-9c3f-4f55-816b-95a90e43887a
public T setBoolean(String name, Boolean value) { try { namedParameterStatement.setObject(name, value); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
02a524ae-3df2-4b4b-8eca-24bc2cabe34c
public T setTimestamp(String name, Date value) { try { namedParameterStatement.setTimestamp(name, new Timestamp(value.getTime())); return (T)this; } catch (SQLException e) { throw new DatabaseException(e); } }
110d6730-b58e-4d74-a243-338a4ed2bcf9
public void close() { if (namedParameterStatement != null) { try { namedParameterStatement.close(); } catch (SQLException e) { //Ignore } } if (con != null) { try { con.close(); } catch ...
b415946f-c8fe-455e-a571-a2c258fa427f
public static void close(Connection con) { if (con != null) { try { con.close(); } catch (SQLException ex) { ex.printStackTrace(); } } }
30db49dd-180f-48ec-9748-4011a736df12
public static void close(PreparedStatement ps) { if (ps != null) { try { ps.close(); } catch (SQLException ex) { ex.printStackTrace(); } } }
87717b9d-102d-4709-8add-ca2c57dc49df
public static void close(ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException ex) { ex.printStackTrace(); } } }
02865fb5-87ac-4a2f-82a1-f3a0cac99396
public QueryImpl(Connection connection, String statement, boolean autoClose) throws SQLException { super(connection, statement); this.autoClose = autoClose; }
043f54bd-5330-4e69-bf35-cfdc638c6355
@Override public List<T> queryForList(RowMapper<T> rowMapper) throws SQLException { List<T> out = new ArrayList<T>(); ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); while (rs.next()) { out.add(rowMapper.mapRow(rs)); ...
a859555f-7677-4bd2-a6e0-569618887c59
@Override public Object queryForObject(RowMapper rowMapper) throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return rowMapper.mapRow(rs); } return null; } finally { ...
91d665d0-6b06-456b-87a9-83eea78982b1
@Override public String queryForString() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return rs.getString(1); } return null; } finally { JdbcUtil.clos...
d60e0c70-9b82-47ab-b64a-d9a3b670ae2f
@Override public Integer queryForInteger() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return Integer.valueOf(rs.getInt(1)); } return null; } finally { ...
32784600-fd7e-4f75-8a34-70042b9d8344
@Override public Long queryForLong() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return rs.getLong(1); } return null; } finally { JdbcUtil.close(rs);...
c54ec4be-b2c3-4b62-bb18-e20399f5e2ff
@Override public Date queryForDate() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return rs.getDate(1); } return null; } finally { JdbcUtil.close(rs);...
6e9e9c8f-eafc-483a-8bdb-955ade57c1cd
@Override public Date queryForTimestamp() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return new Date(rs.getTimestamp(1).getTime()); } return null; } finally { ...
47e16811-317e-428c-9311-9993a0709635
@Override public Boolean queryForBoolean() throws SQLException { ResultSet rs = null; try { rs = namedParameterStatement.executeQuery(); if (rs.next()) { return rs.getBoolean(1); } return null; } finally { JdbcUtil.c...
cde88224-632d-439f-8fb1-30bb3b56b1cd
@org.junit.Test public void testQuery() throws Exception { //given Database db = new Database("org.h2.Driver", "jdbc:h2:target/test", "sa", ""); //when db.update("DROP TABLE IF EXISTS test ").execute(); db.update("CREATE TABLE test(val1 int, val2 varchar(10), val3 date)").e...
7b39de98-e9ae-4ef4-8b13-c6ad8432d33c
@Override public Test mapRow(ResultSet rs) throws SQLException { return new Test(rs.getInt("val1"), rs.getString("val2"), rs.getDate("val3")); }
5c9e597f-3cf8-46d5-89dd-ecd4293f60a7
@org.junit.Test public void testUpdate() throws Exception { //given Database db = new Database("org.h2.Driver", "jdbc:h2:target/test", "sa", ""); //when db.update("DROP TABLE IF EXISTS test ").execute(); db.update("CREATE TABLE test (val1 int, val2 varchar(10), val3 date)")....
1e6e2132-967a-4c8d-a718-2e16a60ef226
@org.junit.Test public void testStartTransaction() throws Exception { //given Database db = new Database("org.h2.Driver", "jdbc:h2:target/test", "sa", ""); //when db.update("DROP TABLE IF EXISTS test ").execute(); db.update("CREATE TABLE test (val1 int, val2 varchar(10), val...
11866adc-9877-46f3-acff-c9abcd9e823a
Test(int val1, String val2, Date val3) { this.val1 = val1; this.val2 = val2; this.val3 = val3; }
04276666-4f03-43e7-8d87-fbd98a48778c
public int getVal1() { return val1; }
97e759c6-97a0-4ac9-a24f-9f3ff1e86798
public String getVal2() { return val2; }
c99b1841-bc1e-4164-8e0f-b39250665164
public Date getVal3() { return val3; }
c38d4b3b-0619-40c6-a385-60bec402d4e6
public int compare(Task t1, Task t2) { if(t1.get_cTime()<t2.get_cTime()) return -1; else if(t1.get_cTime()==t2.get_cTime()) return 0; else if(t1.get_cTime()>t2.get_cTime()) return 1; return -2; }
aea38cad-9e76-4fb7-97ea-b2b020c1a331
public ETCGenerator(int NUM_MACHINES, int NUM_TASKS, TaskHeterogeneity TASK_HETEROGENEITY, MachineHeterogeneity MACHINE_HETEROGENEITY) { m=NUM_MACHINES; n=NUM_TASKS; e=new int[n][m];/*e[i][j] represents the time taken to complete the ith task on the jth machine.*/ T_t=TASK_HETEROGENEITY....
b6beca56-c1db-47e8-bdbf-20eb81fec5c8
public ETCGenerator ETCEngine(int NUM_MACHINES, int NUM_TASKS, TaskHeterogeneity TASK_HETEROGENEITY, MachineHeterogeneity MACHINE_HETEROGENEITY) { m=NUM_MACHINES; n=NUM_TASKS; e=new int[n][m];/*e[i][j] represents the time taken to complete the ith task on the jth machine.*/ T_t=TASK_HETE...
a335d249-54e5-4ad4-a756-302b3992217a
private void generateETC(){ Random rt=new Random(); Random rm=new Random(); int q[]=new int[n]; for(int i=0;i<n;i++){ int N_t=rt.nextInt(T_t); q[i]=N_t; } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ int N_m=rm.nextInt(T...
9b4eb8e4-16cb-45b5-bbf7-2eb779510f6a
public int[][] getETC(){ generateETC(); return e; }
6335c974-c5af-4250-bf96-6c7d0dd46ab8
@Override public String toString(){ String s=Arrays.deepToString(this.getETC()); return s; }
12c69ed0-8a7b-441b-a353-6e2ee6694716
public static void main(String...args){ TaskHeterogeneity TH = null; MachineHeterogeneity MH=null; int ee[][]=new ETCGenerator(3,10,TH.LOW,MH.LOW).getETC(); out.println(Arrays.deepToString(ee)); }
b745bd2d-2e24-4df2-886c-6db4cd8af56f
public SimulatorEngine(int NUM_MACHINES, int NUM_TASKS, double ARRIVAL_RATE, int metaSetSize,Heuristic HEURISTIC, TaskHeterogeneity th, MachineHeterogeneity mh){ sigma=0; makespan=0; MH=mh; TH=th; n=NUM_TASKS; S=metaSetSize; m=NUM_MACHINES; lambd...
581f4da7-a04b-44bd-9317-9320d8e481f0
private void generateRandoms(){ arrivals=new ArrivalGenerator(n,lambda).getArrival(); etc=new ETCGenerator(m,n,TH,MH).getETC(); }
3500be93-b276-4421-a239-442db179776f
public void newSimulation(boolean generateRandoms){ makespan=0; sigma=0; if(generateRandoms) generateRandoms(); for(int i=0;i<m;i++){ mat[i]=0; p[i].clear(); } }
45a618ec-4424-4f5c-b7d6-cedbd240456c
public void setHeuristic(Heuristic h){ this.eng.h=h; }
3dca9677-676b-4f0f-bf56-cfccbf70a141
public long getMakespan() { return makespan; }
4627eb11-50fe-40ed-8466-7165350acfe9
public int[] getArrivals() { return arrivals; }
da1d9536-4152-4c33-862a-1fed85b4c41d
public int[][] getEtc() { return etc; }
0a29590f-c2aa-4007-b493-ed3e531244fe
public void mapTask(Task t, int machine){ t.set_eTime(etc[t.tid][machine]); t.set_cTime( mat[machine]+etc[t.tid][machine] ); p[machine].offer(t); mat[machine]=t.cTime; }
f299c138-2960-4a6b-a024-70cfdce34598
public void simulate(){ /*tick represents the current time*/ int tick=0; Vector<Task> metaSet=new Vector<Task>(S); int i1=0; int i2=S; /*Initialization*/ /*Add the first S tasks to the meta set and schedule them*/ for(int i=i1;i<i2;i++){ Task...
bd4b86b8-4a29-4b45-a973-de9fe76ecd53
private void removeCompletedTasks(int currentTime){ for(int i=0;i<this.m;i++){ if(!p[i].isEmpty()){ Task t=p[i].peek(); while(t.cTime<=currentTime){ sigma+=t.cTime; makespan=max(makespan,t.cTime);...
d7b5a908-e204-4221-9838-7972b6579967
private boolean discontinueSimulation(){ boolean result=true; for(int i=0;i<this.m && result;i++) result=result && p[i].isEmpty(); return result; }
b00b293f-9588-49bb-a46e-616bd551cd79
private long max(long a,long b){ if(a>b) return a; else return b; }
836542b9-8143-4f0f-a763-873949225d03
private long min(long a,long b){ if(a<b) return a; else return b; }
624af9d4-859a-4cb2-ad76-b6ac8cb5c75f
public SchedulingEngine(SimulatorEngine sim,Heuristic heuristic){ h=heuristic; this.sim=sim; }
c1a96410-087c-4f31-97d9-e69fc0c0ee23
public void schedule(Vector<Task> metaSet,int currentTime){ /*If any machine has zero assigned tasks then set mat[] for that machine to be the current time.*/ for(int i=0;i<sim.m;i++){ if(sim.p[i].isEmpty()){ sim.mat[i]=currentTime; } } if(h==Heu...
a566bc2d-79fd-498f-b606-c11a4906b243
private void schedule_MET(Vector<Task> metaSet,int currentTime){ int minExecTime=Integer.MAX_VALUE; int machine=0; for(int i=0;i<metaSet.size();i++){ Task t=metaSet.elementAt(i); for(int j=0;j<sim.m;j++){ if( sim.etc[t.tid][j] < minExecTime){ ...
3b74b3cc-d03d-43fc-bca4-dea5e2e42ebb
private void schedule_MCT(Vector<Task> metaSet,int currentTime){ int minComplTime=Integer.MAX_VALUE; int machine=0; for(int i=0;i<metaSet.size();i++){ Task t=metaSet.elementAt(i); for(int j=0;j<sim.m;j++){ if( sim.etc[t.tid][j] + sim.mat[j] < minC...
0804efe4-932c-4e8e-9d84-c135465bfd01
private void schedule_MinMin(Vector<Task> metaSet, int currentTime){ /*We do not actually delete the task from the meta-set rather mark it as removed*/ boolean[] isRemoved=new boolean[metaSet.size()]; /*Matrix to contain the completion time of each task in the meta-set on each machine.*/ ...
44ba7a7a-1341-45a0-9704-081b09c27290
private void schedule_MaxMin(Vector<Task> metaSet, int currentTime){ /*We do not actually delete the task from the meta-set rather mark it as removed*/ boolean[] isRemoved=new boolean[metaSet.size()]; /*Matrix to contain the completion time of each task in the meta-set on each machine.*/ ...
e1d4a562-7f7c-4033-91e4-7e9643749326
private int[][] schedule_MinMinHelper(Vector<Task> metaSet){ int c[][]=new int[metaSet.size()][sim.m]; int i=0; for(Iterator it=metaSet.iterator();it.hasNext();){ Task t=(Task)it.next(); for(int j=0;j<sim.m;j++){ c[i][j]=sim.mat[j]+sim.etc[t.tid][j]; ...
a014f6cf-6014-4c88-ac43-004bb9ee25b0
private void schedule_Sufferage(Vector<Task> metaSet, int currentTime) { /*We don't directly add the tasks to the p[] matrix of simulator rather add in this copy first*/ Vector<TaskWrapper> pCopy[]=new Vector[sim.m]; /*Copy of mat matrix*/ int[] matCopy=new int[sim.m]; ...
e782999c-d0ac-4ff0-90a7-11314a820e9e
private void mapTaskCopy(Task t, int machine, Vector<TaskWrapper> pCopy[], int mat[],int index){ t.set_eTime(sim.etc[t.tid][machine]); t.set_cTime( mat[machine]+sim.etc[t.tid][machine] ); TaskWrapper tw=new TaskWrapper(index,t); pCopy[machine].add(tw); mat[machine]=t.cTime; ...
6e1a4d0b-1dcf-4505-a56c-a0710aa18491
private void schedule_MinMean(Vector<Task> metaSet, int currentTime) { /*We don't directly add the tasks to the p[] matrix of simulator rather add in this copy first*/ Vector<TaskWrapper> pCopy[]=new Vector[sim.m]; /*Copy of mat matrix*/ int[] matCopy=new int[sim.m]; for(int i...
803d299c-2d19-47e3-bcdc-d792a88896a7
private void schedule_MinMinCopy(Vector<Task> metaSet, int currentTime, Vector<TaskWrapper>[] pCopy, int[] matCopy){ /*We do not actually delete the task from the meta-set rather mark it as removed*/ boolean[] isRemoved=new boolean[metaSet.size()]; /*Matrix to contain the completion time of ea...
044c18d1-1bf2-49cb-91ef-921f674f390a
private int[][] schedule_MinMinCopyHelper(Vector<Task> metaSet, int[] matCopy){ int c[][]=new int[metaSet.size()][sim.m]; int i=0; for(Iterator it=metaSet.iterator();it.hasNext();){ Task t=(Task)it.next(); for(int j=0;j<sim.m;j++){ c[i][j]=matCopy[j]+sim.e...
dc9c7848-97e3-4dfc-a33a-d6fe30a094f1
private void schedule_MinVar(Vector<Task> metaSet, int currentTime) { /*We don't directly add the tasks to the p[] matrix of simulator rather add in this copy first*/ Vector<TaskWrapper> pCopy[]=new Vector[sim.m]; /*Copy of mat matrix*/ int[] matCopy=new int[sim.m]; for(int i=0...
3610259a-b732-4ebb-938b-07546ff4d3bc
private void schedule_NovelI(Vector<Task> metaSet, int currentTime){ }
96ebdd89-3e68-4363-a560-06a27ac1cdb3
public RandomGenerator(double lambda){ r=new Random(); this.lambda=lambda; }
efabaafd-283f-48a6-a881-f5d13861c843
public int nextPoisson() { double L = Math.exp(-lambda); double p = 1.0; int k = 0; do { k++; p *= r.nextDouble(); } while (p > L); return k - 1; }
5aa27df2-bf12-4123-8aac-c96a4d91056b
public static void main(String...args){ int lambda=2; RandomGenerator rg=new RandomGenerator(lambda); int sum=0; double n_trials=100.0; for(int i=0;i<n_trials;i++){ int a=rg.nextPoisson(); sum+=a; out.print(a); } out.println("\...
8de52407-cb0e-4238-b103-f20c2b7bc017
private TaskHeterogeneity(int h){ this.h=h; }
27a3fff7-ce96-445f-bf33-40b0b00e6215
public int getNumericValue(){ return h; }
ed4a95ec-4684-40c5-b1f5-1efc899a850c
public TaskWrapper(int index, Task task){ i=index; t=task; }
84b73db3-73ca-484b-88cc-a49679e74423
public int getIndex() { return i; }
67c2e7a1-5673-4527-bdf6-28a4ee6486f6
public Task getTask() { return t; }
0069bc67-de50-4ec9-8ef2-fbb4827253ad
public static void main(String...args){ long t1=System.currentTimeMillis(); /*Specify the parameters here*/ int NUM_MACHINES=29; int NUM_TASKS=500; double ARRIVAL_RATE=19; int metaSetSize=29; Heuristic h=null; TaskHeterogeneity TH=null; Machine...
d4548062-a312-4dfd-af35-5331b8ce255f
public ArrivalGenerator(int NUM_TASKS, double Lambda){ arrival_time=new int[NUM_TASKS]; lambda=Lambda; }
19f48f3f-6682-4183-9a40-93d3769fafaf
public ArrivalGenerator ArrivalGenerator(int NUM_TASKS, double Lambda){ arrival_time=new int[NUM_TASKS]; lambda=Lambda; return this; }
d62fd4e3-363a-4867-9045-665cc10690f3
private void generateArrival(){ RandomGenerator r= new RandomGenerator(lambda); arrival_time[0]=r.nextPoisson(); for(int i=1;i<arrival_time.length;i++){ arrival_time[i]=arrival_time[i-1]+r.nextPoisson(); } }
aeacad7b-8c44-46f5-ae4b-7ac99d8f69c0
public int[] getArrival(){ generateArrival(); return arrival_time; }