protected int countBoundValues(BatchStatement bs) { int count = 0; for (Statement s : bs.getStatements()) { if (s instanceof BoundStatement) count += ((BoundStatement) s).wrapper.values.length; else if (s instanceof SimpleStatement) count += ((SimpleStatement) s).valuesCount(); } return count; }
protected String statementAsString(Statement statement) { StringBuilder sb = new StringBuilder(); if (statement instanceof BatchStatement) { BatchStatement bs = (BatchStatement) statement; int statements = bs.getStatements().size(); int boundValues = countBoundValues(bs); sb.append("[" + statements + " statements, " + boundValues + " bound values] "); } else if (statement instanceof BoundStatement) { int boundValues = ((BoundStatement) statement).wrapper.values.length; sb.append("[" + boundValues + " bound values] "); } else if (statement instanceof SimpleStatement) { int boundValues = ((SimpleStatement) statement).valuesCount(); sb.append("[" + boundValues + " bound values] "); } append(statement, sb, maxQueryStringLength); return sb.toString(); }
@Test(groups = "unit") public void should_return_number_of_values() { assertThat(new SimpleStatement("doesn't matter").valuesCount()).isEqualTo(0); assertThat(new SimpleStatement("doesn't matter", 1, 2).valuesCount()).isEqualTo(2); } }
protected int appendParameters(SimpleStatement statement, StringBuilder buffer, int remaining) { if (remaining == 0) return 0; int numberOfParameters = statement.valuesCount(); if (numberOfParameters > 0) { int numberOfLoggedParameters;
/** * Adds a new statement to this batch. * * @param statement the new statement to add. * @return this batch. * @throws IllegalArgumentException if counter and non-counter operations are mixed. */ public Batch add(RegularStatement statement) { boolean isCounterOp = statement instanceof BuiltStatement && ((BuiltStatement) statement).isCounterOp(); if (this.isCounterOp == null) setCounterOp(isCounterOp); else if (isCounterOp() != isCounterOp) throw new IllegalArgumentException( "Cannot mix counter operations and non-counter operations in a batch statement"); this.statements.add(statement); if (statement instanceof BuiltStatement) { this.hasBindMarkers |= ((BuiltStatement) statement).hasBindMarkers; } else { // For non-BuiltStatement, we cannot know if it includes a bind makers and we assume it does. // In practice, // this means we will always serialize values as strings when there is non-BuiltStatement this.hasBindMarkers = true; this.nonBuiltStatementValues += ((SimpleStatement) statement).valuesCount(); } setDirty(); return this; }
protected int countBoundValues(BatchStatement bs) { int count = 0; for (Statement s : bs.getStatements()) { if (s instanceof BoundStatement) count += ((BoundStatement) s).wrapper.values.length; else if (s instanceof SimpleStatement) count += ((SimpleStatement) s).valuesCount(); } return count; }
protected int countBoundValues(BatchStatement bs) { int count = 0; for (Statement s : bs.getStatements()) { if (s instanceof BoundStatement) count += ((BoundStatement) s).wrapper.values.length; else if (s instanceof SimpleStatement) count += ((SimpleStatement) s).valuesCount(); } return count; }
protected int countBoundValues(BatchStatement bs) { int count = 0; for (Statement s : bs.getStatements()) { if (s instanceof BoundStatement) count += ((BoundStatement) s).wrapper.values.length; else if (s instanceof SimpleStatement) count += ((SimpleStatement) s).valuesCount(); } return count; }
protected String statementAsString(Statement statement) { StringBuilder sb = new StringBuilder(); if (statement instanceof BatchStatement) { BatchStatement bs = (BatchStatement) statement; int statements = bs.getStatements().size(); int boundValues = countBoundValues(bs); sb.append("[" + statements + " statements, " + boundValues + " bound values] "); } else if (statement instanceof BoundStatement) { int boundValues = ((BoundStatement) statement).wrapper.values.length; sb.append("[" + boundValues + " bound values] "); } else if (statement instanceof SimpleStatement) { int boundValues = ((SimpleStatement) statement).valuesCount(); sb.append("[" + boundValues + " bound values] "); } append(statement, sb, maxQueryStringLength); return sb.toString(); }
protected String statementAsString(Statement statement) { StringBuilder sb = new StringBuilder(); if (statement instanceof BatchStatement) { BatchStatement bs = (BatchStatement) statement; int statements = bs.getStatements().size(); int boundValues = countBoundValues(bs); sb.append("[" + statements + " statements, " + boundValues + " bound values] "); } else if (statement instanceof BoundStatement) { int boundValues = ((BoundStatement) statement).wrapper.values.length; sb.append("[" + boundValues + " bound values] "); } else if (statement instanceof SimpleStatement) { int boundValues = ((SimpleStatement) statement).valuesCount(); sb.append("[" + boundValues + " bound values] "); } append(statement, sb, maxQueryStringLength); return sb.toString(); }
protected String statementAsString(Statement statement) { StringBuilder sb = new StringBuilder(); if (statement instanceof BatchStatement) { BatchStatement bs = (BatchStatement) statement; int statements = bs.getStatements().size(); int boundValues = countBoundValues(bs); sb.append("[" + statements + " statements, " + boundValues + " bound values] "); } else if (statement instanceof BoundStatement) { int boundValues = ((BoundStatement) statement).wrapper.values.length; sb.append("[" + boundValues + " bound values] "); } else if (statement instanceof SimpleStatement) { int boundValues = ((SimpleStatement) statement).valuesCount(); sb.append("[" + boundValues + " bound values] "); } append(statement, sb, maxQueryStringLength); return sb.toString(); }
@Test(groups = "unit") public void should_return_number_of_values() { assertThat(new SimpleStatement("doesn't matter").valuesCount()).isEqualTo(0); assertThat(new SimpleStatement("doesn't matter", 1, 2).valuesCount()).isEqualTo(2); } }
protected int appendParameters(SimpleStatement statement, StringBuilder buffer, int remaining) { if (remaining == 0) return 0; int numberOfParameters = statement.valuesCount(); if (numberOfParameters > 0) { int numberOfLoggedParameters;
protected int appendParameters(SimpleStatement statement, StringBuilder buffer, int remaining) { if (remaining == 0) return 0; int numberOfParameters = statement.valuesCount(); if (numberOfParameters > 0) { int numberOfLoggedParameters;
protected int appendParameters(SimpleStatement statement, StringBuilder buffer, int remaining) { if (remaining == 0) return 0; int numberOfParameters = statement.valuesCount(); if (numberOfParameters > 0) { int numberOfLoggedParameters;
/** * Adds a new statement to this batch. * * @param statement the new statement to add. * @return this batch. * @throws IllegalArgumentException if counter and non-counter operations * are mixed. */ public Batch add(RegularStatement statement) { boolean isCounterOp = statement instanceof BuiltStatement && ((BuiltStatement) statement).isCounterOp(); if (this.isCounterOp == null) setCounterOp(isCounterOp); else if (isCounterOp() != isCounterOp) throw new IllegalArgumentException("Cannot mix counter operations and non-counter operations in a batch statement"); this.statements.add(statement); if (statement instanceof BuiltStatement) { this.hasBindMarkers |= ((BuiltStatement) statement).hasBindMarkers; } else { // For non-BuiltStatement, we cannot know if it includes a bind makers and we assume it does. In practice, // this means we will always serialize values as strings when there is non-BuiltStatement this.hasBindMarkers = true; this.nonBuiltStatementValues += ((SimpleStatement) statement).valuesCount(); } setDirty(); return this; }
/** * Adds a new statement to this batch. * * @param statement the new statement to add. * @return this batch. * @throws IllegalArgumentException if counter and non-counter operations * are mixed. */ public Batch add(RegularStatement statement) { boolean isCounterOp = statement instanceof BuiltStatement && ((BuiltStatement) statement).isCounterOp(); if (this.isCounterOp == null) setCounterOp(isCounterOp); else if (isCounterOp() != isCounterOp) throw new IllegalArgumentException("Cannot mix counter operations and non-counter operations in a batch statement"); this.statements.add(statement); if (statement instanceof BuiltStatement) { this.hasBindMarkers |= ((BuiltStatement) statement).hasBindMarkers; } else { // For non-BuiltStatement, we cannot know if it includes a bind makers and we assume it does. In practice, // this means we will always serialize values as strings when there is non-BuiltStatement this.hasBindMarkers = true; this.nonBuiltStatementValues += ((SimpleStatement) statement).valuesCount(); } setDirty(); return this; }
/** * Adds a new statement to this batch. * * @param statement the new statement to add. * @return this batch. * @throws IllegalArgumentException if counter and non-counter operations * are mixed. */ public Batch add(RegularStatement statement) { boolean isCounterOp = statement instanceof BuiltStatement && ((BuiltStatement) statement).isCounterOp(); if (this.isCounterOp == null) setCounterOp(isCounterOp); else if (isCounterOp() != isCounterOp) throw new IllegalArgumentException("Cannot mix counter operations and non-counter operations in a batch statement"); this.statements.add(statement); if (statement instanceof BuiltStatement) { this.hasBindMarkers |= ((BuiltStatement) statement).hasBindMarkers; } else { // For non-BuiltStatement, we cannot know if it includes a bind makers and we assume it does. In practice, // this means we will always serialize values as strings when there is non-BuiltStatement this.hasBindMarkers = true; this.nonBuiltStatementValues += ((SimpleStatement) statement).valuesCount(); } setDirty(); return this; }