Skip to content

Commit

Permalink
Merge pull request #94 from zznate/preparedcleanup
Browse files Browse the repository at this point in the history
Minor cleanup on prepared statement
  • Loading branch information
edwardcapriolo committed Feb 15, 2013
2 parents 83fb564 + 2a14ffd commit adcf66b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/usergrid/vx/experimental/IntraOp.java
Expand Up @@ -607,17 +607,17 @@ public void execute(IntraReq req, IntraRes res, IntraState state,
int i, Vertx vertx, IntraService is) {
IntraOp op = req.getE().get(i);
Integer id = (Integer) op.getOp().get("pid");
IntraReq preparedReq = state.preparedStatements.get(id);
IntraReq preparedReq = IntraState.preparedStatements.get(id);
if (preparedReq==null){
res.setExceptionAndId( new RuntimeException("ps was null"), id);
}
System.out.println(preparedReq);
Map bind = (Map) op.getOp().get("bind");
System.out.println( "bind " +bind);
state.bindParams = bind;
IntraRes preparedRes = new IntraRes();
is.executeReq(preparedReq, preparedRes, state, vertx);
System.out.println("res "+ preparedRes);
if (preparedRes.getException() != null) {
res.setExceptionAndId(preparedRes.getException(), preparedRes.getExceptionId());
}
res.getOpsRes().putAll(preparedRes.getOpsRes());
}
};
Expand Down
Expand Up @@ -779,18 +779,16 @@ public void preparedStatementTest() throws CharacterCodingException {
.set("keyspace", "myks").set("columnfamily", "mycf"));
IntraRes res2 = new IntraRes();
is.handleIntraReq(r2, res2, x);
Assert.assertEquals(0, res2.getOpsRes().get(0));
//Assert.assertEquals(0, res2.getOpsRes().get(0));
Assert.assertEquals(1, res2.getOpsRes().size());
Integer preparedId = (Integer) res2.getOpsRes().get(0);

IntraReq req3 = new IntraReq();
Map m = new HashMap();
m.put(new Integer(1),"preparedrow1");
req3.add( Operations.executePrepared(0, m));
req3.add( Operations.executePrepared(preparedId, m));
IntraRes res3 = new IntraRes();
is.handleIntraReq(req3, res3, x);
System.out.println(res3.getException());
System.out.println(res3.getExceptionId());
System.out.println(res3.getOpsRes());
List<Map> x = (List<Map>) res3.getOpsRes().get(0);
Assert.assertEquals("preparedvalue1", ByteBufferUtil.string( (ByteBuffer) x.get(0).get("value")));

Expand Down

0 comments on commit adcf66b

Please sign in to comment.